Skip to content

[Az.DataProtection] Adding support for Immutable vaults #20723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 60 additions & 8 deletions src/DataProtection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ This file contains the configuration for generating My API from the OpenAPI spec

``` yaml
# it's the same options as command line options, just drop the double-dash!
branch: c0d5296b483a5fe4de7851fcd45acde14e736574
branch: f38115ac455af89493b0a0719d9a987404560dda
require:
- $(this-folder)/../readme.azure.noprofile.md
input-file:
- $(repo)/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2022-05-01/dataprotection.json
- $(repo)/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2022-12-01/dataprotection.json
title: DataProtection
directive:
- from: swagger-document
Expand All @@ -54,6 +54,35 @@ directive:
set:
parameter-name: CriticalOperationExclusionList
clear-alias: true
- where:
parameter-name: ImmutabilitySettingState
set:
parameter-name: ImmutabilityState
parameter-description: Immutability state of the vault. Allowed values are Disabled, Unlocked, Locked.
clear-alias: true
- where:
parameter-name: CrossSubscriptionRestoreSettingState
set:
parameter-name: CrossSubscriptionRestoreState
parameter-description: Cross subscription restore state of the vault. Allowed values are Disabled, Enabled, PermanentlyDisabled.
clear-alias: true
- where:
parameter-name: SoftDeleteSettingRetentionDurationInDay
set:
parameter-name: SoftDeleteRetentionDurationInDay
parameter-description: Soft delete retention duration in days.
clear-alias: true
- where:
parameter-name: SoftDeleteSettingState
set:
parameter-name: SoftDeleteState
parameter-description: Soft delete state of the vault. Allowed values are Off, On, AlwaysOn.
clear-alias: true
- where:
parameter-name: SecuritySettingSoftDeleteSetting
set:
parameter-name: SoftDeleteSetting
clear-alias: true
- where:
verb: Get
subject: BackupVaultResource.*
Expand All @@ -77,6 +106,9 @@ directive:
verb: Update
subject: ResourceGuard
remove: true
- where:
subject: DeletedBackupInstance
remove: true
- where:
verb: Set
subject: ResourceGuard.*
Expand Down Expand Up @@ -217,6 +249,26 @@ directive:
property-name: VaultCriticalOperationExclusionList
set:
property-name: CriticalOperationExclusionList
- where:
property-name: ImmutabilitySettingState
set:
property-name: ImmutabilityState
- where:
property-name: SecuritySettingSoftDeleteSetting
set:
property-name: SoftDeleteSetting
- where:
property-name: CrossSubscriptionRestoreSettingState
set:
property-name: CrossSubscriptionRestoreState
- where:
property-name: SoftDeleteSettingRetentionDurationInDay
set:
property-name: SoftDeleteRetentionDurationInDay
- where:
property-name: SoftDeleteSettingState
set:
property-name: SoftDeleteState
- where:
model-name: BackupVaultResource
set:
Expand All @@ -227,7 +279,6 @@ directive:
- Type
- IdentityType
- no-inline:
- UserFacingError
- InnerError
- BackupInstance
- RestoreTargetInfo
Expand All @@ -237,20 +288,21 @@ directive:
- RestoreTargetInfoBase
- PolicyParameters
- SecretStoreBasedAuthCredentials
- SecretStoreResource
- SecretStoreResource
- SystemData
- UserFacingError
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IBaseBackupPolicy Property', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IBaseBackupPolicy Property');
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IBaseBackupPolicy Property', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IBaseBackupPolicy Property');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.ITriggerContext Trigger', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.ITriggerContext Trigger');
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.ITriggerContext Trigger', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.ITriggerContext Trigger');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IBackupParameters BackupParameter', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IBackupParameters BackupParameter');
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IBackupParameters BackupParameter', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IBackupParameters BackupParameter');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IAzureBackupRecoveryPoint Property', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IAzureBackupRecoveryPoint Property');
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IAzureBackupRecoveryPoint Property', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IAzureBackupRecoveryPoint Property');
```

## Alternate settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
foreach($argResponse in $argInstanceResponse)
{
$jsonStringResponse = $argResponse | ConvertTo-Json -Depth 100
$backupInstances += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.BackupInstanceResource]::FromJsonString($jsonStringResponse)
$backupInstances += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.BackupInstanceResource]::FromJsonString($jsonStringResponse)
}
return $backupInstances
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
foreach($jobresponse in $argJobResponse)
{
$jsonStringResponse = $jobresponse | ConvertTo-Json -Depth 100
$backupJobs += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.AzureBackupJobResource]::FromJsonString($jsonStringResponse)
$backupJobs += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.AzureBackupJobResource]::FromJsonString($jsonStringResponse)
}
return $backupJobs
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


function Initialize-AzDataProtectionBackupInstance {
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IBackupInstanceResource')]
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IBackupInstanceResource')]
[CmdletBinding(PositionalBinding=$false)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Initializes Backup instance Request object for configuring backup')]

Expand Down Expand Up @@ -43,7 +43,7 @@ function Initialize-AzDataProtectionBackupInstance {
process {

$manifest = LoadManifest -DatasourceType $DatasourceType.ToString()
$backupInstance = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.BackupInstance]::new()
$backupInstance = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.BackupInstance]::new()
$backupInstance.ObjectType = "BackupInstance"

if($DatasourceType.ToString() -ne "AzureDisk" -and $SnapshotResourceGroupId -ne "")
Expand Down Expand Up @@ -84,9 +84,9 @@ function Initialize-AzDataProtectionBackupInstance {
$errormsg = "Please input SecretStoreType"
throw $errormsg
}
$backupInstance.DatasourceAuthCredentials = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.SecretStoreBasedAuthCredentials]::new()
$backupInstance.DatasourceAuthCredentials = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.SecretStoreBasedAuthCredentials]::new()
$backupInstance.DatasourceAuthCredentials.ObjectType = "SecretStoreBasedAuthCredentials"
$backupInstance.DatasourceAuthCredentials.SecretStoreResource = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.SecretStoreResource]::new()
$backupInstance.DatasourceAuthCredentials.SecretStoreResource = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.SecretStoreResource]::new()
$backupInstance.DatasourceAuthCredentials.SecretStoreResource.SecretStoreType = $SecretStoreType
$backupInstance.DatasourceAuthCredentials.SecretStoreResource.Uri = $SecretStoreURI
}
Expand All @@ -96,7 +96,7 @@ function Initialize-AzDataProtectionBackupInstance {
}
}

$backupInstanceResource = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.BackupInstanceResource]::new()
$backupInstanceResource = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.BackupInstanceResource]::new()
$backupInstanceResource.Property = $backupInstance

if($PSBoundParameters.ContainsKey("DatasourceId"))
Expand All @@ -114,7 +114,7 @@ function Initialize-AzDataProtectionBackupInstance {

if($DatasourceType.ToString() -eq "AzureDisk")
{
$operationalParam = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.AzureOperationalStoreParameters]::new()
$operationalParam = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.AzureOperationalStoreParameters]::new()
$operationalParam.DataStoreType = "OperationalStore"
$operationalParam.ObjectType = "AzureOperationalStoreParameters"
$operationalParam.ResourceGroupId = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function New-AzDataProtectionBackupInstance {
${VaultName},

[Parameter(Mandatory, HelpMessage='Backup instance request object which will be used to configure backup')]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IBackupInstanceResource]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IBackupInstanceResource]
${BackupInstance},

[Parameter(Mandatory=$false, HelpMessage='Resource tags')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function New-AzDataProtectionResourceGuard
{
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IResourceGuardResource')]
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IResourceGuardResource')]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Creates a resource guard under a resource group')]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function Update-AzDataProtectionBackupInstanceAssociatedPolicy
{
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IBackupInstanceResource')]
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IBackupInstanceResource')]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Updates associated policy for a given backup instance')]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function Update-AzDataProtectionResourceGuard
{
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IResourceGuardResource')]
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IResourceGuardResource')]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Updates a resource guard belonging to a resource group')]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function Initialize-AzDataProtectionRestoreRequest
{
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.IAzureBackupRestoreRequest')]
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.IAzureBackupRestoreRequest')]
[CmdletBinding(PositionalBinding=$false)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Initializes Restore Request object for triggering restore on a protected backup instance.')]

Expand Down Expand Up @@ -71,7 +71,7 @@

[Parameter(ParameterSetName="OriginalLocationFullRecovery", Mandatory, HelpMessage='Backup Instance object to trigger original localtion restore.')]
[Parameter(ParameterSetName="OriginalLocationILR", Mandatory, HelpMessage='Backup Instance object to trigger original localtion restore.')]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.BackupInstanceResource]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.BackupInstanceResource]
${BackupInstance},

[Parameter(ParameterSetName="AlternateLocationFullRecovery", Mandatory, HelpMessage='Target resource Id to which backup data will be restored.')]
Expand Down Expand Up @@ -132,7 +132,7 @@
Write-Debug -Message $RecoveryPoint

if($PSBoundParameters.ContainsKey("RehydrationPriority")){
$restoreRequest = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.AzureBackupRestoreWithRehydrationRequest]::new()
$restoreRequest = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.AzureBackupRestoreWithRehydrationRequest]::new()
$restoreRequest.ObjectType = "AzureBackupRestoreWithRehydrationRequest"
$restoreRequest.RehydrationPriority = $RehydrationPriority
if($PSBoundParameters.ContainsKey("RehydrationDuration")){
Expand All @@ -143,7 +143,7 @@
}
}
else{
$restoreRequest = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.AzureBackupRecoveryPointBasedRestoreRequest]::new()
$restoreRequest = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.AzureBackupRecoveryPointBasedRestoreRequest]::new()
$restoreRequest.ObjectType = "AzureBackupRecoveryPointBasedRestoreRequest"
}
$restoreRequest.RecoveryPointId = $RecoveryPoint
Expand All @@ -153,7 +153,7 @@
{
$utcTime = $PointInTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.0000000Z")
Write-Debug -Message $utcTime
$restoreRequest = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.AzureBackupRecoveryTimeBasedRestoreRequest]::new()
$restoreRequest = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.AzureBackupRecoveryTimeBasedRestoreRequest]::new()
$restoreRequest.ObjectType = "AzureBackupRecoveryTimeBasedRestoreRequest"
$restoreRequest.RecoveryPointTime = $utcTime
$restoreMode = "PointInTimeBased"
Expand All @@ -170,7 +170,7 @@

if($RestoreType -eq "RestoreAsFiles")
{
$restoreRequest.RestoreTargetInfo = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.RestoreFilesTargetInfo]::new()
$restoreRequest.RestoreTargetInfo = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.RestoreFilesTargetInfo]::new()
$restoreRequest.RestoreTargetInfo.ObjectType = "RestoreFilesTargetInfo"

if(!($PSBoundParameters.ContainsKey("FileNamePrefix")) -or !($PSBoundParameters.ContainsKey("TargetContainerURI")) ){
Expand All @@ -185,21 +185,21 @@
elseif(!($ItemLevelRecovery))
{
# RestoreTargetInfo for OLR ALR Full recovery
$restoreRequest.RestoreTargetInfo = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.RestoreTargetInfo]::new()
$restoreRequest.RestoreTargetInfo = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.RestoreTargetInfo]::new()
$restoreRequest.RestoreTargetInfo.ObjectType = "restoreTargetInfo"
}
else
{
# ILR: ItemLevelRestoreTargetInfo
$restoreRequest.RestoreTargetInfo = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.ItemLevelRestoreTargetInfo]::new()
$restoreRequest.RestoreTargetInfo = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.ItemLevelRestoreTargetInfo]::new()
$restoreRequest.RestoreTargetInfo.ObjectType = "itemLevelRestoreTargetInfo"

$restoreCriteriaList = @()

if($ContainersList.length -gt 0){
for($i = 0; $i -lt $ContainersList.length; $i++){

$restoreCriteria = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.RangeBasedItemLevelRestoreCriteria]::new()
$restoreCriteria = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.RangeBasedItemLevelRestoreCriteria]::new()

$restoreCriteria.ObjectType = "RangeBasedItemLevelRestoreCriteria"
$restoreCriteria.MinMatchingValue = $ContainersList[$i]
Expand All @@ -218,7 +218,7 @@

for($i = 0; $i -lt $FromPrefixPattern.length; $i++){

$restoreCriteria = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.RangeBasedItemLevelRestoreCriteria]::new()
$restoreCriteria = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.RangeBasedItemLevelRestoreCriteria]::new()

$restoreCriteria.ObjectType = "RangeBasedItemLevelRestoreCriteria"
$restoreCriteria.MinMatchingValue = $FromPrefixPattern[$i]
Expand Down Expand Up @@ -280,9 +280,9 @@
$errormsg = "Please input SecretStoreType"
throw $errormsg
}
$restoreRequest.RestoreTargetInfo.DatasourceAuthCredentials = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.SecretStoreBasedAuthCredentials]::new()
$restoreRequest.RestoreTargetInfo.DatasourceAuthCredentials = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.SecretStoreBasedAuthCredentials]::new()
$restoreRequest.RestoreTargetInfo.DatasourceAuthCredentials.ObjectType = "SecretStoreBasedAuthCredentials"
$restoreRequest.RestoreTargetInfo.DatasourceAuthCredentials.SecretStoreResource = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20220501.SecretStoreResource]::new()
$restoreRequest.RestoreTargetInfo.DatasourceAuthCredentials.SecretStoreResource = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20221201.SecretStoreResource]::new()
$restoreRequest.RestoreTargetInfo.DatasourceAuthCredentials.SecretStoreResource.SecretStoreType = $SecretStoreType
$restoreRequest.RestoreTargetInfo.DatasourceAuthCredentials.SecretStoreResource.Uri = $SecretStoreURI
}
Expand Down
Loading