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.DataProtection] OOB for Az.DataProtection #18477

Merged
merged 4 commits into from
Jun 15, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
806 changes: 576 additions & 230 deletions src/DataProtection/Az.DataProtection.format.ps1xml

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions src/DataProtection/Az.DataProtection.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 12/31/2021
# Generated on: 6/13/2022
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = './Az.DataProtection.psm1'

# Version number of this module.
ModuleVersion = '0.3.1'
ModuleVersion = '0.4.0'

# Supported PSEditions
CompatiblePSEditions = 'Core', 'Desktop'
Expand Down Expand Up @@ -80,6 +80,7 @@ FunctionsToExport = 'Backup-AzDataProtectionBackupInstanceAdhoc',
'Get-AzDataProtectionOperation',
'Get-AzDataProtectionPolicyTemplate',
'Get-AzDataProtectionRecoveryPoint',
'Get-AzDataProtectionResourceGuard',
'Initialize-AzDataProtectionBackupInstance',
'Initialize-AzDataProtectionRestoreRequest',
'New-AzDataProtectionBackupInstance',
Expand All @@ -88,15 +89,22 @@ FunctionsToExport = 'Backup-AzDataProtectionBackupInstanceAdhoc',
'New-AzDataProtectionBackupVaultStorageSettingObject',
'New-AzDataProtectionPolicyTagCriteriaClientObject',
'New-AzDataProtectionPolicyTriggerScheduleClientObject',
'New-AzDataProtectionResourceGuard',
'New-AzDataProtectionRetentionLifeCycleClientObject',
'Remove-AzDataProtectionBackupInstance',
'Remove-AzDataProtectionBackupPolicy',
'Remove-AzDataProtectionBackupVault',
'Remove-AzDataProtectionResourceGuard',
'Resume-AzDataProtectionBackupInstanceProtection',
'Search-AzDataProtectionBackupInstanceInAzGraph',
'Search-AzDataProtectionJobInAzGraph',
'Start-AzDataProtectionBackupInstanceRestore',
'Stop-AzDataProtectionBackupInstanceProtection',
'Suspend-AzDataProtectionBackupInstanceBackup',
'Sync-AzDataProtectionBackupInstance',
'Update-AzDataProtectionBackupInstanceAssociatedPolicy',
'Update-AzDataProtectionBackupVault'
'Update-AzDataProtectionBackupVault',
'Update-AzDataProtectionResourceGuard'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand Down Expand Up @@ -134,7 +142,12 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* Fixed trigger schedule client for ''New-AzDataProtectionPolicyTriggerScheduleClientObject'''
ReleaseNotes = '* Added support for CRUD of resource guard resource.
* Added support for protection related commands with swagger refresh
- Resume-AzDataProtectionBackupInstanceProtection
- Stop-AzDataProtectionBackupInstanceProtection
- Suspend-AzDataProtectionBackupInstanceBackup
- Sync-AzDataProtectionBackupInstance'

# Prerelease string of this module
# Prerelease = ''
Expand Down
166 changes: 89 additions & 77 deletions src/DataProtection/Az.DataProtection.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# region Generated
# ----------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ----------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# 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
Expand All @@ -12,92 +12,104 @@
# limitations under the License.
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
# is regenerated.
# ----------------------------------------------------------------------------------
# Load required Az.Accounts module
$accountsName = 'Az.Accounts'
$accountsModule = Get-Module -Name $accountsName
if(-not $accountsModule) {
$localAccountsPath = Join-Path $PSScriptRoot 'generated\modules'
if(Test-Path -Path $localAccountsPath) {
$localAccounts = Get-ChildItem -Path $localAccountsPath -Recurse -Include 'Az.Accounts.psd1' | Select-Object -Last 1
if($localAccounts) {
$accountsModule = Import-Module -Name ($localAccounts.FullName) -Scope Global -PassThru
}
}
# ----------------------------------------------------------------------------------
# Load required Az.Accounts module
$accountsName = 'Az.Accounts'
$accountsModule = Get-Module -Name $accountsName
if(-not $accountsModule) {
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'2.2.3' } | Measure-Object).Count -gt 0
if($hasAdequateVersion) {
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 2.2.3 -Scope Global -PassThru
$localAccountsPath = Join-Path $PSScriptRoot 'generated\modules'
if(Test-Path -Path $localAccountsPath) {
$localAccounts = Get-ChildItem -Path $localAccountsPath -Recurse -Include 'Az.Accounts.psd1' | Select-Object -Last 1
if($localAccounts) {
$accountsModule = Import-Module -Name ($localAccounts.FullName) -Scope Global -PassThru
}
}
if(-not $accountsModule) {
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'2.7.5' } | Measure-Object).Count -gt 0
if($hasAdequateVersion) {
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 2.7.5 -Scope Global -PassThru
}
}
}
}
if(-not $accountsModule) {
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. For installation instructions, please see: https://docs.microsoft.com/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'2.2.3') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to add the switch '-RegenerateSupportModule' when executing 'test-module.ps1'. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
}
Write-Information "Loaded Module '$($accountsModule.Name)'"
# Load the private module dll
$null = Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.DataProtection.private.dll')
# Get the private module's instance
$instance = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Module]::Instance
# Ask for the shared functionality table
$VTable = Register-AzModule

# Tweaks the pipeline on module load
$instance.OnModuleLoad = $VTable.OnModuleLoad

# Tweaks the pipeline per call
$instance.OnNewRequest = $VTable.OnNewRequest
if(-not $accountsModule) {
Write-Error "`nThis module requires $accountsName version 2.7.5 or greater. For installation instructions, please see: https://docs.microsoft.com/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'2.7.5') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 2.7.5 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to add the switch '-RegenerateSupportModule' when executing 'test-module.ps1'. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
}
Write-Information "Loaded Module '$($accountsModule.Name)'"

# Gets shared parameter values
$instance.GetParameterValue = $VTable.GetParameterValue
# Load the private module dll
$null = Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.DataProtection.private.dll')

# Allows shared module to listen to events from this module
$instance.EventListener = $VTable.EventListener
# Get the private module's instance
$instance = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Module]::Instance

# Gets shared argument completers
$instance.ArgumentCompleter = $VTable.ArgumentCompleter
# Ask for the shared functionality table
$VTable = Register-AzModule

# Tweaks the pipeline on module load
$instance.OnModuleLoad = $VTable.OnModuleLoad

# The name of the currently selected Azure profile
$instance.ProfileName = $VTable.ProfileName
# Following two delegates are added for telemetry
$instance.GetTelemetryId = $VTable.GetTelemetryId
$instance.Telemetry = $VTable.Telemetry


# Load the custom module
$customModulePath = Join-Path $PSScriptRoot './custom/Az.DataProtection.custom.psm1'
if(Test-Path $customModulePath) {
$null = Import-Module -Name $customModulePath
}
# Tweaks the pipeline per call
$instance.OnNewRequest = $VTable.OnNewRequest

# Gets shared parameter values
$instance.GetParameterValue = $VTable.GetParameterValue

# Allows shared module to listen to events from this module
$instance.EventListener = $VTable.EventListener

# Gets shared argument completers
$instance.ArgumentCompleter = $VTable.ArgumentCompleter

# The name of the currently selected Azure profile
$instance.ProfileName = $VTable.ProfileName

# Export nothing to clear implicit exports
Export-ModuleMember
# Export proxy cmdlet scripts
$exportsPath = Join-Path $PSScriptRoot './exports'
$directories = Get-ChildItem -Directory -Path $exportsPath
$profileDirectory = $null
if($instance.ProfileName) {
if(($directories | ForEach-Object { $_.Name }) -contains $instance.ProfileName) {
$profileDirectory = $directories | Where-Object { $_.Name -eq $instance.ProfileName }
} else {
# Don't export anything if the profile doesn't exist for the module
$exportsPath = $null
Write-Warning "Selected Azure profile '$($instance.ProfileName)' does not exist for module '$($instance.Name)'. No cmdlets were loaded."

# Load the custom module
$customModulePath = Join-Path $PSScriptRoot './custom/Az.DataProtection.custom.psm1'
if(Test-Path $customModulePath) {
$null = Import-Module -Name $customModulePath
}
} elseif(($directories | Measure-Object).Count -gt 0) {
# Load the last folder if no profile is selected
$profileDirectory = $directories | Select-Object -Last 1
}

# Export nothing to clear implicit exports
Export-ModuleMember

if($profileDirectory) {
Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
$exportsPath = $profileDirectory.FullName
}
# Export proxy cmdlet scripts
$exportsPath = Join-Path $PSScriptRoot './exports'
$directories = Get-ChildItem -Directory -Path $exportsPath
$profileDirectory = $null
if($instance.ProfileName) {
if(($directories | ForEach-Object { $_.Name }) -contains $instance.ProfileName) {
$profileDirectory = $directories | Where-Object { $_.Name -eq $instance.ProfileName }
} else {
# Don't export anything if the profile doesn't exist for the module
$exportsPath = $null
Write-Warning "Selected Azure profile '$($instance.ProfileName)' does not exist for module '$($instance.Name)'. No cmdlets were loaded."
}
} elseif(($directories | Measure-Object).Count -gt 0) {
# Load the last folder if no profile is selected
$profileDirectory = $directories | Select-Object -Last 1
}

if($profileDirectory) {
Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
$exportsPath = $profileDirectory.FullName
}

if($exportsPath) {
Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath
Export-ModuleMember -Function $cmdletNames -Alias (Get-ScriptCmdlet -ScriptFolder $exportsPath -AsAlias)
}

if($exportsPath) {
Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath
Export-ModuleMember -Function $cmdletNames -Alias (Get-ScriptCmdlet -ScriptFolder $exportsPath -AsAlias)
}
# Finalize initialization of this module
$instance.Init();
Write-Information "Loaded Module '$($instance.Name)'"
# Finalize initialization of this module
$instance.Init();
Write-Information "Loaded Module '$($instance.Name)'"
# endregion
8 changes: 8 additions & 0 deletions src/DataProtection/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
-->
## Upcoming Release

## Version 0.4.0
* Added support for CRUD of resource guard resource.
* Added support for protection related commands with swagger refresh
- Resume-AzDataProtectionBackupInstanceProtection
- Stop-AzDataProtectionBackupInstanceProtection
- Suspend-AzDataProtectionBackupInstanceBackup
- Sync-AzDataProtectionBackupInstance

## Version 0.3.1
* Fixed trigger schedule client for `New-AzDataProtectionPolicyTriggerScheduleClientObject`

Expand Down
Loading