Skip to content

[PS] migrate Reservation module to autorest v4 #27545

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

Merged
merged 3 commits into from
Apr 15, 2025
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
30 changes: 30 additions & 0 deletions src/Reservations/Reservations.Autorest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ""AS IS"" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// 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.

using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: System.Reflection.AssemblyCompanyAttribute("Microsoft")]
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - Reservations")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.13.1")]
[assembly: System.Reflection.AssemblyVersionAttribute("0.13.1")]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.CLSCompliantAttribute(false)]




15 changes: 7 additions & 8 deletions src/Reservations/Reservations.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ module-version: 0.1.0
title: Reservations
subject-prefix: $(service-name)

resourcegroup-append: true
nested-object-to-string: true

# For new modules, please avoid setting 3.x using the use-extension method and instead, use 4.x as the default option
use-extension:
"@autorest/powershell": "3.x"

directive:
### Rename Cmdlet names
- where:
Expand Down Expand Up @@ -189,7 +182,13 @@ directive:
subject-prefix: Reservation
subject: AvailableScope

### Hide cmdlet
# Following are common directives which are normally required in all the RPs
# Remove the unexpanded parameter set
- where:
variant: ^(Available|Calculate|Change|Post|Purchase|Split|Update)(?!.*?(Expanded|JsonFilePath|JsonString))
remove: true

### Hide cmdlet to customize
- where:
verb: Split
subject-prefix: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,6 @@
"url": "https://learn.microsoft.com/powershell/module/az.reservations"
},
"commands": [
{
"name": "Get-AzReservationAvailableScope",
"description": "Check whether the scopes from request is valid for `Reservation`.\\n",
"path": "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/availableScopes",
"help": {
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.reservations/get-azreservationavailablescope"
},
"parameterSets": [
{
"parameters": [
"-ReservationId <String>",
"-ReservationOrderId <String>"
]
}
]
},
"examples": [
{
"description": "Check whether the scopes from request is valid for `Reservation`.\\n",
"parameters": [
{
"name": "-ReservationId",
"value": "[Path.reservationId]"
},
{
"name": "-ReservationOrderId",
"value": "[Path.reservationOrderId]"
}
]
}
]
},
{
"name": "Invoke-AzReservationArchiveReservation",
"description": "Archiving a `Reservation` moves it to `Archived` state.",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# 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 @@ -14,58 +14,69 @@

<#
.Synopsis
Return a Reservation.
Return a reservation and get refund information.
.Description
Return a Reservation.
Return a reservation and get refund information.

.Inputs
Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationsIdentity
.Outputs
Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IReservationOrderResponse

Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationOrderResponse
.Notes
COMPLEX PARAMETER PROPERTIES
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.

INPUTOBJECT <IReservationsIdentity>: Identity Parameter
[Id <String>]: Resource identity path
[ReservationId <String>]: Id of the reservation item
[ReservationOrderId <String>]: Order Id of the reservation
[SubscriptionId <String>]: Id of the subscription
.Link
https://learn.microsoft.com/powershell/module/az.reservations/invoke-azreservationreturn
#>
function Invoke-AzReservationReturn {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IReservationOrderResponse])]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationOrderResponse])]
[CmdletBinding(DefaultParameterSetName='PostExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(ParameterSetName='Post', Mandatory)]
[Parameter(ParameterSetName='PostExpanded', Mandatory)]
[Parameter(ParameterSetName='PostViaJsonFilePath', Mandatory)]
[Parameter(ParameterSetName='PostViaJsonString', Mandatory)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Path')]
[System.String]
# Reservation Order Id.
# Order Id of the reservation
${ReservationOrderId},


[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationsIdentity]
# Identity Parameter
${InputObject},

[Parameter(ParameterSetName='PostExpanded', Mandatory)]
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
[System.String]
# Reservation Id to return.
${ReservationToReturnReservationId},

[System.Int32]
# Quantity to be returned.
# Must be greater than zero.
${ReservationToReturnQuantity},

[Parameter(ParameterSetName='PostExpanded', Mandatory)]
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
[int]
# Quantity to return.
${ReservationToReturnQuantity},
[System.String]
# Fully qualified identifier of the reservation being returned
${ReservationToReturnReservationId},

[Parameter(ParameterSetName='PostExpanded', Mandatory)]
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
[System.String]
# The session id obtained from Invoke-AzReservationCalculateRefund..
${SessionId},
# The reason of returning the reservation
${ReturnReason},

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

[Parameter(ParameterSetName='PostViaJsonFilePath', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
[System.String]
# Path of Json file supplied to the Post operation
${JsonFilePath},

[Parameter(ParameterSetName='PostViaJsonString', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
[System.String]
# Json string supplied to the Post operation
${JsonString},
[Parameter(DontShow)]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Azure')]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
# The DefaultProfile parameter is not functional.
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
${DefaultProfile},

[Parameter(DontShow)]
Expand Down Expand Up @@ -128,23 +151,7 @@ function Invoke-AzReservationReturn {
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials},

[Parameter(ParameterSetName='PostViaIdentity', Mandatory, ValueFromPipeline)]
[Parameter(ParameterSetName='PostViaIdentityExpanded', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationsIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='Post', Mandatory)]
[Parameter(ParameterSetName='PostViaIdentity', Mandatory)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IRefundRequest]
# The return request body.
${Body}
${ProxyUseDefaultCredentials}
)

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

# Remove extra parameters for Get-AzReservationOrder
$null = $PSBoundParameters.Remove('Body')
$null = $PSBoundParameters.Remove('JsonString')
$null = $PSBoundParameters.Remove('JsonFilePath')
$null = $PSBoundParameters.Remove('ReservationToReturnReservationId')
$null = $PSBoundParameters.Remove('ReservationToReturnQuantity')
$null = $PSBoundParameters.Remove('SessionId')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Merge two reservations into one reservation within the same reservation order.
Merge two reservations into one reservation within the same reservation order.
#>
function Merge-AzReservation {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IReservationResponse])]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationResponse])]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(Mandatory, HelpMessage='Reservation Order Id.')]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# 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 @@ -19,7 +19,7 @@ Split a Reservation order.
Split a Reservation order.
#>
function Split-AzReservation {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.Api20221101.IReservationResponse])]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Reservations.Models.IReservationResponse])]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(Mandatory, HelpMessage='Reservation Order Id.')]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Module Name: Az.Reservations
Module Guid: 59d3f19f-af05-4d96-a9a8-ff647983b57f
Module Guid: 2aeef1d3-a103-451c-ae76-1769e85dc1f3
Download Help Link: https://learn.microsoft.com/powershell/module/az.reservations
Help Version: 1.0.0.0
Locale: en-US
Expand Down Expand Up @@ -45,7 +45,7 @@ Calculate price for returning `Reservations` if there are no policy errors.\n
Returns one or more `Reservations` in exchange for one or more `Reservation` purchases.\n

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

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

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

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

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

Loading