Skip to content
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

[Az.RecoveryServices.Backup] [8.0.0-preview] Adding autorest based commands equivalent for SDK based Policy commands in RecoveryServices module #21925

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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
16 changes: 16 additions & 0 deletions src/RecoveryServices/RecoveryServices.Backup.Autorest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bin
obj
.vs
generated
internal
exports
tools
custom/*.psm1
custom/autogen-model-cmdlets
test/*-TestResults.xml
/*.ps1
/*.ps1xml
/*.psm1
/*.snk
/*.csproj
/*.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@{
GUID = '37eaf44e-78f7-4a5a-82d1-f6350681704b'
RootModule = './Az.RecoveryServices.psm1'
ModuleVersion = '0.1.0'
CompatiblePSEditions = 'Core', 'Desktop'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Copyright = 'Microsoft Corporation. All rights reserved.'
Description = 'Microsoft Azure PowerShell: RecoveryServices cmdlets'
PowerShellVersion = '5.1'
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.RecoveryServices.private.dll'
FormatsToProcess = './Az.RecoveryServices.format.ps1xml'
FunctionsToExport = 'Edit-AzRecoveryServicesBackupRetentionPolicyClientObject', 'Edit-AzRecoveryServicesBackupSchedulePolicyClientObject', 'Get-AzRecoveryServicesBackupContainer', 'Get-AzRecoveryServicesBackupItem', 'Get-AzRecoveryServicesBackupProtectableItem', 'Get-AzRecoveryServicesBackupProtectionPolicy', 'Get-AzRecoveryServicesPolicyTemplate', 'New-AzRecoveryServicesBackupProtectionPolicy', 'Register-AzRecoveryServicesBackupContainer', 'Remove-AzRecoveryServicesBackupProtectionPolicy', '*'
AliasesToExport = '*'
PrivateData = @{
PSData = @{
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'RecoveryServices'
LicenseUri = 'https://aka.ms/azps-license'
ProjectUri = 'https://github.com/Azure/azure-powershell'
ReleaseNotes = ''
}
}
}
157 changes: 157 additions & 0 deletions src/RecoveryServices/RecoveryServices.Backup.Autorest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<!-- region Generated -->
# Az.RecoveryServices
This directory contains the PowerShell module for the RecoveryServices service.

---
## Status
[![Az.RecoveryServices](https://img.shields.io/powershellgallery/v/Az.RecoveryServices.svg?style=flat-square&label=Az.RecoveryServices "Az.RecoveryServices")](https://www.powershellgallery.com/packages/Az.RecoveryServices/)

## Info
- Modifiable: yes
- Generated: all
- Committed: yes
- Packaged: yes

---
## Detail
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.

## Module Requirements
- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.7.5 or greater

## Authentication
AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent.

## Development
For information on how to develop for `Az.RecoveryServices`, see [how-to.md](how-to.md).
<!-- endregion -->

# My API

This file contains the configuration for generating My API from the OpenAPI specification.

> see https://aka.ms/autorest

``` yaml
# it's the same options as command line options, just drop the double-dash!
branch: c94569d116a82ee11a94c5dfb190650dd675a1bf
require:
- $(this-folder)/../../readme.azure.noprofile.md
input-file:
- $(repo)/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/bms.json
title: RecoveryServices
directive:
- from: swagger-document
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}"].put
transform: $["x-ms-long-running-operation"] = true
- from: swagger-document
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}"].delete
transform: $["x-ms-long-running-operation"] = true
- from: swagger-document
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/refreshContainers"].post
transform: $["x-ms-long-running-operation"] = true
- from: swagger-document
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}"].put
transform: $["x-ms-long-running-operation"] = true
- where:
verb: New
subject: ProtectionPolicy
variant: ^CreateViaIdentityExpanded$|^CreateExpanded$|^CreateViaIdentity$
remove: true
- where:
verb: New
subject: ProtectionPolicy
variant: Create
hide: true
- where:
verb: Remove
subject: ProtectionPolicy
variant: DeleteViaIdentity
remove: true
- where:
verb: Get
subject: ProtectedItem
variant: GetViaIdentity
remove: true
- where:
verb: Get
subject: ProtectionPolicy
variant: GetViaIdentity
remove: true
- where:
subject: ProtectionPolicy
set:
subject: BackupPolicy
- where:
subject: Job|BackupEngine|OperationResult|OperationStatuses|EncryptionConfig|StorageConfigsNonCrr|VaultConfig|BackupStatus|BackupUsageSummary|JobDetail|PrivateEndpointConnection|RecoveryPoint|RecommendedForMove|ResourceGuardProxy|SecurityPiN|ItemLevelRecoveryConnection|Restore|Cancellation|ValidateOperation|ResourceGuardProxyDelete|Prepare|FeatureSupport|WorkloadItem|DeletedProtectionContainer|InquireProtectionContainer|PrivateEndpointOperationStatus|^ProtectionIntent
remove: true
- where:
verb: Start
remove: true
- where:
verb: Set
subject: BackupPolicy
remove: true
- where:
verb: Get
subject: BackupPolicy
hide: true
- where:
verb: Remove
subject: BackupPolicy
set:
subject: BackupProtectionPolicy
- where:
subject: BackupProtectableItem
hide: true
- where:
verb: Unregister
subject: ProtectionContainer
remove: true
- where:
verb: New|Remove|Set
subject: ProtectedItem
remove: true
- where:
subject: ProtectedItem|ProtectionIntent|OperationStatus|ProtectionContainer|ProtectableContainer
hide: true
- no-inline:
- DailyRetentionSchedule
- DiskExclusionProperty
- DiskLunList
- ExtendedInfo
- HourlySchedule
- InquiryInfo
- InstantRpDetail
- IsInclusionList
- MonthlyRetentionSchedule
- Settings
- SubProtectionPolicyTieringPolicy
- TieringPolicy
- WeeklyRetentionSchedule
- YearlyRetentionSchedule
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IProtectionPolicy Property', 'public Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IProtectionPolicy Property');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IRetentionPolicy RetentionPolicy', 'public Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IRetentionPolicy RetentionPolicy');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.ISchedulePolicy SchedulePolicy', 'public Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.ISchedulePolicy SchedulePolicy');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IProtectionContainer Property', 'public Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IProtectionContainer Property');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IProtectedItem Property', 'public Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IProtectedItem Property');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IExtendedProperties ExtendedProperty', 'public Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IExtendedProperties ExtendedProperty');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IWorkloadProtectableItem Property', 'public Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IWorkloadProtectableItem Property');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IRecoveryPoint Property', 'public Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IRecoveryPoint Property');
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"resourceType": "vaults/backupPolicies",
"apiVersion": "2023-02-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.recoveryservices"
},
"commands": [
{
"name": "Remove-AzRecoveryServicesBackupProtectionPolicy",
"description": "Deletes specified backup policy from your Recovery Services Vault.\nThis is an asynchronous operation.\nStatus of the\\r\\noperation can be fetched using GetProtectionPolicyOperationResult API.",
"path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupPolicies/{policyName}",
"help": {
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.recoveryservices/remove-azrecoveryservicesbackupprotectionpolicy"
},
"parameterSets": [
{
"parameters": [
"-PolicyName <String>",
"-ResourceGroupName <String>",
"[-SubscriptionId <String>]",
"-VaultName <String>"
]
}
]
},
"examples": [
{
"description": "Deletes specified backup policy from your Recovery Services Vault. This is an asynchronous operation. Status of the\\r\\noperation can be fetched using GetProtectionPolicyOperationResult API.",
"parameters": [
{
"name": "-PolicyName",
"value": "[Path.policyName]"
},
{
"name": "-ResourceGroupName",
"value": "[Path.resourceGroupName]"
},
{
"name": "-SubscriptionId",
"value": "[Path.subscriptionId]"
},
{
"name": "-VaultName",
"value": "[Path.vaultName]"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
function Get-AzRecoveryServicesBackupContainer
{
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Models.Api20230201.IProtectionContainerResource')]
[CmdletBinding(PositionalBinding=$false)]
[Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Description('Gets list of backup containers registered with a recovery services vault')]

param(
[Parameter(Mandatory=$false, HelpMessage='Subscription Id')]
[System.String]
${SubscriptionId},

[Parameter(Mandatory, HelpMessage='The name of the resource group where the recovery services vault is present.')]
[System.String]
${ResourceGroupName},

[Parameter(Mandatory, HelpMessage='The name of the recovery services vault.')]
[System.String]
${VaultName},

[Parameter(Mandatory=$false, HelpMessage='Specifies the friendly name of the container to get')]
[System.String]
${FriendlyName},

[Parameter(Mandatory=$false, HelpMessage='Specifies the DatasourceType')]
[Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Support.DatasourceTypes]
${DatasourceType},

[Parameter(Mandatory=$true, HelpMessage='Specifies the backup container type. The acceptable values for this parameter are: AzureVM, Windows, AzureStorage, AzureVMAppContainer')]
[Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Support.BackupContainerType]
${ContainerType},

[Parameter(Mandatory=$false, HelpMessage='The ResourceGroup of the resource being managed by the Azure Backup service for example: ResourceGroup name of the VM')]
[System.String]
${ContainerResourceGroupName},

[Parameter()]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile},

[Parameter(DontShow)]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter(DontShow)]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(DontShow)]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials}
)

process
{
$containerResourceGroupName = $ContainerResourceGroupName

$filter = Get-ContainerFilter -ContainerType $ContainerType -FriendlyName $FriendlyName -DatasourceType $DatasourceType
Write-Debug "Container filter - $filter"

$inquiryContainerType = $null
if($PSBoundParameters.ContainsKey("DatasourceType")){
# load manifest and get workload type filter if enabled
$manifest = LoadManifest -DatasourceType $DatasourceType.ToString()

if($manifest.containerInquiryType -ne $null){
$inquiryContainerType = $manifest.containerInquiryType
}
}

$null = $PSBoundParameters.Remove("ContainerType")
$null = $PSBoundParameters.Remove("FriendlyName")
$null = $PSBoundParameters.Remove("DatasourceType")
$null = $PSBoundParameters.Remove("ContainerResourceGroupName")

if($filter -ne $null){
$null = $PSBoundParameters.Add("Filter", $filter)
}

$containersList = Az.RecoveryServices.Internal\Get-AzRecoveryServicesBackupProtectionContainer @PSBoundParameters

# filter by container resource group
if($containerResourceGroupName -ne ""){
$containersList = $containersList | Where-Object { $_.Id.Split(';')[-2] -eq $containerResourceGroupName }
}

# filter by worloadType - MSSQL, SAPHANA
if($inquiryContainerType -ne ""){
$containersList = $containersList | Where-Object { $_.Property.ExtendedInfo.InquiryInfo.InquiryDetail.Type -match $inquiryContainerType }
}

$containersList
}
}
Loading
Loading