Skip to content

Commit 9417467

Browse files
Generate powershell cmdlets from latest swagger + add support for customer disk job creation (Azure#21697)
* Generate powershell cmdlets from latest swagger + add support for customer disk job creation * Fix some issues as part of review process * Update test recordings * fixes to examples as per review comments * changes as per review comments * rename parameters
1 parent 53b5bb3 commit 9417467

File tree

50 files changed

+2305
-784
lines changed

Some content is hidden

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

50 files changed

+2305
-784
lines changed

src/DataBox/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

src/DataBox/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
bin
2+
obj
3+
.vs
4+
generated
5+
internal
6+
exports
7+
tools
8+
custom/*.psm1
9+
custom/autogen-model-cmdlets
10+
test/*-TestResults.xml
11+
/*.ps1
12+
/*.ps1xml
13+
/*.psm1
14+
/*.snk
15+
/*.csproj
16+
/*.nuspec

src/DataBox/Az.DataBox.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
DotNetFrameworkVersion = '4.7.2'
1212
RequiredAssemblies = './bin/Az.DataBox.private.dll'
1313
FormatsToProcess = './Az.DataBox.format.ps1xml'
14-
FunctionsToExport = 'Get-AzDataBoxJob', 'Get-AzDataBoxJobCredential', 'New-AzDataBoxContactDetailsObject', 'New-AzDataBoxDiskJobDetailsObject', 'New-AzDataBoxHeavyJobDetailsObject', 'New-AzDataBoxJob', 'New-AzDataBoxJobDetailsObject', 'New-AzDataBoxKeyEncryptionKeyObject', 'New-AzDataBoxManagedDiskDetailsObject', 'New-AzDataBoxShippingAddressObject', 'New-AzDataBoxStorageAccountDetailsObject', 'New-AzDataBoxTransferConfigurationObject', 'Remove-AzDataBoxJob', 'Stop-AzDataBoxJob', 'Update-AzDataBoxJob', '*'
14+
FunctionsToExport = 'Get-AzDataBoxJob', 'Get-AzDataBoxJobCredential', 'New-AzDataBoxContactDetailsObject', 'New-AzDataBoxCustomerDiskJobDetailsObject', 'New-AzDataBoxDiskJobDetailsObject', 'New-AzDataBoxHeavyJobDetailsObject', 'New-AzDataBoxJob', 'New-AzDataBoxJobDetailsObject', 'New-AzDataBoxKeyEncryptionKeyObject', 'New-AzDataBoxManagedDiskDetailsObject', 'New-AzDataBoxShippingAddressObject', 'New-AzDataBoxStorageAccountDetailsObject', 'New-AzDataBoxTransferConfigurationObject', 'Remove-AzDataBoxJob', 'Stop-AzDataBoxJob', 'Update-AzDataBoxJob', '*'
1515
AliasesToExport = '*'
1616
PrivateData = @{
1717
PSData = @{

src/DataBox/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This directory contains the PowerShell module for the DataBox service.
1717
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.
1818

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

2222
## Authentication
2323
AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent.
@@ -35,7 +35,7 @@ require:
3535
- $(this-folder)/../readme.azure.noprofile.md
3636
input-file:
3737
# You need to specify your swagger files here.
38-
- $(repo)/specification/databox/resource-manager/Microsoft.DataBox/stable/2021-03-01/databox.json
38+
- $(repo)/specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/databox.json
3939
# If the swagger has not been put in the repo, you may uncomment the following line and refer to it locally
4040
# - (this-folder)/relative-path-to-your-swagger
4141

@@ -109,6 +109,26 @@ directive:
109109
set:
110110
parameter-name: UserAssignedIdentity
111111

112+
- where:
113+
parameter-name: PreferenceStorageAccountAccessTierPreference
114+
set:
115+
parameter-name: StorageAccountAccessTierPreference
116+
117+
- where:
118+
parameter-name: ReverseShippingDetailShippingAddress
119+
set:
120+
parameter-name: ReverseShippingDetail
121+
122+
- where:
123+
parameter-name: ReverseTransportPreferencePreferredShipmentType
124+
set:
125+
parameter-name: ReverseTransportPreferredShipmentType
126+
127+
- where:
128+
parameter-name: TransportPreferencePreferredShipmentType
129+
set:
130+
parameter-name: TransportPreferredShipmentType
131+
112132
- where:
113133
model-name: JobResource
114134
set:
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
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+
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
14+
# is regenerated.
15+
# ----------------------------------------------------------------------------------
16+
17+
<#
18+
.Synopsis
19+
Create an in-memory object for DataBoxCustomerDiskJobDetails.
20+
.Description
21+
Create an in-memory object for DataBoxCustomerDiskJobDetails.
22+
23+
.Outputs
24+
Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.DataBoxCustomerDiskJobDetails
25+
.Link
26+
https://learn.microsoft.com/powershell/module/Az.DataBox/new-AzDataBoxCustomerDiskJobDetailsObject
27+
#>
28+
function New-AzDataBoxCustomerDiskJobDetailsObject {
29+
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.DataBoxCustomerDiskJobDetails')]
30+
[CmdletBinding(PositionalBinding=$false)]
31+
Param(
32+
33+
[Parameter(HelpMessage="Contains the map of disk serial number to the disk details for import jobs.")]
34+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.IDataBoxCustomerDiskJobDetailsImportDiskDetailsCollection]
35+
$ImportDiskDetailsCollection,
36+
[Parameter(HelpMessage="Contains the map of disk serial number to the disk details for export jobs.")]
37+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.IDataBoxCustomerDiskJobDetailsExportDiskDetailsCollection]
38+
$ExportDiskDetailsCollection,
39+
[Parameter(HelpMessage="Carrier Account Number of customer for customer disk.")]
40+
[string]
41+
$ReturnToCustomerPackageDetailCarrierAccountNumber,
42+
[Parameter(Mandatory, HelpMessage="Contact details for notification and shipping.")]
43+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.IContactDetails]
44+
$ContactDetail,
45+
[Parameter(HelpMessage="Details of the data to be exported from azure.")]
46+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.IDataExportDetails[]]
47+
$DataExportDetail,
48+
[Parameter(HelpMessage="Details of the data to be imported into azure.")]
49+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.IDataImportDetails[]]
50+
$DataImportDetail,
51+
[Parameter(HelpMessage="The expected size of the data, which needs to be transferred in this job, in terabytes.")]
52+
[int]
53+
$ExpectedDataSizeInTeraByte,
54+
[Parameter(HelpMessage="Details about which key encryption type is being used.")]
55+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.IKeyEncryptionKey]
56+
$KeyEncryptionKey,
57+
[Parameter(HelpMessage="Preferences for the order.")]
58+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.IPreferences]
59+
$Preference,
60+
[Parameter(HelpMessage="Optional Reverse Shipping details for order.")]
61+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.IReverseShippingDetails]
62+
$ReverseShippingDetail,
63+
[Parameter(HelpMessage="Shipping address of the customer.")]
64+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.IShippingAddress]
65+
$ShippingAddress,
66+
[Parameter(Mandatory, HelpMessage="Indicates the type of job details.")]
67+
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.DataBox.Support.ClassDiscriminator])]
68+
[Microsoft.Azure.PowerShell.Cmdlets.DataBox.Support.ClassDiscriminator]
69+
$Type
70+
)
71+
72+
process {
73+
$Object = [Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20221201.DataBoxCustomerDiskJobDetails]::New()
74+
75+
if ($PSBoundParameters.ContainsKey('ImportDiskDetailsCollection')) {
76+
$Object.ImportDiskDetailsCollection = $ImportDiskDetailsCollection
77+
}
78+
if ($PSBoundParameters.ContainsKey('ExportDiskDetailsCollection')) {
79+
$Object.ExportDiskDetailsCollection = $ExportDiskDetailsCollection
80+
}
81+
if ($PSBoundParameters.ContainsKey('ReturnToCustomerPackageDetailCarrierAccountNumber')) {
82+
$Object.ReturnToCustomerPackageDetailCarrierAccountNumber = $ReturnToCustomerPackageDetailCarrierAccountNumber
83+
}
84+
if ($PSBoundParameters.ContainsKey('ContactDetail')) {
85+
$Object.ContactDetail = $ContactDetail
86+
}
87+
if ($PSBoundParameters.ContainsKey('DataExportDetail')) {
88+
$Object.DataExportDetail = $DataExportDetail
89+
}
90+
if ($PSBoundParameters.ContainsKey('DataImportDetail')) {
91+
$Object.DataImportDetail = $DataImportDetail
92+
}
93+
if ($PSBoundParameters.ContainsKey('ExpectedDataSizeInTeraByte')) {
94+
$Object.ExpectedDataSizeInTeraByte = $ExpectedDataSizeInTeraByte
95+
}
96+
if ($PSBoundParameters.ContainsKey('KeyEncryptionKey')) {
97+
$Object.KeyEncryptionKey = $KeyEncryptionKey
98+
}
99+
if ($PSBoundParameters.ContainsKey('Preference')) {
100+
$Object.Preference = $Preference
101+
}
102+
if ($PSBoundParameters.ContainsKey('ReverseShippingDetail')) {
103+
$Object.ReverseShippingDetail = $ReverseShippingDetail
104+
}
105+
if ($PSBoundParameters.ContainsKey('ShippingAddress')) {
106+
$Object.ShippingAddress = $ShippingAddress
107+
}
108+
if ($PSBoundParameters.ContainsKey('Type')) {
109+
$Object.Type = $Type
110+
}
111+
return $Object
112+
}
113+
}
114+

src/DataBox/custom/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Custom
2-
This directory contains custom implementation for non-generated cmdlets for the `Az.DataBox` module. Both scripts (`.ps1`) and C# files (`.cs`) can be implemented here. They will be used during the build process in `build-module.ps1`, and create cmdlets into the `../exports` folder. The only generated file into this folder is the `Az.DataBox.custom.psm1`. This file should not be modified.
2+
This directory contains custom implementation for non-generated cmdlets for the `Az.DataBox` module. Both scripts (`.ps1`) and C# files (`.cs`) can be implemented here. They will be used during the build process in `build-module.ps1`, and create cmdlets into the `..\exports` folder. The only generated file into this folder is the `Az.DataBox.custom.psm1`. This file should not be modified.
33

44
## Info
55
- Modifiable: yes
@@ -12,13 +12,13 @@ For `Az.DataBox` to use custom cmdlets, it does this two different ways. We **hi
1212

1313
For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Az.DataBox.private.dll`. The names of the cmdlets (methods) and files must follow the `[cmdletName]_[variantName]` syntax used for generated cmdlets. The `variantName` is used as the `ParameterSetName`, so use something appropriate that doesn't clash with already created variant or parameter set names. You cannot use the `ParameterSetName` property in the `Parameter` attribute on C# cmdlets. Each cmdlet must be separated into variants using the same pattern as seen in the `generated/cmdlets` folder.
1414

15-
For script cmdlets, these are loaded via the `Az.DataBox.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundemental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build.
15+
For script cmdlets, these are loaded via the `Az.DataBox.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundamental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build.
1616

1717
## Purpose
18-
This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `../exports` folder.
18+
This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `..\exports` folder.
1919

2020
## Usage
21-
The easiest way currently to start developing custom cmdlets is to copy an existing cmdlet. For C# cmdlets, copy one from the `generated/cmdlets` folder. For script cmdlets, build the project using `build-module.ps1` and copy one of the scripts from the `../exports` folder. After that, if you want to add new parameter sets, follow the guidelines in the `Details` section above. For implementing a new cmdlets, at minimum, please keep these parameters:
21+
The easiest way currently to start developing custom cmdlets is to copy an existing cmdlet. For C# cmdlets, copy one from the `generated/cmdlets` folder. For script cmdlets, build the project using `build-module.ps1` and copy one of the scripts from the `..\exports` folder. After that, if you want to add new parameter sets, follow the guidelines in the `Details` section above. For implementing a new cmdlets, at minimum, please keep these parameters:
2222
- Break
2323
- DefaultProfile
2424
- HttpPipelineAppend
@@ -32,10 +32,10 @@ These provide functionality to our HTTP pipeline and other useful features. In s
3232
### Attributes
3333
For processing the cmdlets, we've created some additional attributes:
3434
- `Microsoft.Azure.PowerShell.Cmdlets.DataBox.DescriptionAttribute`
35-
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propegated to reference documentation via [help comments](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
35+
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propagated to reference documentation via [help comments](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
3636
- `Microsoft.Azure.PowerShell.Cmdlets.DataBox.DoNotExportAttribute`
3737
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.DataBox`.
3838
- `Microsoft.Azure.PowerShell.Cmdlets.DataBox.InternalExportAttribute`
39-
- Used in C# cmdlets to route exported cmdlets to the `../internal`, which are *not exposed* by `Az.DataBox`. For more information, see [readme.md](../internal/readme.md) in the `../internal` folder.
39+
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.DataBox`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder.
4040
- `Microsoft.Azure.PowerShell.Cmdlets.DataBox.ProfileAttribute`
4141
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.

0 commit comments

Comments
 (0)