Skip to content

Commit 6fa2807

Browse files
authored
[PS] migrate Reservation module to autorest v4 (Azure#27545)
1 parent 50c5f05 commit 6fa2807

File tree

59 files changed

+1290
-951
lines changed

Some content is hidden

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

59 files changed

+1290
-951
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0 (the ""License"");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an ""AS IS"" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
12+
// is regenerated.
13+
14+
using System;
15+
using System.Reflection;
16+
using System.Runtime.CompilerServices;
17+
using System.Runtime.InteropServices;
18+
19+
[assembly: System.Reflection.AssemblyCompanyAttribute("Microsoft")]
20+
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
21+
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
22+
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - Reservations")]
23+
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.13.1")]
24+
[assembly: System.Reflection.AssemblyVersionAttribute("0.13.1")]
25+
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
26+
[assembly: System.CLSCompliantAttribute(false)]
27+
28+
29+
30+

src/Reservations/Reservations.Autorest/README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ module-version: 0.1.0
5353
title: Reservations
5454
subject-prefix: $(service-name)
5555

56-
resourcegroup-append: true
57-
nested-object-to-string: true
58-
59-
# For new modules, please avoid setting 3.x using the use-extension method and instead, use 4.x as the default option
60-
use-extension:
61-
"@autorest/powershell": "3.x"
62-
6356
directive:
6457
### Rename Cmdlet names
6558
- where:
@@ -189,7 +182,13 @@ directive:
189182
subject-prefix: Reservation
190183
subject: AvailableScope
191184

192-
### Hide cmdlet
185+
# Following are common directives which are normally required in all the RPs
186+
# Remove the unexpanded parameter set
187+
- where:
188+
variant: ^(Available|Calculate|Change|Post|Purchase|Split|Update)(?!.*?(Expanded|JsonFilePath|JsonString))
189+
remove: true
190+
191+
### Hide cmdlet to customize
193192
- where:
194193
verb: Split
195194
subject-prefix: ''

src/Reservations/Reservations.Autorest/UX/Microsoft.Capacity/reservationOrders-reservations.json

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,6 @@
55
"url": "https://learn.microsoft.com/powershell/module/az.reservations"
66
},
77
"commands": [
8-
{
9-
"name": "Get-AzReservationAvailableScope",
10-
"description": "Check whether the scopes from request is valid for `Reservation`.\\n",
11-
"path": "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/availableScopes",
12-
"help": {
13-
"learnMore": {
14-
"url": "https://learn.microsoft.com/powershell/module/az.reservations/get-azreservationavailablescope"
15-
},
16-
"parameterSets": [
17-
{
18-
"parameters": [
19-
"-ReservationId <String>",
20-
"-ReservationOrderId <String>"
21-
]
22-
}
23-
]
24-
},
25-
"examples": [
26-
{
27-
"description": "Check whether the scopes from request is valid for `Reservation`.\\n",
28-
"parameters": [
29-
{
30-
"name": "-ReservationId",
31-
"value": "[Path.reservationId]"
32-
},
33-
{
34-
"name": "-ReservationOrderId",
35-
"value": "[Path.reservationOrderId]"
36-
}
37-
]
38-
}
39-
]
40-
},
418
{
429
"name": "Invoke-AzReservationArchiveReservation",
4310
"description": "Archiving a `Reservation` moves it to `Archived` state.",

src/Reservations/Reservations.Autorest/UX/Microsoft.Capacity/reservationOrders.json

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/Reservations/Reservations.Autorest/custom/Invoke-AzReservationReturn.ps1

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ----------------------------------------------------------------------------------
22
#
3-
# Copyright Microsoft Corporation
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
66
# You may obtain a copy of the License at
@@ -14,58 +14,69 @@
1414

1515
<#
1616
.Synopsis
17-
Return a Reservation.
17+
Return a reservation and get refund information.
1818
.Description
19-
Return a Reservation.
19+
Return a reservation and get refund information.
2020
2121
.Inputs
2222
Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationsIdentity
2323
.Outputs
24-
Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IReservationOrderResponse
25-
24+
Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationOrderResponse
25+
.Notes
26+
COMPLEX PARAMETER PROPERTIES
2627
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.
2728
2829
INPUTOBJECT <IReservationsIdentity>: Identity Parameter
2930
[Id <String>]: Resource identity path
3031
[ReservationId <String>]: Id of the reservation item
3132
[ReservationOrderId <String>]: Order Id of the reservation
3233
[SubscriptionId <String>]: Id of the subscription
34+
.Link
35+
https://learn.microsoft.com/powershell/module/az.reservations/invoke-azreservationreturn
3336
#>
3437
function Invoke-AzReservationReturn {
35-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IReservationOrderResponse])]
36-
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
38+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationOrderResponse])]
39+
[CmdletBinding(DefaultParameterSetName='PostExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
3740
param(
38-
[Parameter(ParameterSetName='Post', Mandatory)]
3941
[Parameter(ParameterSetName='PostExpanded', Mandatory)]
42+
[Parameter(ParameterSetName='PostViaJsonFilePath', Mandatory)]
43+
[Parameter(ParameterSetName='PostViaJsonString', Mandatory)]
4044
[ValidateNotNull()]
41-
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
45+
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Path')]
4246
[System.String]
43-
# Reservation Order Id.
47+
# Order Id of the reservation
4448
${ReservationOrderId},
45-
49+
50+
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory, ValueFromPipeline)]
51+
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Path')]
52+
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationsIdentity]
53+
# Identity Parameter
54+
${InputObject},
55+
4656
[Parameter(ParameterSetName='PostExpanded', Mandatory)]
4757
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory)]
4858
[ValidateNotNull()]
4959
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
50-
[System.String]
51-
# Reservation Id to return.
52-
${ReservationToReturnReservationId},
53-
60+
[System.Int32]
61+
# Quantity to be returned.
62+
# Must be greater than zero.
63+
${ReservationToReturnQuantity},
64+
5465
[Parameter(ParameterSetName='PostExpanded', Mandatory)]
5566
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory)]
5667
[ValidateNotNull()]
5768
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
58-
[int]
59-
# Quantity to return.
60-
${ReservationToReturnQuantity},
69+
[System.String]
70+
# Fully qualified identifier of the reservation being returned
71+
${ReservationToReturnReservationId},
6172

6273
[Parameter(ParameterSetName='PostExpanded', Mandatory)]
6374
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory)]
6475
[ValidateNotNull()]
6576
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
6677
[System.String]
67-
# The session id obtained from Invoke-AzReservationCalculateRefund..
68-
${SessionId},
78+
# The reason of returning the reservation
79+
${ReturnReason},
6980

7081
[Parameter(ParameterSetName='PostExpanded', Mandatory)]
7182
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory)]
@@ -80,15 +91,27 @@ function Invoke-AzReservationReturn {
8091
[ValidateNotNull()]
8192
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
8293
[System.String]
83-
# The reason for this reservation return.
84-
${ReturnReason},
94+
# The session id obtained from Invoke-AzReservationCalculateRefund..
95+
${SessionId},
8596

97+
[Parameter(ParameterSetName='PostViaJsonFilePath', Mandatory)]
98+
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
99+
[System.String]
100+
# Path of Json file supplied to the Post operation
101+
${JsonFilePath},
102+
103+
[Parameter(ParameterSetName='PostViaJsonString', Mandatory)]
104+
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
105+
[System.String]
106+
# Json string supplied to the Post operation
107+
${JsonString},
86108
[Parameter(DontShow)]
87109
[Alias('AzureRMContext', 'AzureCredential')]
88110
[ValidateNotNull()]
89111
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Azure')]
90112
[System.Management.Automation.PSObject]
91-
# The credentials, account, tenant, and subscription used for communication with Azure.
113+
# The DefaultProfile parameter is not functional.
114+
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
92115
${DefaultProfile},
93116

94117
[Parameter(DontShow)]
@@ -128,23 +151,7 @@ function Invoke-AzReservationReturn {
128151
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Runtime')]
129152
[System.Management.Automation.SwitchParameter]
130153
# Use the default credentials for the proxy
131-
${ProxyUseDefaultCredentials},
132-
133-
[Parameter(ParameterSetName='PostViaIdentity', Mandatory, ValueFromPipeline)]
134-
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory, ValueFromPipeline)]
135-
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Path')]
136-
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationsIdentity]
137-
# Identity Parameter
138-
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
139-
${InputObject},
140-
141-
[Parameter(ParameterSetName='Post', Mandatory)]
142-
[Parameter(ParameterSetName='PostViaIdentity', Mandatory)]
143-
[ValidateNotNull()]
144-
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
145-
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IRefundRequest]
146-
# The return request body.
147-
${Body}
154+
${ProxyUseDefaultCredentials}
148155
)
149156

150157
process {
@@ -153,7 +160,8 @@ function Invoke-AzReservationReturn {
153160
$response = Az.Reservations.internal\Invoke-AzReservationReturn @PSBoundParameters
154161

155162
# Remove extra parameters for Get-AzReservationOrder
156-
$null = $PSBoundParameters.Remove('Body')
163+
$null = $PSBoundParameters.Remove('JsonString')
164+
$null = $PSBoundParameters.Remove('JsonFilePath')
157165
$null = $PSBoundParameters.Remove('ReservationToReturnReservationId')
158166
$null = $PSBoundParameters.Remove('ReservationToReturnQuantity')
159167
$null = $PSBoundParameters.Remove('SessionId')

src/Reservations/Reservations.Autorest/custom/Merge-AzReservation.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Merge two reservations into one reservation within the same reservation order.
1919
Merge two reservations into one reservation within the same reservation order.
2020
#>
2121
function Merge-AzReservation {
22-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IReservationResponse])]
22+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationResponse])]
2323
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
2424
param(
2525
[Parameter(Mandatory, HelpMessage='Reservation Order Id.')]

src/Reservations/Reservations.Autorest/custom/Split-AzReservation.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ----------------------------------------------------------------------------------
22
#
3-
# Copyright Microsoft Corporation
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
66
# You may obtain a copy of the License at
@@ -19,7 +19,7 @@ Split a Reservation order.
1919
Split a Reservation order.
2020
#>
2121
function Split-AzReservation {
22-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IReservationResponse])]
22+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationResponse])]
2323
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
2424
param(
2525
[Parameter(Mandatory, HelpMessage='Reservation Order Id.')]

src/Reservations/Reservations.Autorest/docs/Az.Reservations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Module Name: Az.Reservations
3-
Module Guid: 59d3f19f-af05-4d96-a9a8-ff647983b57f
3+
Module Guid: 2aeef1d3-a103-451c-ae76-1769e85dc1f3
44
Download Help Link: https://learn.microsoft.com/powershell/module/az.reservations
55
Help Version: 1.0.0.0
66
Locale: en-US
@@ -45,7 +45,7 @@ Calculate price for returning `Reservations` if there are no policy errors.\n
4545
Returns one or more `Reservations` in exchange for one or more `Reservation` purchases.\n
4646

4747
### [Invoke-AzReservationReturn](Invoke-AzReservationReturn.md)
48-
Return a Reservation.
48+
Return a reservation and get refund information.
4949

5050
### [Invoke-AzReservationUnarchiveReservation](Invoke-AzReservationUnarchiveReservation.md)
5151
Restores a `Reservation` to the state it was before archiving.\n
@@ -57,11 +57,11 @@ Merge two reservations into one reservation within the same reservation order.
5757
Change directory (tenant) of `ReservationOrder` and all `Reservation` under it to specified tenant id
5858

5959
### [New-AzReservation](New-AzReservation.md)
60-
Purchase `ReservationOrder` and create resource under the specified URI.
60+
Purchase `ReservationOrder` and purchase resource under the specified URI.
6161

6262
### [Split-AzReservation](Split-AzReservation.md)
6363
Split a Reservation order.
6464

6565
### [Update-AzReservation](Update-AzReservation.md)
66-
Updates the applied scopes of the `Reservation`.
66+
update the applied scopes of the `Reservation`.
6767

0 commit comments

Comments
 (0)