|
| 1 | +// ---------------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// Copyright Microsoft Corporation |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// Unless required by applicable law or agreed to in writing, software |
| 9 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +// See the License for the specific language governing permissions and |
| 12 | +// limitations under the License. |
| 13 | +// ---------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +using System; |
| 16 | +using System.Collections.Generic; |
| 17 | +using System.Linq; |
| 18 | +using System.Management.Automation; |
| 19 | +using Microsoft.Azure.Management.RecoveryServices.Models; |
| 20 | + |
| 21 | +namespace Microsoft.Azure.Commands.RecoveryServices |
| 22 | +{ |
| 23 | + /// <summary> |
| 24 | + /// Retrieves Azure Recovery Services Vault. |
| 25 | + /// </summary> |
| 26 | + [Cmdlet(VerbsCommon.Set, "AzureRmRecoveryServicesVault")] |
| 27 | + public class SetAzureRmRecoveryServicesVaults : RecoveryServicesCmdletBase |
| 28 | + { |
| 29 | + #region Parameters |
| 30 | + /// <summary> |
| 31 | + /// Gets or sets vault Object. |
| 32 | + /// </summary> |
| 33 | + [Parameter(Mandatory = true, ValueFromPipeline = true)] |
| 34 | + [ValidateNotNullOrEmpty] |
| 35 | + public ARSVault Vault { get; set; } |
| 36 | + /// <summary> |
| 37 | + /// Gets or sets BackupStorageRedundancy type. |
| 38 | + /// </summary> |
| 39 | + [Parameter(Mandatory = false)] |
| 40 | + public string BackupStorageRedundancy { get; set; } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Gets or sets BackupStorageDeduplication type. |
| 44 | + /// </summary> |
| 45 | + [Parameter(Mandatory = false)] |
| 46 | + public string BackupStorageDeduplication { get; set; } |
| 47 | + #endregion Parameters |
| 48 | + |
| 49 | + /// <summary> |
| 50 | + /// ProcessRecord of the command. |
| 51 | + /// </summary> |
| 52 | + public override void ExecuteCmdlet() |
| 53 | + { |
| 54 | + try |
| 55 | + { |
| 56 | + if (!(string.IsNullOrEmpty(this.BackupStorageRedundancy) && string.IsNullOrEmpty(this.BackupStorageDeduplication))) |
| 57 | + { |
| 58 | + UpdateVaultStorageTypeRequest vaultStorageRequest = new UpdateVaultStorageTypeRequest(); |
| 59 | + vaultStorageRequest.Properties = new StorageTypeProperties(); |
| 60 | + vaultStorageRequest.Properties.StorageModelType = BackupStorageRedundancy; |
| 61 | + vaultStorageRequest.Properties.DedupState = BackupStorageDeduplication; |
| 62 | + AzureOperationResponse storageResponse = RecoveryServicesClient.UpdateVaultStorageType(this.Vault.ResouceGroupName, this.Vault.Name, vaultStorageRequest); |
| 63 | + } |
| 64 | + } |
| 65 | + catch (Exception exception) |
| 66 | + { |
| 67 | + this.HandleException(exception); |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | +} |
0 commit comments