Skip to content

Commit 320ec1b

Browse files
author
Samuel Anudeep
committed
Merge pull request #26 from MabOneSdk/anudeeb
Set-AzureBackupVaultStorageType cmdlet
2 parents 33c5f43 + 2cb24a4 commit 320ec1b

File tree

9 files changed

+71
-10
lines changed

9 files changed

+71
-10
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletHelpMessage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ internal static class AzureBackupCmdletHelpMessage
3131
public const string ProtectionStatus = "Protection Status of the azure backup item.";
3232
public const string AzureBackUpItem = "Azure BackUp Item.";
3333
public const string RecoveryPointId = "Recovery Point Id.";
34+
public const string StorageType = "The vault back-end storage type.";
3435
}
3536
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/VaultCredentials/GetAzureBackupVaultCredentials.cs renamed to src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Vault/GetAzureBackupVaultCredentials/GetAzureBackupVaultCredentials.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private AcsNamespace UploadCert(X509Certificate2 cert, string subscriptionId, st
131131

132132
string response = string.Empty;
133133
VaultCredUploadCertResponse vaultCredUploadCertResponse =
134-
AzureBackupClient.VaultCredentials.UploadCertificateAsync(
134+
AzureBackupClient.Vault.UploadCertificateAsync(
135135
"IdMgmtInternalCert",
136136
vaultCredUploadCertRequest,
137137
GetCustomRequestHeaders(),
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@
137137
<Compile Include="Cmdlets\Container\UnregisterAzureBackupContainer.cs" />
138138
<Compile Include="Cmdlets\Jobs\GetAzureBackupJob.cs" />
139139
<Compile Include="Cmdlets\ProtectionPolicy\GetAzureBackupProtectionPolicy.cs" />
140-
<Compile Include="Cmdlets\VaultCredentials\AcsNamespace.cs" />
141-
<Compile Include="Cmdlets\VaultCredentials\CertUtils.cs" />
142-
<Compile Include="Cmdlets\VaultCredentials\Constants.cs" />
143-
<Compile Include="Cmdlets\VaultCredentials\GetAzureBackupVaultCredentials.cs" />
144-
<Compile Include="Cmdlets\VaultCredentials\VaultCredentials.cs" />
140+
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\AcsNamespace.cs" />
141+
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\CertUtils.cs" />
142+
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\Constants.cs" />
143+
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\GetAzureBackupVaultCredentials.cs" />
144+
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\VaultCredentials.cs" />
145+
<Compile Include="Cmdlets\Vault\SetAzureBackupVaultStorageType.cs" />
145146
<Compile Include="Models\AzureBackupBaseObjects.cs" />
146147
<Compile Include="Models\AzureBackupContainer.cs" />
147148
<Compile Include="Models\AzureBackupEnums.cs" />

src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupEnums.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
2323
{
2424
public enum AzureBackupContainerTypeInput
2525
{
26-
All,
27-
AzureVirtualMachine,
26+
AzureVirtualMachine = 1,
2827
}
2928

3029
public enum AzureBackupContainerStatusInput
3130
{
32-
All,
33-
Registering,
31+
Registering = 1,
3432
Registered,
3533
}
3634

@@ -88,4 +86,10 @@ public enum AzureBackupOperationErrorCode
8886
BMSUserErrorObjectLocked = 390026,
8987
DiscoveryInProgress = 410002,
9088
}
89+
90+
public enum AzureBackupVaultStorageType
91+
{
92+
GeoRedundant = 1,
93+
LocallyRedundant,
94+
}
9195
}

0 commit comments

Comments
 (0)