Skip to content

[PS] Migrate AutoScale module to autorest v4 #28081

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
27 changes: 27 additions & 0 deletions src/Monitor/Autoscale.Autorest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 - Autoscale")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("6.0.2")]
[assembly: System.Reflection.AssemblyVersionAttribute("6.0.2")]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.CLSCompliantAttribute(false)]

29 changes: 6 additions & 23 deletions src/Monitor/Autoscale.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,13 @@ title: Autoscale
module-version: 0.1.0
subject-prefix: Autoscale
namespace: Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale
nested-object-to-string: true

# If there are post APIs for some kinds of actions in the RP, you may need to
# uncomment following line to support viaIdentity for these post APIs
# identity-correction-for-post: 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:
# Following is two common directive which are normally required in all the RPs
# 1. Remove the unexpanded parameter set
# 2. For New-* cmdlets, ViaIdentity is not required, so CreateViaIdentityExpanded is removed as well
- where:
variant: ^Create$|^CreateViaIdentityExpanded$|^Update$|^UpdateViaIdentity$
variant: ^(Create|Update)(?!.*?Expanded)
remove: true
- where:
verb: Set
Expand All @@ -67,14 +58,6 @@ directive:
verb: Update
subject: AutoscaleSetting
hide: true
# Rename 'Equals'
- from: source-file-csharp
where: $
transform: $ = $.replace('public static Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ComparisonOperationType Equals = @"Equals";', 'public static Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ComparisonOperationType Equal = @"Equals";');

- from: source-file-csharp
where: $
transform: $ = $.replace('public static Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ScaleRuleMetricDimensionOperationType Equals = @"Equals";', 'public static Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ScaleRuleMetricDimensionOperationType Equal = @"Equals";');

- from: swagger-document
where: $.definitions.TimeWindow
Expand All @@ -101,9 +84,9 @@ directive:
}

- model-cmdlet:
- AutoscaleProfile
- ScaleRule
- AutoscaleNotification
- WebhookNotification
- ScaleRuleMetricDimension
- model-name: AutoscaleProfile
- model-name: ScaleRule
- model-name: AutoscaleNotification
- model-name: WebhookNotification
- model-name: ScaleRuleMetricDimension
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To update other fields use the CreateOrUpdate method.
.Inputs
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.IAutoscaleIdentity
.Outputs
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.IAutoscaleSettingResource
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.IAutoscaleSettingResource
.Notes
COMPLEX PARAMETER PROPERTIES

Expand Down Expand Up @@ -87,7 +87,7 @@ PROFILE <IAutoscaleProfile[]>: the collection of automatic scaling profiles that
https://learn.microsoft.com/powershell/module/az.monitor/update-azAutoscaleSetting
#>
function Update-AzAutoscaleSetting {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.IAutoscaleSettingResource])]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.IAutoscaleSettingResource])]
[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(ParameterSetName='UpdateExpanded', Mandatory)]
Expand Down Expand Up @@ -129,7 +129,7 @@ function Update-AzAutoscaleSetting {
[Parameter()]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.IAutoscaleNotification[]]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.IAutoscaleNotification[]]
# the collection of notifications.
# To construct, see NOTES section for NOTIFICATION properties and create a hash table.
${Notification},
Expand All @@ -142,24 +142,24 @@ function Update-AzAutoscaleSetting {
${PredictiveAutoscalePolicyScaleLookAheadTime},

[Parameter()]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.PredictiveAutoscalePolicyScaleMode])]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.PSArgumentCompleterAttribute("Disabled", "ForecastOnly", "Enabled")]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.PredictiveAutoscalePolicyScaleMode]
[System.String]
# the predictive autoscale mode
${PredictiveAutoscalePolicyScaleMode},

[Parameter()]
[AllowEmptyCollection()]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.IAutoscaleProfile[]]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.IAutoscaleProfile[]]
# the collection of automatic scaling profiles that specify different scaling parameters for different time periods.
# A maximum of 20 profiles can be specified.
# To construct, see NOTES section for PROFILE properties and create a hash table.
${Profile},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.IAutoscaleSettingResourcePatchTags]))]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.IAutoscaleSettingResourcePatchTags]))]
[System.Collections.Hashtable]
# Resource tags
${Tag},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ Create an in-memory object for AutoscaleNotification.
Create an in-memory object for AutoscaleNotification.

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.AutoscaleNotification
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.AutoscaleNotification
.Link
https://learn.microsoft.com/powershell/module/Az.Monitor/new-AzAutoscaleNotificationObject
https://learn.microsoft.com/powershell/module/Az.Monitor/new-azautoscalenotificationobject
#>
function New-AzAutoscaleNotificationObject {
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.AutoscaleNotification')]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.ModelCmdletAttribute()]
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.AutoscaleNotification')]
[CmdletBinding(PositionalBinding=$false)]
Param(

Expand All @@ -40,12 +41,12 @@ function New-AzAutoscaleNotificationObject {
[bool]
$EmailSendToSubscriptionCoAdministrator,
[Parameter(HelpMessage="the collection of webhook notifications.")]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.IWebhookNotification[]]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.IWebhookNotification[]]
$Webhook
)

process {
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.AutoscaleNotification]::New()
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.AutoscaleNotification]::New()

if ($PSBoundParameters.ContainsKey('EmailCustomEmail')) {
$Object.EmailCustomEmail = $EmailCustomEmail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ Create an in-memory object for AutoscaleProfile.
Create an in-memory object for AutoscaleProfile.

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.AutoscaleProfile
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.AutoscaleProfile
.Link
https://learn.microsoft.com/powershell/module/Az.Monitor/new-AzAutoscaleProfileObject
https://learn.microsoft.com/powershell/module/Az.Monitor/new-azautoscaleprofileobject
#>
function New-AzAutoscaleProfileObject {
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.AutoscaleProfile')]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.ModelCmdletAttribute()]
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.AutoscaleProfile')]
[CmdletBinding(PositionalBinding=$false)]
Param(

Expand All @@ -52,11 +53,11 @@ function New-AzAutoscaleProfileObject {
[string]
$Name,
[Parameter(HelpMessage="the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly.")]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.RecurrenceFrequency])]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.RecurrenceFrequency]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.PSArgumentCompleterAttribute("None", "Second", "Minute", "Hour", "Day", "Week", "Month", "Year")]
[string]
$RecurrenceFrequency,
[Parameter(Mandatory, HelpMessage="the collection of rules that provide the triggers and parameters for the scaling action. A maximum of 10 rules can be specified.")]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.IScaleRule[]]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.IScaleRule[]]
$Rule,
[Parameter(HelpMessage="the collection of days that the profile takes effect on. Possible values are Sunday through Saturday.")]
[string[]]
Expand All @@ -73,7 +74,7 @@ function New-AzAutoscaleProfileObject {
)

process {
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.AutoscaleProfile]::New()
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.AutoscaleProfile]::New()

if ($PSBoundParameters.ContainsKey('CapacityDefault')) {
$Object.CapacityDefault = $CapacityDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,30 @@ Create an in-memory object for ScaleRuleMetricDimension.
Create an in-memory object for ScaleRuleMetricDimension.

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.ScaleRuleMetricDimension
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.ScaleRuleMetricDimension
.Link
https://learn.microsoft.com/powershell/module/Az.Monitor/new-AzAutoscaleScaleRuleMetricDimensionObject
https://learn.microsoft.com/powershell/module/Az.Monitor/new-azautoscalescalerulemetricdimensionobject
#>
function New-AzAutoscaleScaleRuleMetricDimensionObject {
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.ScaleRuleMetricDimension')]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.ModelCmdletAttribute()]
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.ScaleRuleMetricDimension')]
[CmdletBinding(PositionalBinding=$false)]
Param(

[Parameter(Mandatory, HelpMessage="Name of the dimension.")]
[string]
$DimensionName,
[Parameter(Mandatory, HelpMessage="the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values.")]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ScaleRuleMetricDimensionOperationType])]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ScaleRuleMetricDimensionOperationType]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.PSArgumentCompleterAttribute("Equals", "NotEquals")]
[string]
$Operator,
[Parameter(Mandatory, HelpMessage="list of dimension values. For example: [`"App1`",`"App2`"].")]
[string[]]
$Value
)

process {
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.ScaleRuleMetricDimension]::New()
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.ScaleRuleMetricDimension]::New()

if ($PSBoundParameters.ContainsKey('DimensionName')) {
$Object.DimensionName = $DimensionName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ Create an in-memory object for ScaleRule.
Create an in-memory object for ScaleRule.

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.ScaleRule
Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.ScaleRule
.Link
https://learn.microsoft.com/powershell/module/Az.Monitor/new-AzAutoscaleScaleRuleObject
https://learn.microsoft.com/powershell/module/Az.Monitor/new-azautoscalescaleruleobject
#>
function New-AzAutoscaleScaleRuleObject {
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.ScaleRule')]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.ModelCmdletAttribute()]
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.ScaleRule')]
[CmdletBinding(PositionalBinding=$false)]
Param(

[Parameter(HelpMessage="List of dimension conditions. For example: [{`"DimensionName`":`"AppName`",`"Operator`":`"Equals`",`"Values`":[`"App1`"]},{`"DimensionName`":`"Deployment`",`"Operator`":`"Equals`",`"Values`":[`"default`"]}].")]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.IScaleRuleMetricDimension[]]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.IScaleRuleMetricDimension[]]
$MetricTriggerDimension,
[Parameter(HelpMessage="a value indicating whether metric should divide per instance.")]
[bool]
Expand All @@ -49,19 +50,19 @@ function New-AzAutoscaleScaleRuleObject {
[string]
$MetricTriggerMetricResourceUri,
[Parameter(Mandatory, HelpMessage="the operator that is used to compare the metric data and the threshold.")]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ComparisonOperationType])]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ComparisonOperationType]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.PSArgumentCompleterAttribute("Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual")]
[string]
$MetricTriggerOperator,
[Parameter(Mandatory, HelpMessage="the metric statistic type. How the metrics from multiple instances are combined.")]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.MetricStatisticType])]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.MetricStatisticType]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.PSArgumentCompleterAttribute("Average", "Min", "Max", "Sum", "Count")]
[string]
$MetricTriggerStatistic,
[Parameter(Mandatory, HelpMessage="the threshold of the metric that triggers the scale action.")]
[double]
$MetricTriggerThreshold,
[Parameter(Mandatory, HelpMessage="time aggregation type. How the data that is collected should be combined over time. The default value is Average.")]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.TimeAggregationType])]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.TimeAggregationType]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.PSArgumentCompleterAttribute("Average", "Minimum", "Maximum", "Total", "Count", "Last")]
[string]
$MetricTriggerTimeAggregation,
[Parameter(Mandatory, HelpMessage="the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute.")]
[System.TimeSpan]
Expand All @@ -73,20 +74,20 @@ function New-AzAutoscaleScaleRuleObject {
[System.TimeSpan]
$ScaleActionCooldown,
[Parameter(Mandatory, HelpMessage="the scale direction. Whether the scaling action increases or decreases the number of instances.")]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ScaleDirection])]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ScaleDirection]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.PSArgumentCompleterAttribute("None", "Increase", "Decrease")]
[string]
$ScaleActionDirection,
[Parameter(Mandatory, HelpMessage="the type of action that should occur when the scale rule fires.")]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ScaleType])]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Support.ScaleType]
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.PSArgumentCompleterAttribute("ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue")]
[string]
$ScaleActionType,
[Parameter(HelpMessage="the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1.")]
[string]
$ScaleActionValue
)

process {
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.Api20221001.ScaleRule]::New()
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.Autoscale.Models.ScaleRule]::New()

if ($PSBoundParameters.ContainsKey('MetricTriggerDimension')) {
$Object.MetricTriggerDimension = $MetricTriggerDimension
Expand Down
Loading