public void UpdatesSetPSResourceGroupWithTagFromId() { PSUpdateResourceGroupParameters expectedParameters = new PSUpdateResourceGroupParameters() { ResourceGroupName = resourceGroupName, Tag = tags }; PSUpdateResourceGroupParameters actualParameters = new PSUpdateResourceGroupParameters(); PSResourceGroup expected = new PSResourceGroup() { ResourceGroupName = expectedParameters.ResourceGroupName, Tags = expectedParameters.Tag }; resourcesClientMock.Setup(f => f.UpdatePSResourceGroup(It.IsAny <PSUpdateResourceGroupParameters>())) .Returns(expected) .Callback((PSUpdateResourceGroupParameters p) => { actualParameters = p; }); cmdlet.Id = resourceGroupId; cmdlet.Tag = expectedParameters.Tag; cmdlet.ExecuteCmdlet(); Assert.Equal(expectedParameters.ResourceGroupName, actualParameters.ResourceGroupName); Assert.Equal(expectedParameters.Tag, actualParameters.Tag); commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once()); }
/// <summary> /// Updates a resource group. /// </summary> /// <param name="parameters">The create parameters</param> public virtual PSResourceGroup UpdatePSResourceGroup(PSUpdateResourceGroupParameters parameters) { ResourceGroup resourceGroup = ResourceManagementClient.ResourceGroups.Get(parameters.ResourceGroupName); resourceGroup = CreateOrUpdateResourceGroup(parameters.ResourceGroupName, resourceGroup.Location, parameters.Tag); WriteVerbose(string.Format(ProjectResources.UpdatedResourceGroup, resourceGroup.Name, resourceGroup.Location)); return(resourceGroup.ToPSResourceGroup()); }
public override void ExecuteCmdlet() { WriteWarning(ProjectResources.WarnOnTags); PSUpdateResourceGroupParameters parameters = new PSUpdateResourceGroupParameters { ResourceGroupName = Name ?? ResourceIdentifier.FromResourceGroupIdentifier(this.Id).ResourceGroupName, Tag = Tag, }; WriteObject(ResourceManagerSdkClient.UpdatePSResourceGroup(parameters)); }
public override void ExecuteCmdlet() { PSUpdateResourceGroupParameters parameters = new PSUpdateResourceGroupParameters { ResourceGroupName = Name ?? ResourceIdentifier.FromResourceGroupIdentifier(this.Id).ResourceGroupName, Tag = Tag, }; var resourceGroup = ResourceManagerSdkClient.UpdatePSResourceGroup(parameters); if (resourceGroup != null) { WriteObject(resourceGroup); } }
/// <summary> /// Updates a resource group. /// </summary> /// <param name="parameters">The create parameters</param> public virtual PSResourceGroup UpdatePSResourceGroup(PSUpdateResourceGroupParameters parameters) { if (!ResourceManagementClient.ResourceGroups.CheckExistence(parameters.ResourceGroupName).Value) { WriteError(ProjectResources.ResourceGroupDoesntExists); return(null); } ResourceGroup resourceGroup = ResourceManagementClient.ResourceGroups.Get(parameters.ResourceGroupName); resourceGroup = CreateOrUpdateResourceGroup(parameters.ResourceGroupName, resourceGroup.Location, parameters.Tag); WriteVerbose(string.Format(ProjectResources.UpdatedResourceGroup, resourceGroup.Name, resourceGroup.Location)); return(resourceGroup.ToPSResourceGroup()); }
protected override void OnProcessRecord() { PSUpdateResourceGroupParameters parameters = new PSUpdateResourceGroupParameters { ResourceGroupName = Name ?? ResourceIdentifier.FromResourceGroupIdentifier(this.Id).ResourceGroupName, Tag = Tag, }; var resourceGroup = ResourceManagerSdkClient.UpdatePSResourceGroup(parameters); if (resourceGroup != null) { WriteObject(resourceGroup); } }
/// <summary> /// Updates a resource group. /// </summary> /// <param name="parameters">The create parameters</param> public virtual PSResourceGroup UpdatePSResourceGroup(PSUpdateResourceGroupParameters parameters) { if (!ResourceManagementClient.ResourceGroups.CheckExistence(parameters.ResourceGroupName)) { WriteError(ProjectResources.ResourceGroupDoesntExists); return(null); } ResourceGroup resourceGroup = ResourceManagementClient.ResourceGroups.Get(parameters.ResourceGroupName); Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(parameters.Tag, validate: true); resourceGroup = ResourceManagementClient.ResourceGroups.Update(resourceGroup.Name, new ResourceGroupPatchable { Name = resourceGroup.Name, Properties = resourceGroup.Properties, ManagedBy = resourceGroup.ManagedBy, Tags = tagDictionary }); WriteVerbose(string.Format(ProjectResources.UpdatedResourceGroup, resourceGroup.Name, resourceGroup.Location)); return(resourceGroup.ToPSResourceGroup()); }