Skip to content

Commit b003b74

Browse files
committed
[Get/Set AzureRmRecoveryServicesvault] Adding Missing Files and some code changes
1 parent f16d5cd commit b003b74

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Vault/GetAzureRmRecoveryServicesVaults.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ private void WriteVaults(IList<Vault> vaults)
9696
{
9797
foreach (Vault vault in vaults)
9898
{
99-
if (0 == string.Compare(this.Name, vault.Name, true))
99+
if (0 == string.Compare(this.Name, vault.Name, true) || string.IsNullOrEmpty(this.Name))
100100
{
101101
ARSVault rsVault = new ARSVault(vault);
102-
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(this.ResourceGroupName, vault.Name);
102+
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(rsVault.ResouceGroupName, rsVault.Name);
103103
rsVault.Properties.BackupStorageRedundancy = getStorageResponse.Properties.StorageType;
104104
rsVault.Properties.BackupStorageDeduplication = getStorageResponse.Properties.DedupState;
105105
this.WriteObject(new ARSVault(vault));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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

Comments
 (0)