public override void ExecuteCmdlet()
        {
            IDictionary <string, string> tagPairs = null;

            if (Tag != null)
            {
                tagPairs = new Dictionary <string, string>();

                foreach (string key in Tag.Keys)
                {
                    tagPairs.Add(key, Tag[key].ToString());
                }
            }

            if (ParameterSetName == ResourceIdParameterSet)
            {
                var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
                ResourceGroupName = resourceIdentifier.ResourceGroupName;
                var parentResources = resourceIdentifier.ParentResource.Split('/');
                AccountName = parentResources[1];
                PoolName    = parentResources[3];
                Name        = resourceIdentifier.ResourceName;
            }
            else if (ParameterSetName == ObjectParameterSet)
            {
                ResourceGroupName = InputObject.ResourceGroupName;
                Location          = InputObject.Location;
                var NameParts = InputObject.Name.Split('/');
                AccountName = NameParts[0];
                PoolName    = NameParts[1];
                Name        = NameParts[2];
            }
            else if (ParameterSetName == ParentObjectParameterSet)
            {
                ResourceGroupName = PoolObject.ResourceGroupName;
                Location          = PoolObject.Location;
                var NameParts = InputObject.Name.Split('/');
                AccountName = NameParts[0];
                PoolName    = NameParts[1];
            }

            var volumePatchBody = new VolumePatch()
            {
                ServiceLevel   = ServiceLevel,
                UsageThreshold = UsageThreshold,
                ExportPolicy   = (ExportPolicy != null) ? ModelExtensions.ConvertExportPolicyPatchFromPs(ExportPolicy) : null,
                Tags           = tagPairs
            };

            if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.UpdateResourceMessage, ResourceGroupName)))
            {
                var anfVolume = AzureNetAppFilesManagementClient.Volumes.Update(volumePatchBody, ResourceGroupName, AccountName, PoolName, Name);
                WriteObject(anfVolume.ToPsNetAppFilesVolume());
            }
        }
Beispiel #2
0
        public override void ExecuteCmdlet()
        {
            IDictionary <string, string> tagPairs = null;

            if (Tag != null)
            {
                tagPairs = new Dictionary <string, string>();

                foreach (string key in Tag.Keys)
                {
                    tagPairs.Add(key, Tag[key].ToString());
                }
            }

            if (ParameterSetName == ResourceIdParameterSet)
            {
                var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
                ResourceGroupName = resourceIdentifier.ResourceGroupName;
                var parentResources = resourceIdentifier.ParentResource.Split('/');
                AccountName = parentResources[1];
                PoolName    = parentResources[3];
                Name        = resourceIdentifier.ResourceName;
            }
            else if (ParameterSetName == ObjectParameterSet)
            {
                ResourceGroupName = InputObject.ResourceGroupName;
                Location          = InputObject.Location;
                var NameParts = InputObject.Name.Split('/');
                AccountName = NameParts[0];
                PoolName    = NameParts[1];
                Name        = NameParts[2];
            }
            else if (ParameterSetName == ParentObjectParameterSet)
            {
                ResourceGroupName = PoolObject.ResourceGroupName;
                Location          = PoolObject.Location;
                var NameParts = InputObject.Name.Split('/');
                AccountName = NameParts[0];
                PoolName    = NameParts[1];
            }

            PSNetAppFilesVolumeDataProtection dataProtection = null;

            if (!string.IsNullOrWhiteSpace(SnapshotPolicyId) || Backup != null)
            {
                dataProtection = new PSNetAppFilesVolumeDataProtection
                {
                    Snapshot = new PSNetAppFilesVolumeSnapshot()
                    {
                        SnapshotPolicyId = SnapshotPolicyId
                    },
                    Backup = Backup
                };
            }

            var volumePatchBody = new VolumePatch()
            {
                ServiceLevel            = ServiceLevel,
                UsageThreshold          = UsageThreshold,
                ExportPolicy            = (ExportPolicy != null) ? ModelExtensions.ConvertExportPolicyPatchFromPs(ExportPolicy) : null,
                Tags                    = tagPairs,
                ThroughputMibps         = ThroughputMibps,
                DataProtection          = (dataProtection != null) ? dataProtection.ConvertToPatchFromPs() : null,
                IsDefaultQuotaEnabled   = IsDefaultQuotaEnabled,
                DefaultUserQuotaInKiBs  = DefaultUserQuotaInKiB,
                DefaultGroupQuotaInKiBs = DefaultGroupQuotaInKiB
            };

            if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.UpdateResourceMessage, ResourceGroupName)))
            {
                var anfVolume = AzureNetAppFilesManagementClient.Volumes.Update(volumePatchBody, ResourceGroupName, AccountName, PoolName, Name);
                WriteObject(anfVolume.ToPsNetAppFilesVolume());
            }
        }