forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get/Set AzureRmRecoveryServicesBackupProperties
- Loading branch information
Showing
9 changed files
with
184 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...eryServices/Commands.RecoveryServices/Vault/GetAzureRmRecoveryServicesBackupProperties.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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 System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
using Microsoft.Azure.Management.RecoveryServices.Models; | ||
|
||
namespace Microsoft.Azure.Commands.RecoveryServices | ||
{ | ||
/// <summary> | ||
/// Retrieves Azure Recovery Services Vault. | ||
/// </summary> | ||
[Cmdlet(VerbsCommon.Get, "AzureRmRecoveryServicesBackupProperties")] | ||
[OutputType(typeof(ASRVaultBackupProperties))] | ||
public class GetAzureRmRecoveryServicesBackupProperties : RecoveryServicesCmdletBase | ||
{ | ||
#region Parameters | ||
|
||
/// <summary> | ||
/// Gets or sets vault Object. | ||
/// </summary> | ||
[Parameter(Mandatory = true, ValueFromPipeline = true)] | ||
[ValidateNotNullOrEmpty] | ||
public ARSVault Vault { get; set; } | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// ProcessRecord of the command. | ||
/// </summary> | ||
public override void ExecuteCmdlet() | ||
{ | ||
try | ||
{ | ||
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(this.Vault.ResouceGroupName, this.Vault.Name); | ||
ASRVaultBackupProperties vaultBackupProperties = new ASRVaultBackupProperties(); | ||
vaultBackupProperties.BackupStorageRedundancy = getStorageResponse.Properties.StorageType; | ||
this.WriteObject(vaultBackupProperties); | ||
} | ||
catch (Exception exception) | ||
{ | ||
this.HandleException(exception); | ||
} | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...eryServices/Commands.RecoveryServices/Vault/SetAzureRmRecoveryServicesBackupProperties.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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 System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
using Microsoft.Azure.Management.RecoveryServices.Models; | ||
|
||
namespace Microsoft.Azure.Commands.RecoveryServices | ||
{ | ||
/// <summary> | ||
/// Retrieves Azure Recovery Services Vault. | ||
/// </summary> | ||
[Cmdlet(VerbsCommon.Set, "AzureRmRecoveryServicesBackupProperties")] | ||
public class SetAzureRmRecoveryServicesBackupProperties : RecoveryServicesCmdletBase | ||
{ | ||
#region Parameters | ||
/// <summary> | ||
/// Gets or sets vault Object. | ||
/// </summary> | ||
[Parameter(Mandatory = true, ValueFromPipeline = true)] | ||
[ValidateNotNullOrEmpty] | ||
public ARSVault Vault { get; set; } | ||
/// <summary> | ||
/// Gets or sets BackupStorageRedundancy type. | ||
/// </summary> | ||
[Parameter(Mandatory = false)] | ||
public string BackupStorageRedundancy { get; set; } | ||
|
||
#endregion Parameters | ||
|
||
/// <summary> | ||
/// ProcessRecord of the command. | ||
/// </summary> | ||
public override void ExecuteCmdlet() | ||
{ | ||
try | ||
{ | ||
if (!string.IsNullOrEmpty(this.BackupStorageRedundancy)) | ||
{ | ||
UpdateVaultStorageTypeRequest vaultStorageRequest = new UpdateVaultStorageTypeRequest(); | ||
vaultStorageRequest.Properties = new StorageTypeProperties(); | ||
vaultStorageRequest.Properties.StorageModelType = BackupStorageRedundancy; | ||
AzureOperationResponse storageResponse = RecoveryServicesClient.UpdateVaultStorageType(this.Vault.ResouceGroupName, this.Vault.Name, vaultStorageRequest); | ||
} | ||
} | ||
catch (Exception exception) | ||
{ | ||
this.HandleException(exception); | ||
} | ||
} | ||
} | ||
} |