Skip to content

Remove permission from ResourceGroup cmdlet output #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ public sealed class NewAzureResourceCmdlet : ResourceManipulationCmdletBase
protected override void OnProcessRecord()
{
base.OnProcessRecord();
if(this.IsFullObject.IsPresent)
{
this.WriteWarning("The IsFullObject parameter is obsolete and will be removed in future releases.");
}

var resourceId = this.GetResourceId();
this.ConfirmAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public void RemoveDeployment()

cmdlet.ResourceGroupName = resourceGroupName;
cmdlet.Name = deploymentName;
cmdlet.PassThru = true;
cmdlet.Force = true;

cmdlet.ExecuteCmdlet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void StopsActiveDeployment()
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);

cmdlet.ResourceGroupName = resourceGroupName;
cmdlet.PassThru = true;
cmdlet.Force = true;

cmdlet.ExecuteCmdlet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function Test-RemoveDeployment
# Test
New-AzureRmResourceGroup -Name $rgName -Location "west us"
$deployment = New-AzureRmResourceGroupDeployment -ResourceGroupName $rgName -Name $deploymentName -TemplateUri $templateUri
Assert-True { Remove-AzureRmResourceGroupDeployment -ResourceGroupName $deployment.ResourceGroupName -Name $deployment.DeploymentName -Force -PassThru }
Assert-True { Remove-AzureRmResourceGroupDeployment -ResourceGroupName $deployment.ResourceGroupName -Name $deployment.DeploymentName -Force }
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1683,13 +1683,6 @@ Tags:
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>ProvisioningState</maml:name>
<maml:description>
<maml:para>Gets only the deployments with the specified provisioning state. Valid values include, but are not limited to: Canceled, Deprovisioning, Failed, NotProvisioned, Provisioned, Provisioning, and Succeeded. This parameter is optional. By default, Get-AzureRmResourceGroupDeployment returns all deployments for the specified resource group.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Profile</maml:name>
<maml:description>
Expand Down Expand Up @@ -1726,19 +1719,6 @@ Tags:
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>ProvisioningState</maml:name>
<maml:description>
<maml:para>Gets only the deployments with the specified provisioning state. Valid values include, but are not limited to: Canceled, Deprovisioning, Failed, NotProvisioned, Provisioned, Provisioning, and Succeeded. This parameter is optional. By default, Get-AzureRmResourceGroupDeployment returns all deployments for the specified resource group.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Profile</maml:name>
<maml:description>
Expand Down Expand Up @@ -1865,27 +1845,6 @@ Outputs :</dev:code>
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------------------- Example 3: Get a deployment by provisioning state --------------------------</maml:title>
<maml:introduction>
<maml:paragraph>PS C:\&gt;</maml:paragraph>
</maml:introduction>
<dev:code>PS C:\&gt;Get-AzureRmResourceGroupDeployment -ResourceGroupName ContosoLabsRG -ProvisioningState NotProvisioned</dev:code>
<dev:remarks>
<maml:para>This command gets the deployments of the ContosoLabsRG resource group that are not yet provisioned.</maml:para>
<maml:para />
<maml:para />
<maml:para>
</maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText>
<maml:para />
</command:commandText>
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------------------- Example 4: Get the deployments of all resource groups --------------------------</maml:title>
<maml:introduction>
Expand Down Expand Up @@ -9156,13 +9115,6 @@ Tags:
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="3">
<maml:name>PassThru</maml:name>
<maml:description>
<maml:para>Returns $True when the stopping operation succeeds and $False when it fails. By default, this cmdlet does not generate any output.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Profile</maml:name>
<maml:description>
Expand Down Expand Up @@ -9212,19 +9164,6 @@ Tags:
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="3">
<maml:name>PassThru</maml:name>
<maml:description>
<maml:para>Returns $True when the stopping operation succeeds and $False when it fails. By default, this cmdlet does not generate any output.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Profile</maml:name>
<maml:description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ public string ResourcesTable

public string ProvisioningState { get; set; }

public List<PSPermission> Permissions { get; set; }

public string PermissionsTable
{
get { return ResourcesExtensions.ConstructPermissionsTable(Permissions); }
}

public Hashtable[] Tags { get; set; }

public string TagsTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,6 @@ public virtual PSResourceGroupDeployment ExecuteDeployment(CreatePSResourceGroup
parameters.DeploymentName = GenerateDeploymentName(parameters);
Deployment deployment = CreateBasicDeployment(parameters, parameters.DeploymentMode);

if (!string.IsNullOrEmpty(parameters.StorageAccountName))
{
WriteWarning("The StorageAccountName parameter is no longer used and will be removed in a future release. Please update scripts to remove this parameter.");
}

ResourceManagementClient.Deployments.CreateOrUpdate(parameters.ResourceGroupName, parameters.DeploymentName, deployment);
WriteVerbose(string.Format("Create template deployment '{0}'.", parameters.DeploymentName));
DeploymentExtended result = ProvisionDeploymentStatus(parameters.ResourceGroupName, parameters.DeploymentName, deployment);
Expand Down Expand Up @@ -463,22 +458,14 @@ public virtual List<PSResourceGroupDeployment> FilterResourceGroupDeployments(Fi
string resourceGroup = options.ResourceGroupName;
string name = options.DeploymentName;
List<string> excludedProvisioningStates = options.ExcludedProvisioningStates ?? new List<string>();
List<string> provisioningStates = options.ProvisioningStates ?? new List<string>();

if (!string.IsNullOrEmpty(resourceGroup) && !string.IsNullOrEmpty(name))
{
deployments.Add(ResourceManagementClient.Deployments.Get(resourceGroup, name).ToPSResourceGroupDeployment(options.ResourceGroupName));
}
else if (!string.IsNullOrEmpty(resourceGroup))
{
DeploymentListParameters parameters = new DeploymentListParameters();

if (provisioningStates.Count == 1)
{
parameters.ProvisioningState = provisioningStates.First();
}

DeploymentListResult result = ResourceManagementClient.Deployments.List(resourceGroup, parameters);
DeploymentListResult result = ResourceManagementClient.Deployments.List(resourceGroup, null);

deployments.AddRange(result.Deployments.Select(d => d.ToPSResourceGroupDeployment(options.ResourceGroupName)));

Expand All @@ -489,12 +476,7 @@ public virtual List<PSResourceGroupDeployment> FilterResourceGroupDeployments(Fi
}
}

if (provisioningStates.Count > 1)
{
return deployments.Where(d => provisioningStates
.Any(s => s.Equals(d.ProvisioningState, StringComparison.OrdinalIgnoreCase))).ToList();
}
else if (provisioningStates.Count == 0 && excludedProvisioningStates.Count > 0)
if(excludedProvisioningStates.Count > 0)
{
return deployments.Where(d => excludedProvisioningStates
.All(s => !s.Equals(d.ProvisioningState, StringComparison.OrdinalIgnoreCase))).ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,18 +409,6 @@ private TemplateValidationInfo CheckBasicDeploymentErrors(string resourceGroup,
return new TemplateValidationInfo(validationResult);
}

internal List<PSPermission> GetResourceGroupPermissions(string resourceGroup)
{
PermissionGetResult permissionsResult = AuthorizationManagementClient.Permissions.ListForResourceGroup(resourceGroup);

if (permissionsResult != null)
{
return permissionsResult.Permissions.Select(p => p.ToPSPermission()).ToList();
}

return null;
}

internal List<PSPermission> GetResourcePermissions(ResourceIdentifier identity)
{
PermissionGetResult permissionsResult = AuthorizationManagementClient.Permissions.ListForResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public static PSResourceGroup ToPSResourceGroup(this ResourceGroupExtended resou
{
result.Resources = client.FilterResources(new FilterResourcesOptions { ResourceGroup = resourceGroup.Name })
.Select(r => r.ToPSResource(client, true)).ToList();
result.Permissions = client.GetResourceGroupPermissions(resourceGroup.Name);
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public class GetAzureResourceGroupDeploymentCommand : ResourcesBaseCmdlet
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(Mandatory = false, HelpMessage = "The provisioning state of the resource group deployment.")]
[ValidateNotNullOrEmpty]
public string ProvisioningState { get; set; }

[Alias("DeploymentId", "ResourceId")]
[Parameter(ParameterSetName = GetAzureResourceGroupDeploymentCommand.DeploymentIdParameterSet, Mandatory = true, HelpMessage = "The fully qualified resource Id of the deployment. example: /subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Resources/deployments/{deploymentName}")]
[ValidateNotNullOrEmpty]
Expand All @@ -58,15 +54,9 @@ protected override void ProcessRecord()
FilterResourceGroupDeploymentOptions options = new FilterResourceGroupDeploymentOptions()
{
ResourceGroupName = ResourceGroupName ?? ResourceIdUtility.GetResourceGroupName(Id),
DeploymentName = Name ?? (string.IsNullOrEmpty(Id) ? null : ResourceIdUtility.GetResourceName(Id)),
ProvisioningStates = string.IsNullOrEmpty(ProvisioningState) ? new List<string>() :
new List<string>() { ProvisioningState }
DeploymentName = Name ?? (string.IsNullOrEmpty(Id) ? null : ResourceIdUtility.GetResourceName(Id))
};

if(!string.IsNullOrEmpty(ProvisioningState))
{
WriteWarning("The ProvisioningState parameter is being deprecated and will be removed in a future release.");
}
WriteObject(ResourcesClient.FilterResourceGroupDeployments(options), true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public class RemoveAzureResourceGroupDeploymentCommand : ResourcesBaseCmdlet
[Parameter(Mandatory = false, HelpMessage = "Do not confirm the remove.")]
public SwitchParameter Force { get; set; }

[Parameter(Mandatory = false, HelpMessage = "True if succeed, false otherwise.")]
public SwitchParameter PassThru { get; set; }

protected override void ProcessRecord()
{
if(string.IsNullOrEmpty(ResourceGroupName) && string.IsNullOrEmpty(Name))
Expand All @@ -69,11 +66,8 @@ protected override void ProcessRecord()
ResourceGroupName,
() => ResourcesClient.DeleteDeployment(ResourceGroupName, Name));

if (PassThru)
{
WriteWarning("The PassThru switch parameter is being deprecated and will be removed in a future release.");
WriteObject(true);
}
WriteObject(true);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public class StopAzureResourceGroupDeploymentCommand : ResourcesBaseCmdlet
[Parameter(Mandatory = false, HelpMessage = "Do not confirm the stop.")]
public SwitchParameter Force { get; set; }

[Parameter(Mandatory = false, HelpMessage = "True if succeed, false otherwise.")]
public SwitchParameter PassThru { get; set; }

protected override void ProcessRecord()
{
if (string.IsNullOrEmpty(ResourceGroupName) && string.IsNullOrEmpty(Name))
Expand All @@ -69,11 +66,8 @@ protected override void ProcessRecord()
ResourceGroupName,
() => ResourcesClient.CancelDeployment(ResourceGroupName, Name));

if (PassThru)
{
WriteWarning("The output object of this cmdlet will be modified in a future release.");
WriteObject(true);
}
WriteObject(true);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public class GetAzureResourceGroupCommand : ResourcesBaseCmdlet, IModuleAssembly

protected override void ProcessRecord()
{
WriteWarning("The output object of this cmdlet will be modified in a future release.");
Name = Name ?? ResourceIdentifier.FromResourceGroupIdentifier(this.Id).ResourceGroupName;

this.WriteObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ protected override void ProcessRecord()
ConfirmAction = ConfirmAction
};

WriteWarning("The output object of this cmdlet will be modified in a future release.");
WriteObject(ResourcesClient.CreatePSResourceGroup(parameters));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ protected override void ProcessRecord()
ResourceGroupName = Name ?? ResourceIdentifier.FromResourceGroupIdentifier(this.Id).ResourceGroupName,
Tag = Tag,
};
WriteWarning("The output object of this cmdlet will be modified in a future release.");
WriteObject(ResourcesClient.UpdatePSResourceGroup(parameters));
}
}
Expand Down