Skip to content

Commit 24137f5

Browse files
dolauliazurepowershellVeryEarly
authored
[Az.DataProtection] OnBoard workload AzureBlobs to Az.DataProtection preview module (Azure#14833)
* Move DataProtection to master * Add change log for Az.DataProtection v0.2.0 (Azure#14832) * Update Find-AzDataProtectionRestorableTimeRange.md * Update Changelog.md Co-authored-by: azurepowershell <[email protected]> Co-authored-by: Yabo Hu <[email protected]>
1 parent b5516be commit 24137f5

File tree

633 files changed

+12219
-7323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

633 files changed

+12219
-7323
lines changed

src/DataProtection/Az.DataProtection.format.ps1xml

Lines changed: 290 additions & 200 deletions
Large diffs are not rendered by default.

src/DataProtection/Az.DataProtection.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 3/18/2021
6+
# Generated on: 4/26/2021
77
#
88

99
@{
@@ -73,6 +73,7 @@ FunctionsToExport = 'Backup-AzDataProtectionBackupInstanceAdhoc',
7373
'Edit-AzDataProtectionPolicyRetentionRuleClientObject',
7474
'Edit-AzDataProtectionPolicyTagClientObject',
7575
'Edit-AzDataProtectionPolicyTriggerClientObject',
76+
'Find-AzDataProtectionRestorableTimeRange',
7677
'Get-AzDataProtectionBackupInstance',
7778
'Get-AzDataProtectionBackupPolicy',
7879
'Get-AzDataProtectionBackupVault', 'Get-AzDataProtectionJob',

src/DataProtection/Az.DataProtection.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
if(-not $accountsModule) {
3535
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
3636
} elseif (($accountsModule.Version -lt [System.Version]'2.2.3') -and (-not $localAccounts)) {
37-
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 remove '.PSSharedModules' in your home directory. 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
37+
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
3838
}
3939
Write-Information "Loaded Module '$($accountsModule.Name)'"
4040

src/DataProtection/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* OnBoarded workload AzureBlobs
2122

2223
## Version 0.1.0
2324
* First preview release for module Az.DataProtection

src/DataProtection/build-module.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ $moduleName = 'Az.DataProtection'
120120
$examplesFolder = Join-Path $PSScriptRoot 'examples'
121121
$null = New-Item -ItemType Directory -Force -Path $examplesFolder
122122

123+
Write-Host -ForegroundColor Green 'Creating cmdlets for specified models...'
124+
$modelCmdlets = @()
125+
. (Join-Path $PSScriptRoot 'create-model-cmdlets.ps1') -Models $modelCmdlets
126+
123127
if($NoDocs) {
124128
Write-Host -ForegroundColor Green 'Creating exports...'
125129
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs -ExamplesFolder $examplesFolder

src/DataProtection/check-dependencies.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ $tools = Join-Path $PSScriptRoot 'tools'
5353
$resourceDir = Join-Path $tools 'Resources'
5454
$resourceModule = Join-Path $HOME '.PSSharedModules\Resources\Az.Resources.TestSupport.psm1'
5555

56-
if ($Resources.IsPresent -and (-not (Test-Path -Path $resourceModule))) {
56+
if ($Resources.IsPresent -and ((-not (Test-Path -Path $resourceModule)) -or $RegenerateSupportModule.IsPresent)) {
5757
Write-Host -ForegroundColor Green "Building local Resource module used for test..."
5858
Set-Location $resourceDir
5959
$null = autorest .\readme.md --use:@autorest/powershell@3.0.414 --output-folder=$HOME/.PSSharedModules/Resources
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
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+
param([string[]]$Models)
16+
17+
if ($Models.Count -eq 0)
18+
{
19+
return
20+
}
21+
22+
$ModelCsPath = Join-Path (Join-Path $PSScriptRoot 'generated\api') 'Models'
23+
$ModuleName = 'Az.DataProtection'.Split(".")[1]
24+
$OutputDir = Join-Path $PSScriptRoot 'custom\autogen-model-cmdlets'
25+
$null = New-Item -ItemType Directory -Force -Path $OutputDir
26+
27+
$CsFiles = Get-ChildItem -Path $ModelCsPath -Recurse -Filter *.cs
28+
$Content = ''
29+
$null = $CsFiles | ForEach-Object -Process { if ($_.Name.Split('.').count -eq 2 )
30+
{ $Content += get-content $_.fullname -raw
31+
} }
32+
33+
$Tree = [Microsoft.CodeAnalysis.CSharp.SyntaxFactory]::ParseCompilationUnit($Content)
34+
$Nodes = $Tree.ChildNodes().ChildNodes()
35+
foreach ($Model in $Models)
36+
{
37+
$InterfaceNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq "I$Model") }
38+
if ($InterfaceNode.count -eq 0) {
39+
continue
40+
}
41+
# through a queue, we iterate all the parent models.
42+
$Queue = @($InterfaceNode)
43+
$visited = @("I$Model")
44+
$AllInterfaceNodes = @()
45+
while ($Queue.count -ne 0)
46+
{
47+
$AllInterfaceNodes += $Queue[0]
48+
# Baselist contains the direct parent models.
49+
foreach ($parent in $Queue[0].BaseList.Types)
50+
{
51+
if (($parent.Type.Right.Identifier.Value -ne 'IJsonSerializable') -and (-not $visited.Contains($parent.Type.Right.Identifier.Value)))
52+
{
53+
$Queue = [Array]$Queue + ($Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq $parent.Type.Right.Identifier.Value) })
54+
$visited = [Array]$visited + $parent.Type.Right.Identifier.Value
55+
}
56+
}
57+
$first, $Queue = $Queue
58+
}
59+
60+
$Namespace = $InterfaceNode.Parent.Name
61+
$ObjectType = $Model
62+
$ObjectTypeWithNamespace = "${Namespace}.${ObjectType}"
63+
# remove duplicated module name
64+
if ($ObjectType.StartsWith($ModuleName)) {
65+
$ModulePrefix = ''
66+
} else {
67+
$ModulePrefix = $ModuleName
68+
}
69+
$OutputPath = Join-Path -ChildPath "New-Az${ModulePrefix}${ObjectType}Object.ps1" -Path $OutputDir
70+
71+
$ParameterDefineScriptList = New-Object System.Collections.Generic.List[string]
72+
$ParameterAssignScriptList = New-Object System.Collections.Generic.List[string]
73+
foreach ($Node in $AllInterfaceNodes)
74+
{
75+
foreach ($Member in $Node.Members)
76+
{
77+
$Arguments = $Member.AttributeLists.Attributes.ArgumentList.Arguments
78+
$Required = $false
79+
$Description = ""
80+
$Readonly = $False
81+
foreach ($Argument in $Arguments)
82+
{
83+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Required")
84+
{
85+
$Required = $Argument.Expression.Token.Value
86+
}
87+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Description")
88+
{
89+
$Description = $Argument.Expression.Token.Value.Trim('.').replace('"', '`"')
90+
}
91+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Readonly")
92+
{
93+
$Readonly = $Argument.Expression.Token.Value
94+
}
95+
}
96+
if ($Readonly)
97+
{
98+
continue
99+
}
100+
$Identifier = $Member.Identifier.Value
101+
$Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
102+
$ParameterDefinePropertyList = New-Object System.Collections.Generic.List[string]
103+
if ($Required)
104+
{
105+
$ParameterDefinePropertyList.Add("Mandatory")
106+
}
107+
if ($Description -ne "")
108+
{
109+
$ParameterDefinePropertyList.Add("HelpMessage=`"${Description}.`"")
110+
}
111+
$ParameterDefineProperty = [System.String]::Join(", ", $ParameterDefinePropertyList)
112+
$ParameterDefineScript = "
113+
[Parameter($ParameterDefineProperty)]
114+
[${Type}]
115+
`$${Identifier}"
116+
$ParameterDefineScriptList.Add($ParameterDefineScript)
117+
$ParameterAssignScriptList.Add("
118+
`$Object.${Identifier} = `$${Identifier}")
119+
}
120+
}
121+
$ParameterDefineScript = $ParameterDefineScriptList | Join-String -Separator ","
122+
$ParameterAssignScript = $ParameterAssignScriptList | Join-String -Separator ""
123+
124+
$Script = "
125+
# ----------------------------------------------------------------------------------
126+
#
127+
# Copyright Microsoft Corporation
128+
# Licensed under the Apache License, Version 2.0 (the \`"License\`");
129+
# you may not use this file except in compliance with the License.
130+
# You may obtain a copy of the License at
131+
# http://www.apache.org/licenses/LICENSE-2.0
132+
# Unless required by applicable law or agreed to in writing, software
133+
# distributed under the License is distributed on an \`"AS IS\`" BASIS,
134+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135+
# See the License for the specific language governing permissions and
136+
# limitations under the License.
137+
# ----------------------------------------------------------------------------------
138+
139+
<#
140+
.Synopsis
141+
Create a in-memory object for ${ObjectType}
142+
.Description
143+
Create a in-memory object for ${ObjectType}
144+
145+
.Outputs
146+
${ObjectTypeWithNamespace}
147+
.Link
148+
https://docs.microsoft.com/powershell/module//az.${ModuleName}/new-Az${ModulePrefix}${ObjectType}Object
149+
#>
150+
function New-Az${ModulePrefix}${ObjectType}Object {
151+
[OutputType('${ObjectTypeWithNamespace}')]
152+
[CmdletBinding(PositionalBinding=`$false)]
153+
Param(
154+
${ParameterDefineScript}
155+
)
156+
157+
process {
158+
`$Object = [${ObjectTypeWithNamespace}]::New()
159+
${ParameterAssignScript}
160+
return `$Object
161+
}
162+
}
163+
"
164+
Set-Content -Path $OutputPath -Value $Script
165+
}

src/DataProtection/custom/Cmdlets/Backupcenter/Search-AzDataProtectionBackupInstanceInAzGraph.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
foreach($argResponse in $argInstanceResponse)
5656
{
5757
$jsonStringResponse = $argResponse | ConvertTo-Json -Depth 100
58-
$backupInstances += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.BackupInstanceResource]::FromJsonString($jsonStringResponse)
58+
$backupInstances += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api202101.BackupInstanceResource]::FromJsonString($jsonStringResponse)
5959
}
6060
return $backupInstances
6161
}

src/DataProtection/custom/Cmdlets/Backupcenter/Search-AzDataProtectionJobInAzGraph.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
foreach($jobresponse in $argJobResponse)
8484
{
8585
$jsonStringResponse = $jobresponse | ConvertTo-Json -Depth 100
86-
$backupJobs += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.AzureBackupJobResource]::FromJsonString($jsonStringResponse)
86+
$backupJobs += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api202101.AzureBackupJobResource]::FromJsonString($jsonStringResponse)
8787
}
8888
return $backupJobs
8989
}

src/DataProtection/custom/Cmdlets/Common/Initialize-AzDataProtectionBackupInstance.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
function Initialize-AzDataProtectionBackupInstance {
5-
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.IBackupInstanceResource')]
5+
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api202101.IBackupInstanceResource')]
66
[CmdletBinding(PositionalBinding=$false)]
77
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Initializes Backup instance Request object for configuring backup')]
88

@@ -29,7 +29,7 @@ function Initialize-AzDataProtectionBackupInstance {
2929
process {
3030

3131
$manifest = LoadManifest -DatasourceType $DatasourceType.ToString()
32-
$backupInstance = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.BackupInstance]::new()
32+
$backupInstance = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api202101.BackupInstance]::new()
3333
$backupInstance.ObjectType = "BackupInstance"
3434

3535
if($PSBoundParameters.ContainsKey("DatasourceId"))
@@ -50,7 +50,7 @@ function Initialize-AzDataProtectionBackupInstance {
5050

5151

5252

53-
$backupInstanceResource = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.BackupInstanceResource]::new()
53+
$backupInstanceResource = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api202101.BackupInstanceResource]::new()
5454
$backupInstanceResource.Property = $backupInstance
5555

5656
if($PSBoundParameters.ContainsKey("DatasourceId"))
@@ -68,7 +68,7 @@ function Initialize-AzDataProtectionBackupInstance {
6868

6969
if($DatasourceType.ToString() -eq "AzureDisk")
7070
{
71-
$operationalParam = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.AzureOperationalStoreParameters]::new()
71+
$operationalParam = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api202101.AzureOperationalStoreParameters]::new()
7272
$operationalParam.DataStoreType = "OperationalStore"
7373
$operationalParam.ObjectType = "AzureOperationalStoreParameters"
7474
$operationalParam.ResourceGroupId = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}"

src/DataProtection/custom/Cmdlets/Common/New-AzDataProtectionBackupInstance.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function New-AzDataProtectionBackupInstance {
2020
${VaultName},
2121

2222
[Parameter(Mandatory, HelpMessage='Backup instance request object which will be used to configure backup')]
23-
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.IBackupInstanceResource]
23+
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api202101.IBackupInstanceResource]
2424
${BackupInstance},
2525

2626
[Parameter()]

src/DataProtection/custom/Cmdlets/Common/Update-AzDataProtectionBackupInstanceAssociatedPolicy.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
function Update-AzDataProtectionBackupInstanceAssociatedPolicy
44
{
5-
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20210201Preview.IBackupInstanceResource')]
5+
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api202101.IBackupInstanceResource')]
66
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess)]
77
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Updates associated policy for a given backup instance')]
88

0 commit comments

Comments
 (0)