Skip to content

Migrate Monitor from wyunchi/generation/pipeline/code-gen to wyunchi/pipeline/code-gen #23871

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

Closed
Closed
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
2 changes: 1 addition & 1 deletion src/Monitor/ActionGroup.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For information on how to develop for `Az.ActionGroup`, see [how-to.md](how-to.m
require:
# readme.azure.noprofile.md is the common configuration file
- $(this-folder)/../../readme.azure.noprofile.md
branch: 47d1d82108a0db0395ed4eca106622becee7fbb4
commit: 47d1d82108a0db0395ed4eca106622becee7fbb4

input-file:
- $(repo)/specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/actionGroups_API.json
Expand Down
8 changes: 3 additions & 5 deletions src/Monitor/ActionGroup.Autorest/generate-portal-ux.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ $instance = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActionGroup.Module]::Ins
$moduleInfo = Get-Module -Name $moduleName
$parameterSetsInfo = Get-Module -Name "$moduleName.private"

$buildinFunctions = @("Export-CmdletSurface", "Export-ExampleStub", "Export-FormatPs1xml", "Export-HelpMarkdown", "Export-ModelSurface", "Export-ProxyCmdlet", "Export-Psd1", "Export-TestStub", "Get-CommonParameter", "Get-ModuleGuid", "Get-ScriptCmdlet")

function Test-FunctionSupported()
{
[CmdletBinding()]
Expand All @@ -53,12 +51,12 @@ function Test-FunctionSupported()
$FunctionName
)

If ($buildinfunctions.Contains($FunctionName)) {
If (-not $FunctionName.Contains("_")) {
return $false
}

$cmdletName, $parameterSetName = $FunctionName.Split("_")
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity")) {
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity") -or $parameterSetName.Contains("ViaJson")) {
return $false
}
If ($cmdletName.StartsWith("New") -or $cmdletName.StartsWith("Set") -or $cmdletName.StartsWith("Update")) {
Expand Down Expand Up @@ -311,7 +309,7 @@ function New-MetadataForCmdlet()
return $result
}

$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-functionSupported($_) }
$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-FunctionSupported($_) }
$resourceTypes = @{}
foreach ($parameterSetName in $parameterSets)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,31 @@ protected override void ProcessRecord()
return -join ((48..57) + (97..122) | Get-Random -Count $len | % {[char]$_})
}
}
function Start-TestSleep {
[CmdletBinding(DefaultParameterSetName = 'SleepBySeconds')]
param(
[parameter(Mandatory = $true, Position = 0, ParameterSetName = 'SleepBySeconds')]
[ValidateRange(0.0, 2147483.0)]
[double] $Seconds,

[parameter(Mandatory = $true, ParameterSetName = 'SleepByMilliseconds')]
[ValidateRange('NonNegative')]
[Alias('ms')]
[int] $Milliseconds
)

if ($TestMode -ne 'playback') {
switch ($PSCmdlet.ParameterSetName) {
'SleepBySeconds' {
Start-Sleep -Seconds $Seconds
}
'SleepByMilliseconds' {
Start-Sleep -Milliseconds $Milliseconds
}
}
}
}

$env = @{}
if ($UsePreviousConfigForRecord) {
$previousEnv = Get-Content (Join-Path $PSScriptRoot 'env.json') | ConvertFrom-Json
Expand Down
7 changes: 6 additions & 1 deletion src/Monitor/ActivityLogAlert.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ For information on how to develop for `Az.ActivityLogAlert`, see [how-to.md](how
### AutoRest Configuration
> see https://aka.ms/autorest
``` yaml
commit: e94b0da0c7f80e2986af90c1dd7e9c8f4c336c61
require:
# readme.azure.noprofile.md is the common configuration file
- $(this-folder)/../../readme.azure.noprofile.md
input-file:
# You need to specify your swagger files here.
- https://github.com/Azure/azure-rest-api-specs/blob/e94b0da0c7f80e2986af90c1dd7e9c8f4c336c61/specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/activityLogAlerts_API.json
- $(repo)/specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/activityLogAlerts_API.json

root-module-name: $(prefix).Monitor
title: ActivityLogAlert
Expand All @@ -48,6 +49,10 @@ nested-object-to-string: true
# 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
Expand Down
7 changes: 6 additions & 1 deletion src/Monitor/Autoscale.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ For information on how to develop for `Az.Autoscale`, see [how-to.md](how-to.md)
### AutoRest Configuration
> see https://aka.ms/autorest
``` yaml
commit: 9ae616c4a5447e9cae43752b68f089bff2e46398
require:
# readme.azure.noprofile.md is the common configuration file
- $(this-folder)/../../readme.azure.noprofile.md
input-file:
# You need to specify your swagger files here.
- https://github.com/Azure/azure-rest-api-specs/blob/9ae616c4a5447e9cae43752b68f089bff2e46398/specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/autoscale_API.json
- $(repo)/specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/autoscale_API.json

root-module-name: $(prefix).Monitor
title: Autoscale
Expand All @@ -47,6 +48,10 @@ nested-object-to-string: true
# 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
Expand Down
25 changes: 25 additions & 0 deletions src/Monitor/Autoscale.Autorest/test/utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ function RandomString([bool]$allChars, [int32]$len) {
return -join ((48..57) + (97..122) | Get-Random -Count $len | % {[char]$_})
}
}
function Start-TestSleep {
[CmdletBinding(DefaultParameterSetName = 'SleepBySeconds')]
param(
[parameter(Mandatory = $true, Position = 0, ParameterSetName = 'SleepBySeconds')]
[ValidateRange(0.0, 2147483.0)]
[double] $Seconds,

[parameter(Mandatory = $true, ParameterSetName = 'SleepByMilliseconds')]
[ValidateRange('NonNegative')]
[Alias('ms')]
[int] $Milliseconds
)

if ($TestMode -ne 'playback') {
switch ($PSCmdlet.ParameterSetName) {
'SleepBySeconds' {
Start-Sleep -Seconds $Seconds
}
'SleepByMilliseconds' {
Start-Sleep -Milliseconds $Milliseconds
}
}
}
}

$env = @{}
if ($UsePreviousConfigForRecord) {
$previousEnv = Get-Content (Join-Path $PSScriptRoot 'env.json') | ConvertFrom-Json
Expand Down
5 changes: 1 addition & 4 deletions src/Monitor/DataCollectionRule.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For information on how to develop for `Az.DataCollectionRule`, see [how-to.md](h
require:
# readme.azure.noprofile.md is the common configuration file
- $(this-folder)/../../readme.azure.noprofile.md
branch: 4f4044394791773e6e7e82a9bd90d3935caaca1b
commit: 4f4044394791773e6e7e82a9bd90d3935caaca1b

input-file:
- $(repo)/specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/dataCollectionEndpoints_API.json
Expand All @@ -49,9 +49,6 @@ subject-prefix: ''
resourcegroup-append: true
nested-object-to-string: true

use-extension:
"@autorest/powershell": "4.x"

directive:
- remove-operation: DataCollectionRules_Update
# # Following is two common directive which are normally required in all the RPs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ $instance = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.DataCollection.Module]::
$moduleInfo = Get-Module -Name $moduleName
$parameterSetsInfo = Get-Module -Name "$moduleName.private"

$buildinFunctions = @("Export-CmdletSurface", "Export-ExampleStub", "Export-FormatPs1xml", "Export-HelpMarkdown", "Export-ModelSurface", "Export-ProxyCmdlet", "Export-Psd1", "Export-TestStub", "Get-CommonParameter", "Get-ModuleGuid", "Get-ScriptCmdlet")

function Test-FunctionSupported()
{
[CmdletBinding()]
Expand All @@ -53,12 +51,12 @@ function Test-FunctionSupported()
$FunctionName
)

If ($buildinfunctions.Contains($FunctionName)) {
If (-not $FunctionName.Contains("_")) {
return $false
}

$cmdletName, $parameterSetName = $FunctionName.Split("_")
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity")) {
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity") -or $parameterSetName.Contains("ViaJson")) {
return $false
}
If ($cmdletName.StartsWith("New") -or $cmdletName.StartsWith("Set") -or $cmdletName.StartsWith("Update")) {
Expand Down Expand Up @@ -311,7 +309,7 @@ function New-MetadataForCmdlet()
return $result
}

$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-functionSupported($_) }
$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-FunctionSupported($_) }
$resourceTypes = @{}
foreach ($parameterSetName in $parameterSets)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,31 @@ protected override void ProcessRecord()
return -join ((48..57) + (97..122) | Get-Random -Count $len | % {[char]$_})
}
}
function Start-TestSleep {
[CmdletBinding(DefaultParameterSetName = 'SleepBySeconds')]
param(
[parameter(Mandatory = $true, Position = 0, ParameterSetName = 'SleepBySeconds')]
[ValidateRange(0.0, 2147483.0)]
[double] $Seconds,

[parameter(Mandatory = $true, ParameterSetName = 'SleepByMilliseconds')]
[ValidateRange('NonNegative')]
[Alias('ms')]
[int] $Milliseconds
)

if ($TestMode -ne 'playback') {
switch ($PSCmdlet.ParameterSetName) {
'SleepBySeconds' {
Start-Sleep -Seconds $Seconds
}
'SleepByMilliseconds' {
Start-Sleep -Milliseconds $Milliseconds
}
}
}
}

$env = @{}
if ($UsePreviousConfigForRecord) {
$previousEnv = Get-Content (Join-Path $PSScriptRoot 'env.json') | ConvertFrom-Json
Expand Down
13 changes: 9 additions & 4 deletions src/Monitor/DiagnosticSetting.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ For information on how to develop for `Az.DiagnosticSetting`, see [how-to.md](ho
### AutoRest Configuration
> see https://aka.ms/autorest
``` yaml
commit: e94b0da0c7f80e2986af90c1dd7e9c8f4c336c61
require:
# readme.azure.noprofile.md is the common configuration file
- $(this-folder)/../../readme.azure.noprofile.md
input-file:
# You need to specify your swagger files here.
- https://github.com/Azure/azure-rest-api-specs/blob/62ec79080af0d0d609650d67155ef4a93ae11482/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/diagnosticsSettings_API.json
- https://github.com/Azure/azure-rest-api-specs/blob/62ec79080af0d0d609650d67155ef4a93ae11482/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/diagnosticsSettingsCategories_API.json
- https://github.com/Azure/azure-rest-api-specs/blob/62ec79080af0d0d609650d67155ef4a93ae11482/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/subscriptionDiagnosticsSettings_API.json
- https://github.com/Azure/azure-rest-api-specs/blob/e94b0da0c7f80e2986af90c1dd7e9c8f4c336c61/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/eventCategories_API.json
- $(repo)/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/diagnosticsSettings_API.json
- $(repo)/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/diagnosticsSettingsCategories_API.json
- $(repo)/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/subscriptionDiagnosticsSettings_API.json
- $(repo)/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/eventCategories_API.json

root-module-name: $(prefix).Monitor
title: DiagnosticSetting
Expand All @@ -50,6 +51,10 @@ nested-object-to-string: true
# 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
Expand Down
10 changes: 10 additions & 0 deletions src/Monitor/Metrics.Autorest/Az.Metric.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PsModuleName>Metric</PsModuleName>
<PsRootModuleName>Monitor</PsRootModuleName>
<PsModuleFolder>Metrics.Autorest</PsModuleFolder>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., build.proj))\src\Az.autorest.props" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., build.proj))\src\Az.Post.props" />
</Project>
Loading