|
| 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 Microsoft.Azure.Management.BackupServices.Models; |
| 16 | +using System; |
| 17 | +using System.Collections.Generic; |
| 18 | +using System.Linq; |
| 19 | +using System.Management.Automation; |
| 20 | +using System.Text; |
| 21 | +using System.Threading.Tasks; |
| 22 | + |
| 23 | +namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets |
| 24 | +{ |
| 25 | + [Cmdlet(VerbsCommon.Set, "AzureBackupVaultStorageType")] |
| 26 | + public class SetAzureBackupVaultStorageType : AzureBackupVaultCmdletBase |
| 27 | + { |
| 28 | + [Parameter(Position = 2, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.StorageType)] |
| 29 | + [ValidateNotNullOrEmpty] |
| 30 | + public AzureBackupVaultStorageType Type { get; set; } |
| 31 | + |
| 32 | + public override void ExecuteCmdlet() |
| 33 | + { |
| 34 | + base.ExecuteCmdlet(); |
| 35 | + |
| 36 | + ExecutionBlock(() => |
| 37 | + { |
| 38 | + if (Type == 0) |
| 39 | + { |
| 40 | + throw new ArgumentException("Please provide a vaild storage type."); |
| 41 | + } |
| 42 | + |
| 43 | + UpdateVaultStorageTypeRequest updateVaultStorageTypeRequest = new UpdateVaultStorageTypeRequest() |
| 44 | + { |
| 45 | + StorageTypeProperties = new StorageTypeProperties() |
| 46 | + { |
| 47 | + StorageModelType = Type.ToString(), |
| 48 | + }, |
| 49 | + }; |
| 50 | + |
| 51 | + AzureBackupClient.Vault.UpdateStorageTypeAsync(updateVaultStorageTypeRequest, GetCustomRequestHeaders(), CmdletCancellationToken); |
| 52 | + }); |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + // TODO: Move to common enums cs file. |
| 57 | + public enum AzureBackupVaultStorageType |
| 58 | + { |
| 59 | + GeoRedundant = 1, |
| 60 | + LocallyRedundant, |
| 61 | + } |
| 62 | +} |
0 commit comments