Skip to content

Commit

Permalink
Merge pull request #26 from MabOneSdk/anudeeb
Browse files Browse the repository at this point in the history
Set-AzureBackupVaultStorageType cmdlet
  • Loading branch information
Samuel Anudeep committed Jun 11, 2015
2 parents 33c5f43 + 2cb24a4 commit 320ec1b
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ internal static class AzureBackupCmdletHelpMessage
public const string ProtectionStatus = "Protection Status of the azure backup item.";
public const string AzureBackUpItem = "Azure BackUp Item.";
public const string RecoveryPointId = "Recovery Point Id.";
public const string StorageType = "The vault back-end storage type.";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private AcsNamespace UploadCert(X509Certificate2 cert, string subscriptionId, st

string response = string.Empty;
VaultCredUploadCertResponse vaultCredUploadCertResponse =
AzureBackupClient.VaultCredentials.UploadCertificateAsync(
AzureBackupClient.Vault.UploadCertificateAsync(
"IdMgmtInternalCert",
vaultCredUploadCertRequest,
GetCustomRequestHeaders(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.BackupServices.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
{
[Cmdlet(VerbsCommon.Set, "AzureBackupVaultStorageType")]
public class SetAzureBackupVaultStorageType : AzureBackupVaultCmdletBase
{
[Parameter(Position = 2, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.StorageType)]
[ValidateNotNullOrEmpty]
public AzureBackupVaultStorageType Type { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

ExecutionBlock(() =>
{
if (Type == 0)
{
throw new ArgumentException("Please provide a vaild storage type.");
}
UpdateVaultStorageTypeRequest updateVaultStorageTypeRequest = new UpdateVaultStorageTypeRequest()
{
StorageTypeProperties = new StorageTypeProperties()
{
StorageModelType = Type.ToString(),
},
};
AzureBackupClient.Vault.UpdateStorageTypeAsync(updateVaultStorageTypeRequest, GetCustomRequestHeaders(), CmdletCancellationToken);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@
<Compile Include="Cmdlets\Container\UnregisterAzureBackupContainer.cs" />
<Compile Include="Cmdlets\Jobs\GetAzureBackupJob.cs" />
<Compile Include="Cmdlets\ProtectionPolicy\GetAzureBackupProtectionPolicy.cs" />
<Compile Include="Cmdlets\VaultCredentials\AcsNamespace.cs" />
<Compile Include="Cmdlets\VaultCredentials\CertUtils.cs" />
<Compile Include="Cmdlets\VaultCredentials\Constants.cs" />
<Compile Include="Cmdlets\VaultCredentials\GetAzureBackupVaultCredentials.cs" />
<Compile Include="Cmdlets\VaultCredentials\VaultCredentials.cs" />
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\AcsNamespace.cs" />
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\CertUtils.cs" />
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\Constants.cs" />
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\GetAzureBackupVaultCredentials.cs" />
<Compile Include="Cmdlets\Vault\GetAzureBackupVaultCredentials\VaultCredentials.cs" />
<Compile Include="Cmdlets\Vault\SetAzureBackupVaultStorageType.cs" />
<Compile Include="Models\AzureBackupBaseObjects.cs" />
<Compile Include="Models\AzureBackupContainer.cs" />
<Compile Include="Models\AzureBackupEnums.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
{
public enum AzureBackupContainerTypeInput
{
All,
AzureVirtualMachine,
AzureVirtualMachine = 1,
}

public enum AzureBackupContainerStatusInput
{
All,
Registering,
Registering = 1,
Registered,
}

Expand Down Expand Up @@ -88,4 +86,10 @@ public enum AzureBackupOperationErrorCode
BMSUserErrorObjectLocked = 390026,
DiscoveryInProgress = 410002,
}

public enum AzureBackupVaultStorageType
{
GeoRedundant = 1,
LocallyRedundant,
}
}

0 comments on commit 320ec1b

Please sign in to comment.