diff --git a/src/Monitor/Metric.Autorest/Az.Metric.csproj b/src/Monitor/Metric.Autorest/Az.Metric.csproj
new file mode 100644
index 000000000000..54e967009531
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/Az.Metric.csproj
@@ -0,0 +1,10 @@
+
+
+ Metric
+ Monitor
+ Metric.Autorest
+
+
+
+
+
diff --git a/src/Monitor/Metric.Autorest/Az.Metric.format.ps1xml b/src/Monitor/Metric.Autorest/Az.Metric.format.ps1xml
new file mode 100644
index 000000000000..901c1a52387d
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/Az.Metric.format.ps1xml
@@ -0,0 +1,471 @@
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse#Multiple
+
+
+
+
+ Code
+
+
+ Message
+
+
+ Target
+
+
+
+
+
+
+ Code
+
+
+ Message
+
+
+ Target
+
+
+
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString#Multiple
+
+
+
+
+ LocalizedValue
+
+
+ Value
+
+
+
+
+
+
+ LocalizedValue
+
+
+ Value
+
+
+
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetadataValue
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetadataValue#Multiple
+
+
+
+
+ Value
+
+
+
+
+
+
+ Value
+
+
+
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Metric
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Metric#Multiple
+
+
+
+
+ DisplayDescription
+
+
+ ErrorCode
+
+
+ ErrorMessage
+
+
+ Unit
+
+
+
+
+
+
+ DisplayDescription
+
+
+ ErrorCode
+
+
+ ErrorMessage
+
+
+ Unit
+
+
+
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricDefinition
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricDefinition#Multiple
+
+
+
+
+ Category
+
+
+ DisplayDescription
+
+
+ IsDimensionRequired
+
+
+ MetricClass
+
+
+ Namespace
+
+
+ PrimaryAggregationType
+
+
+ ResourceId
+
+
+ Unit
+
+
+
+
+
+
+ Category
+
+
+ DisplayDescription
+
+
+ IsDimensionRequired
+
+
+ MetricClass
+
+
+ Namespace
+
+
+ PrimaryAggregationType
+
+
+ ResourceId
+
+
+ Unit
+
+
+
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricIdentity
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricIdentity#Multiple
+
+
+
+
+ ResourceUri
+
+
+ SubscriptionId
+
+
+
+
+
+
+ ResourceUri
+
+
+ SubscriptionId
+
+
+
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricValue
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricValue#Multiple
+
+
+
+
+ Average
+
+
+ Count
+
+
+ Maximum
+
+
+ Minimum
+
+
+ TimeStamp
+
+
+ Total
+
+
+
+
+
+
+ Average
+
+
+ Count
+
+
+ Maximum
+
+
+ Minimum
+
+
+ TimeStamp
+
+
+ Total
+
+
+
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Response
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Response#Multiple
+
+
+
+
+ Cost
+
+
+ Interval
+
+
+ Namespace
+
+
+ Resourceregion
+
+
+ Timespan
+
+
+
+
+
+
+ Cost
+
+
+ Interval
+
+
+ Namespace
+
+
+ Resourceregion
+
+
+ Timespan
+
+
+
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.SubscriptionScopeMetricDefinition
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.SubscriptionScopeMetricDefinition#Multiple
+
+
+
+
+ Category
+
+
+ DisplayDescription
+
+
+ IsDimensionRequired
+
+
+ MetricClass
+
+
+ Namespace
+
+
+ PrimaryAggregationType
+
+
+ ResourceId
+
+
+ Unit
+
+
+
+
+
+
+ Category
+
+
+ DisplayDescription
+
+
+ IsDimensionRequired
+
+
+ MetricClass
+
+
+ Namespace
+
+
+ PrimaryAggregationType
+
+
+ ResourceId
+
+
+ Unit
+
+
+
+
+
+
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.SubscriptionScopeMetricsRequestBodyParameters
+
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.SubscriptionScopeMetricsRequestBodyParameters#Multiple
+
+
+
+
+ Aggregation
+
+
+ AutoAdjustTimegrain
+
+
+ Filter
+
+
+ Interval
+
+
+ MetricName
+
+
+ MetricNamespace
+
+
+ OrderBy
+
+
+ ResultType
+
+
+ RollUpBy
+
+
+ Timespan
+
+
+ Top
+
+
+ ValidateDimension
+
+
+
+
+
+
+ Aggregation
+
+
+ AutoAdjustTimegrain
+
+
+ Filter
+
+
+ Interval
+
+
+ MetricName
+
+
+ MetricNamespace
+
+
+ OrderBy
+
+
+ ResultType
+
+
+ RollUpBy
+
+
+ Timespan
+
+
+ Top
+
+
+ ValidateDimension
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/Az.Metric.psd1 b/src/Monitor/Metric.Autorest/Az.Metric.psd1
new file mode 100644
index 000000000000..f4c03e3de4f0
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/Az.Metric.psd1
@@ -0,0 +1,23 @@
+@{
+ GUID = '3c8bd492-2949-4471-a98c-6dee77ee7f73'
+ RootModule = './Az.Metric.psm1'
+ ModuleVersion = '0.1.0'
+ CompatiblePSEditions = 'Core', 'Desktop'
+ Author = 'Microsoft Corporation'
+ CompanyName = 'Microsoft Corporation'
+ Copyright = 'Microsoft Corporation. All rights reserved.'
+ Description = 'Microsoft Azure PowerShell: Metric cmdlets'
+ PowerShellVersion = '5.1'
+ DotNetFrameworkVersion = '4.7.2'
+ RequiredAssemblies = './bin/Az.Metric.private.dll'
+ FormatsToProcess = './Az.Metric.format.ps1xml'
+ FunctionsToExport = 'Get-AzMetric', 'Get-AzMetricDefinition', 'New-AzMetricFilter'
+ PrivateData = @{
+ PSData = @{
+ Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'Metric'
+ LicenseUri = 'https://aka.ms/azps-license'
+ ProjectUri = 'https://github.com/Azure/azure-powershell'
+ ReleaseNotes = ''
+ }
+ }
+}
diff --git a/src/Monitor/Metric.Autorest/Az.Metric.psm1 b/src/Monitor/Metric.Autorest/Az.Metric.psm1
new file mode 100644
index 000000000000..d19ac1344ec2
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/Az.Metric.psm1
@@ -0,0 +1,119 @@
+# region Generated
+ # ----------------------------------------------------------------------------------
+ # 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.
+ # ----------------------------------------------------------------------------------
+ # Load required Az.Accounts module
+ $accountsName = 'Az.Accounts'
+ $accountsModule = Get-Module -Name $accountsName
+ if(-not $accountsModule) {
+ $localAccountsPath = Join-Path $PSScriptRoot 'generated\modules'
+ if(Test-Path -Path $localAccountsPath) {
+ $localAccounts = Get-ChildItem -Path $localAccountsPath -Recurse -Include 'Az.Accounts.psd1' | Select-Object -Last 1
+ if($localAccounts) {
+ $accountsModule = Import-Module -Name ($localAccounts.FullName) -Scope Global -PassThru
+ }
+ }
+ if(-not $accountsModule) {
+ $hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'2.7.5' } | Measure-Object).Count -gt 0
+ if($hasAdequateVersion) {
+ $accountsModule = Import-Module -Name $accountsName -MinimumVersion 2.7.5 -Scope Global -PassThru
+ }
+ }
+ }
+
+ if(-not $accountsModule) {
+ Write-Error "`nThis module requires $accountsName version 2.7.5 or greater. For installation instructions, please see: https://learn.microsoft.com/powershell/azure/install-az-ps" -ErrorAction Stop
+ } elseif (($accountsModule.Version -lt [System.Version]'2.7.5') -and (-not $localAccounts)) {
+ Write-Error "`nThis module requires $accountsName version 2.7.5 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to add the switch '-RegenerateSupportModule' when executing 'test-module.ps1'. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
+ }
+ Write-Information "Loaded Module '$($accountsModule.Name)'"
+
+ # Load the private module dll
+ $null = Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.Metric.private.dll')
+
+ # Get the private module's instance
+ $instance = [Microsoft.Azure.PowerShell.Cmdlets.Metric.Module]::Instance
+
+ # Ask for the shared functionality table
+ $VTable = Register-AzModule
+
+ # Tweaks the pipeline on module load
+ $instance.OnModuleLoad = $VTable.OnModuleLoad
+
+ # Following two delegates are added for telemetry
+ $instance.GetTelemetryId = $VTable.GetTelemetryId
+ $instance.Telemetry = $VTable.Telemetry
+
+ # Delegate to sanitize the output object
+ $instance.SanitizeOutput = $VTable.SanitizerHandler
+
+ # Delegate to get the telemetry info
+ $instance.GetTelemetryInfo = $VTable.GetTelemetryInfo
+
+ # Tweaks the pipeline per call
+ $instance.OnNewRequest = $VTable.OnNewRequest
+
+ # Gets shared parameter values
+ $instance.GetParameterValue = $VTable.GetParameterValue
+
+ # Allows shared module to listen to events from this module
+ $instance.EventListener = $VTable.EventListener
+
+ # Gets shared argument completers
+ $instance.ArgumentCompleter = $VTable.ArgumentCompleter
+
+ # The name of the currently selected Azure profile
+ $instance.ProfileName = $VTable.ProfileName
+
+ # Load the custom module
+ $customModulePath = Join-Path $PSScriptRoot './custom/Az.Metric.custom.psm1'
+ if(Test-Path $customModulePath) {
+ $null = Import-Module -Name $customModulePath
+ }
+
+ # Export nothing to clear implicit exports
+ Export-ModuleMember
+
+ # Export proxy cmdlet scripts
+ $exportsPath = Join-Path $PSScriptRoot './exports'
+ $directories = Get-ChildItem -Directory -Path $exportsPath
+ $profileDirectory = $null
+ if($instance.ProfileName) {
+ if(($directories | ForEach-Object { $_.Name }) -contains $instance.ProfileName) {
+ $profileDirectory = $directories | Where-Object { $_.Name -eq $instance.ProfileName }
+ } else {
+ # Don't export anything if the profile doesn't exist for the module
+ $exportsPath = $null
+ Write-Warning "Selected Azure profile '$($instance.ProfileName)' does not exist for module '$($instance.Name)'. No cmdlets were loaded."
+ }
+ } elseif(($directories | Measure-Object).Count -gt 0) {
+ # Load the last folder if no profile is selected
+ $profileDirectory = $directories | Select-Object -Last 1
+ }
+
+ if($profileDirectory) {
+ Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
+ $exportsPath = $profileDirectory.FullName
+ }
+
+ if($exportsPath) {
+ Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+ $cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath
+ Export-ModuleMember -Function $cmdletNames -Alias (Get-ScriptCmdlet -ScriptFolder $exportsPath -AsAlias)
+ }
+
+ # Finalize initialization of this module
+ $instance.Init();
+ Write-Information "Loaded Module '$($instance.Name)'"
+# endregion
diff --git a/src/Monitor/Metric.Autorest/README.md b/src/Monitor/Metric.Autorest/README.md
new file mode 100644
index 000000000000..13b881c111cb
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/README.md
@@ -0,0 +1,113 @@
+
+# Az.Metric
+This directory contains the PowerShell module for the Metric service.
+
+---
+## Info
+- Modifiable: yes
+- Generated: all
+- Committed: yes
+- Packaged: yes
+
+---
+## Detail
+This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.
+
+## Module Requirements
+- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.7.5 or greater
+
+## Authentication
+AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent.
+
+## Development
+For information on how to develop for `Az.Metric`, see [how-to.md](how-to.md).
+
+
+### AutoRest Configuration
+> see https://aka.ms/autorest
+```yaml
+# pin the swagger version by using the commit id instead of branch name
+require:
+# readme.azure.noprofile.md is the common configuration file
+ - $(this-folder)/../../readme.azure.noprofile.md
+commit: 62937afd6872cb4da67787bcc7866725db3366a5
+
+input-file:
+ - $(repo)/specification/monitor/resource-manager/Microsoft.Insights/stable/2023-10-01/metricDefinitions_API.json
+ - $(repo)/specification/monitor/resource-manager/Microsoft.Insights/stable/2023-10-01/metrics_API.json
+
+root-module-name: $(prefix).Monitor
+title: Metric
+module-name: Az.Metric
+module-version: 0.1.0
+subject-prefix: Metric
+
+directive:
+ # remove duplicate parameter
+ - from: swagger-document
+ where: $.paths["/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics"].post.parameters
+ transform: >-
+ return [
+ {
+ "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/SubscriptionIdParameter"
+ },
+ {
+ "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter"
+ },
+ {
+ "$ref": "../../../../common-types/v2/commonMonitoringTypes.json#/parameters/RegionParameter"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Parameters serialized in the body",
+ "schema": {
+ "$ref": "#/definitions/SubscriptionScopeMetricsRequestBodyParameters"
+ }
+ }
+ ]
+ # remove variant: Metrics_ListAtSubscriptionScope and non-expanded Metrics_ListAtSubscriptionScopePost
+ - where:
+ subject: Metric
+ variant: ^List$|^List1$
+ remove: true
+ # rollupby and orderby use Camel-Case, fix 'Sequence contains no matching element' error when building Metrics_ListAtSubscriptionScopePost
+ - where:
+ subject: Metric
+ parameter-name: rollUpBy
+ set:
+ parameter-name: RollUpBy
+ - where:
+ subject: Metric
+ parameter-name: orderBy
+ set:
+ parameter-name: OrderBy
+ - where:
+ parameter-name: Metricnamespace
+ set:
+ parameter-name: MetricNamespace
+ - where:
+ parameter-name: Metricname
+ set:
+ parameter-name: MetricName
+ # Fix breaking change
+ - where:
+ parameter-name: ResourceUri
+ set:
+ alias: ResourceId
+ - where:
+ parameter-name: Filter
+ set:
+ alias: MetricFilter
+ - where:
+ parameter-name: Aggregation
+ set:
+ alias: AggregationType
+ - where:
+ parameter-name: Interval
+ set:
+ alias: TimeGrain
+ # Customize cmdlets
+ - where:
+ subject: Metric
+ hide: true
diff --git a/src/Monitor/Metric.Autorest/build-module.ps1 b/src/Monitor/Metric.Autorest/build-module.ps1
new file mode 100644
index 000000000000..c5d901d1cf42
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/build-module.ps1
@@ -0,0 +1,180 @@
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+param([switch]$NotIsolated, [switch]$Run, [switch]$Test, [switch]$Docs, [switch]$Pack, [switch]$Code, [switch]$Release, [switch]$Debugger, [switch]$NoDocs, [switch]$UX)
+$ErrorActionPreference = 'Stop'
+
+if($PSEdition -ne 'Core') {
+ Write-Error 'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.'
+}
+
+if(-not $NotIsolated -and -not $Debugger) {
+ Write-Host -ForegroundColor Green 'Creating isolated process...'
+ $pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
+ & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -NotIsolated
+
+ if($LastExitCode -ne 0) {
+ # Build failed. Don't attempt to run the module.
+ return
+ }
+
+ if($Test) {
+ . (Join-Path $PSScriptRoot 'test-module.ps1')
+ if($LastExitCode -ne 0) {
+ # Tests failed. Don't attempt to run the module.
+ return
+ }
+ }
+
+ if($Docs) {
+ . (Join-Path $PSScriptRoot 'generate-help.ps1')
+ if($LastExitCode -ne 0) {
+ # Docs generation failed. Don't attempt to run the module.
+ return
+ }
+ }
+
+ if($UX) {
+ . (Join-Path $PSScriptRoot 'generate-portal-ux.ps1')
+ if($LastExitCode -ne 0) {
+ # UX generation failed. Don't attempt to run the module.
+ return
+ }
+ }
+
+ if($Pack) {
+ . (Join-Path $PSScriptRoot 'pack-module.ps1')
+ if($LastExitCode -ne 0) {
+ # Packing failed. Don't attempt to run the module.
+ return
+ }
+ }
+
+ $runModulePath = Join-Path $PSScriptRoot 'run-module.ps1'
+ if($Code) {
+ . $runModulePath -Code
+ } elseif($Run) {
+ . $runModulePath
+ } else {
+ Write-Host -ForegroundColor Cyan "To run this module in an isolated PowerShell session, run the 'run-module.ps1' script or provide the '-Run' parameter to this script."
+ }
+ return
+}
+
+$binFolder = Join-Path $PSScriptRoot 'bin'
+$objFolder = Join-Path $PSScriptRoot 'obj'
+
+if(-not $Debugger) {
+ Write-Host -ForegroundColor Green 'Cleaning build folders...'
+ $null = Remove-Item -Recurse -ErrorAction SilentlyContinue -Path $binFolder, $objFolder
+
+ if((Test-Path $binFolder) -or (Test-Path $objFolder)) {
+ Write-Host -ForegroundColor Cyan 'Did you forget to exit your isolated module session before rebuilding?'
+ Write-Error 'Unable to clean ''bin'' or ''obj'' folder. A process may have an open handle.'
+ }
+
+ Write-Host -ForegroundColor Green 'Compiling module...'
+ $buildConfig = 'Debug'
+ if($Release) {
+ $buildConfig = 'Release'
+ }
+ dotnet publish $PSScriptRoot --verbosity quiet --configuration $buildConfig /nologo
+ if($LastExitCode -ne 0) {
+ Write-Error 'Compilation failed.'
+ }
+
+ $null = Remove-Item -Recurse -ErrorAction SilentlyContinue -Path (Join-Path $binFolder 'Debug'), (Join-Path $binFolder 'Release')
+}
+
+$dll = Join-Path $PSScriptRoot 'bin\Az.Metric.private.dll'
+if(-not (Test-Path $dll)) {
+ Write-Error "Unable to find output assembly in '$binFolder'."
+}
+
+# Load DLL to use build-time cmdlets
+$null = Import-Module -Name $dll
+
+$modulePaths = $dll
+$customPsm1 = Join-Path $PSScriptRoot 'custom\Az.Metric.custom.psm1'
+if(Test-Path $customPsm1) {
+ $modulePaths = @($dll, $customPsm1)
+}
+
+$exportsFolder = Join-Path $PSScriptRoot 'exports'
+if(Test-Path $exportsFolder) {
+ $null = Get-ChildItem -Path $exportsFolder -Recurse -Exclude 'README.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue
+}
+$null = New-Item -ItemType Directory -Force -Path $exportsFolder
+
+$internalFolder = Join-Path $PSScriptRoot 'internal'
+if(Test-Path $internalFolder) {
+ $null = Get-ChildItem -Path $internalFolder -Recurse -Exclude '*.psm1', 'README.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue
+}
+$null = New-Item -ItemType Directory -Force -Path $internalFolder
+
+$psd1 = Join-Path $PSScriptRoot './Az.Metric.psd1'
+$guid = Get-ModuleGuid -Psd1Path $psd1
+$moduleName = 'Az.Metric'
+$examplesFolder = Join-Path $PSScriptRoot 'examples'
+$null = New-Item -ItemType Directory -Force -Path $examplesFolder
+
+Write-Host -ForegroundColor Green 'Creating cmdlets for specified models...'
+$modelCmdlets = @()
+$modelCmdletFolder = Join-Path (Join-Path $PSScriptRoot './custom') 'autogen-model-cmdlets'
+if (Test-Path $modelCmdletFolder) {
+ $null = Remove-Item -Force -Recurse -Path $modelCmdletFolder
+}
+if ($modelCmdlets.Count -gt 0) {
+ . (Join-Path $PSScriptRoot 'create-model-cmdlets.ps1')
+ CreateModelCmdlet($modelCmdlets)
+}
+
+if($NoDocs) {
+ Write-Host -ForegroundColor Green 'Creating exports...'
+ Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs -ExamplesFolder $examplesFolder
+} else {
+ Write-Host -ForegroundColor Green 'Creating exports and docs...'
+ $moduleDescription = 'Microsoft Azure PowerShell: Metric cmdlets'
+ $docsFolder = Join-Path $PSScriptRoot 'docs'
+ if(Test-Path $docsFolder) {
+ $null = Get-ChildItem -Path $docsFolder -Recurse -Exclude 'README.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue
+ }
+ $null = New-Item -ItemType Directory -Force -Path $docsFolder
+ $addComplexInterfaceInfo = ![System.Convert]::ToBoolean('true')
+ Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ModuleDescription $moduleDescription -DocsFolder $docsFolder -ExamplesFolder $examplesFolder -ModuleGuid $guid -AddComplexInterfaceInfo:$addComplexInterfaceInfo
+}
+
+Write-Host -ForegroundColor Green 'Creating format.ps1xml...'
+$formatPs1xml = Join-Path $PSScriptRoot './Az.Metric.format.ps1xml'
+Export-FormatPs1xml -FilePath $formatPs1xml
+
+Write-Host -ForegroundColor Green 'Creating psd1...'
+$customFolder = Join-Path $PSScriptRoot 'custom'
+Export-Psd1 -ExportsFolder $exportsFolder -CustomFolder $customFolder -Psd1Path $psd1 -ModuleGuid $guid
+
+Write-Host -ForegroundColor Green 'Creating test stubs...'
+$testFolder = Join-Path $PSScriptRoot 'test'
+$null = New-Item -ItemType Directory -Force -Path $testFolder
+Export-TestStub -ModuleName $moduleName -ExportsFolder $exportsFolder -OutputFolder $testFolder
+
+Write-Host -ForegroundColor Green 'Creating example stubs...'
+Export-ExampleStub -ExportsFolder $exportsFolder -OutputFolder $examplesFolder
+
+if (Test-Path (Join-Path $PSScriptRoot 'generate-portal-ux.ps1'))
+{
+ Write-Host -ForegroundColor Green 'Creating ux metadata...'
+ . (Join-Path $PSScriptRoot 'generate-portal-ux.ps1')
+}
+
+Write-Host -ForegroundColor Green '-------------Done-------------'
diff --git a/src/Monitor/Metric.Autorest/check-dependencies.ps1 b/src/Monitor/Metric.Autorest/check-dependencies.ps1
new file mode 100644
index 000000000000..90ca9867ae40
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/check-dependencies.ps1
@@ -0,0 +1,65 @@
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+param([switch]$NotIsolated, [switch]$Accounts, [switch]$Pester, [switch]$Resources)
+$ErrorActionPreference = 'Stop'
+
+if(-not $NotIsolated) {
+ Write-Host -ForegroundColor Green 'Creating isolated process...'
+ $pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
+ & "$pwsh" -NoExit -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -NotIsolated
+ return
+}
+
+function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum, [string]$requiredVersion) {
+ if($predicate) {
+ $module = Get-Module -ListAvailable -Name $moduleName
+ if((-not $module) -or ($versionMinimum -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -ge [System.Version]$versionMinimum } | Measure-Object).Count -eq 0) -or ($requiredVersion -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -eq [System.Version]$requiredVersion } | Measure-Object).Count -eq 0)) {
+ $null = New-Item -ItemType Directory -Force -Path $path
+ Write-Host -ForegroundColor Green "Installing local $moduleName module into '$path'..."
+ if ($requiredVersion) {
+ Find-Module -Name $moduleName -RequiredVersion $requiredVersion -Repository PSGallery | Save-Module -Path $path
+ }elseif($versionMinimum) {
+ Find-Module -Name $moduleName -MinimumVersion $versionMinimum -Repository PSGallery | Save-Module -Path $path
+ } else {
+ Find-Module -Name $moduleName -Repository PSGallery | Save-Module -Path $path
+ }
+ }
+ }
+}
+
+$ProgressPreference = 'SilentlyContinue'
+$all = (@($Accounts.IsPresent, $Pester.IsPresent) | Select-Object -Unique | Measure-Object).Count -eq 1
+
+$localModulesPath = Join-Path $PSScriptRoot 'generated\modules'
+if(Test-Path -Path $localModulesPath) {
+ $env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath"
+}
+
+DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '2.7.5'
+DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -requiredVersion '4.10.1'
+
+$tools = Join-Path $PSScriptRoot 'tools'
+$resourceDir = Join-Path $tools 'Resources'
+$resourceModule = Join-Path $HOME '.PSSharedModules\Resources\Az.Resources.TestSupport.psm1'
+
+if ($Resources.IsPresent -and ((-not (Test-Path -Path $resourceModule)) -or $RegenerateSupportModule.IsPresent)) {
+ Write-Host -ForegroundColor Green "Building local Resource module used for test..."
+ Set-Location $resourceDir
+ $null = autorest .\README.md --use:@autorest/powershell@3.0.414 --output-folder=$HOME/.PSSharedModules/Resources
+ $null = Copy-Item custom/* $HOME/.PSSharedModules/Resources/custom/
+ Set-Location $HOME/.PSSharedModules/Resources
+ $null = .\build-module.ps1
+ Set-Location $PSScriptRoot
+}
diff --git a/src/Monitor/Metric.Autorest/create-model-cmdlets.ps1 b/src/Monitor/Metric.Autorest/create-model-cmdlets.ps1
new file mode 100644
index 000000000000..d4ed98cd9801
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/create-model-cmdlets.ps1
@@ -0,0 +1,262 @@
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+
+function CreateModelCmdlet {
+
+ param([Hashtable[]]$Models)
+
+ if ($Models.Count -eq 0)
+ {
+ return
+ }
+
+ $ModelCsPath = Join-Path (Join-Path $PSScriptRoot 'generated\api') 'Models'
+ $OutputDir = Join-Path $PSScriptRoot 'custom\autogen-model-cmdlets'
+ $null = New-Item -ItemType Directory -Force -Path $OutputDir
+ if ('Az.Monitor'.length -gt 0) {
+ $ModuleName = 'Az.Monitor'
+ } else {
+ $ModuleName = 'Az.Metric'
+ }
+ $CsFiles = Get-ChildItem -Path $ModelCsPath -Recurse -Filter *.cs
+ $Content = ''
+ $null = $CsFiles | ForEach-Object -Process { if ($_.Name.Split('.').count -eq 2 )
+ { $Content += get-content $_.fullname -raw
+ } }
+
+ $Tree = [Microsoft.CodeAnalysis.CSharp.SyntaxFactory]::ParseCompilationUnit($Content)
+ $Nodes = $Tree.ChildNodes().ChildNodes()
+ $classConstantMember = @{}
+ foreach ($Model in $Models)
+ {
+ $ModelName = $Model.modelName
+ $InterfaceNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq "I$ModelName") }
+ $ClassNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'class') -and ($_.Identifier.value -eq "$ModelName") }
+ $classConstantMember = @()
+ foreach ($class in $ClassNode) {
+ foreach ($member in $class.Members) {
+ $isConstant = $false
+ foreach ($attr in $member.AttributeLists) {
+ $memberName = $attr.Attributes.Name.ToString()
+ if ($memberName.EndsWith('.Constant')) {
+ $isConstant = $true
+ break
+ }
+ }
+ if (($member.Modifiers.ToString() -eq 'public') -and $isConstant) {
+ $classConstantMember += $member.Identifier.Value
+ }
+ }
+ }
+ if ($InterfaceNode.count -eq 0) {
+ continue
+ }
+ # through a queue, we iterate all the parent models.
+ $Queue = @($InterfaceNode)
+ $visited = @("I$ModelName")
+ $AllInterfaceNodes = @()
+ while ($Queue.count -ne 0)
+ {
+ $AllInterfaceNodes += $Queue[0]
+ # Baselist contains the direct parent models.
+ foreach ($parent in $Queue[0].BaseList.Types)
+ {
+ if (($parent.Type.Right.Identifier.Value -ne 'IJsonSerializable') -and (-not $visited.Contains($parent.Type.Right.Identifier.Value)))
+ {
+ $Queue = [Array]$Queue + ($Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq $parent.Type.Right.Identifier.Value) })
+ $visited = [Array]$visited + $parent.Type.Right.Identifier.Value
+ }
+ }
+ $first, $Queue = $Queue
+ }
+
+ $Namespace = $InterfaceNode.Parent.Name
+ $ObjectType = $ModelName
+ $ObjectTypeWithNamespace = "${Namespace}.${ObjectType}"
+ # remove duplicated module name
+ if ($ObjectType.StartsWith('Metric')) {
+ $ModulePrefix = ''
+ } else {
+ $ModulePrefix = 'Metric'
+ }
+ $OutputPath = Join-Path -ChildPath "New-Az${ModulePrefix}${ObjectType}Object.ps1" -Path $OutputDir
+
+ $ParameterDefineScriptList = New-Object System.Collections.Generic.List[string]
+ $ParameterAssignScriptList = New-Object System.Collections.Generic.List[string]
+ foreach ($Node in $AllInterfaceNodes)
+ {
+ foreach ($Member in $Node.Members)
+ {
+ if ($classConstantMember.Contains($Member.Identifier.Value)) {
+ # skip constant member
+ continue
+ }
+ $Arguments = $Member.AttributeLists.Attributes.ArgumentList.Arguments
+ $Required = $false
+ $Description = ""
+ $Readonly = $False
+ $mutability = @{Read = $true; Create = $true; Update = $true}
+ foreach ($Argument in $Arguments)
+ {
+ if ($Argument.NameEquals.Name.Identifier.Value -eq "Required")
+ {
+ $Required = $Argument.Expression.Token.Value
+ }
+ if ($Argument.NameEquals.Name.Identifier.Value -eq "Description")
+ {
+ $Description = $Argument.Expression.Token.Value.Trim('.').replace('"', '`"')
+ }
+ if ($Argument.NameEquals.Name.Identifier.Value -eq "Readonly")
+ {
+ $Readonly = $Argument.Expression.Token.Value
+ }
+ if ($Argument.NameEquals.Name.Identifier.Value -eq "Read")
+ {
+ $mutability.Read = $Argument.Expression.Token.Value
+ }
+ if ($Argument.NameEquals.Name.Identifier.Value -eq "Create")
+ {
+ $mutability.Create = $Argument.Expression.Token.Value
+ }
+ if ($Argument.NameEquals.Name.Identifier.Value -eq "Update")
+ {
+ $mutability.Update = $Argument.Expression.Token.Value
+ }
+ }
+ if ($Readonly)
+ {
+ continue
+ }
+ $Identifier = $Member.Identifier.Value
+ $Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
+ $Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
+ if ($Type.StartsWith("System.Collections.Generic.List"))
+ {
+ # if the type is a list, we need to convert it to array
+ $matched = $Type -match '\<(?.+)\>$'
+ if ($matched)
+ {
+ $Type = $matches.Name + '[]';
+ }
+ }
+ $ParameterDefinePropertyList = New-Object System.Collections.Generic.List[string]
+ if ($Required -and $mutability.Create -and $mutability.Update)
+ {
+ $ParameterDefinePropertyList.Add("Mandatory")
+ }
+ if ($Description -ne "")
+ {
+ $ParameterDefinePropertyList.Add("HelpMessage=`"${Description}.`"")
+ }
+ $ParameterDefineProperty = [System.String]::Join(", ", $ParameterDefinePropertyList)
+ # check whether completer is needed
+ $completer = '';
+ if(IsEnumType($Member)){
+ $completer += GetCompleter($Member)
+ }
+ $ParameterDefineScript = "
+ [Parameter($ParameterDefineProperty)]${completer}
+ [${Type}]
+ `$${Identifier}"
+ $ParameterDefineScriptList.Add($ParameterDefineScript)
+ $ParameterAssignScriptList.Add("
+ if (`$PSBoundParameters.ContainsKey('${Identifier}')) {
+ `$Object.${Identifier} = `$${Identifier}
+ }")
+ }
+ }
+ $ParameterDefineScript = $ParameterDefineScriptList | Join-String -Separator ","
+ $ParameterAssignScript = $ParameterAssignScriptList | Join-String -Separator ""
+
+ $cmdletName = "New-Az${ModulePrefix}${ObjectType}Object"
+ if ('' -ne $Model.cmdletName) {
+ $cmdletName = $Model.cmdletName
+ }
+ $OutputPath = Join-Path -ChildPath "${cmdletName}.ps1" -Path $OutputDir
+ $cmdletNameInLowerCase = $cmdletName.ToLower()
+ $Script = "
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+
+<#
+.Synopsis
+Create an in-memory object for ${ObjectType}.
+.Description
+Create an in-memory object for ${ObjectType}.
+
+.Outputs
+${ObjectTypeWithNamespace}
+.Link
+https://learn.microsoft.com/powershell/module/${ModuleName}/${cmdletNameInLowerCase}
+#>
+function ${cmdletName} {
+ [OutputType('${ObjectTypeWithNamespace}')]
+ [CmdletBinding(PositionalBinding=`$false)]
+ Param(
+${ParameterDefineScript}
+ )
+
+ process {
+ `$Object = [${ObjectTypeWithNamespace}]::New()
+${ParameterAssignScript}
+ return `$Object
+ }
+}
+"
+ Set-Content -Path $OutputPath -Value $Script
+ }
+}
+
+function IsEnumType {
+ param (
+ [Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax]$property
+ )
+ $isEnum = $false
+ foreach ($attr in $property.AttributeLists) {
+ $attributeName = $attr.Attributes.Name.ToString()
+ if ($attributeName.Contains('ArgumentCompleter')) {
+ $isEnum = $true
+ break
+ }
+ }
+ return $isEnum;
+}
+
+function GetCompleter {
+ param (
+ [Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax]$property
+ )
+ foreach ($attr in $property.AttributeLists) {
+ $attributeName = $attr.Attributes.Name.ToString()
+ if ($attributeName.Contains('ArgumentCompleter')) {
+ $attributeName = $attributeName.Split("::")[-1]
+ $possibleValues = [System.String]::Join(", ", $attr.Attributes.ArgumentList.Arguments)
+ $completer += "`n [${attributeName}(${possibleValues})]"
+ return $completer
+ }
+ }
+}
diff --git a/src/Monitor/Metric.Autorest/custom/Az.Metric.custom.psm1 b/src/Monitor/Metric.Autorest/custom/Az.Metric.custom.psm1
new file mode 100644
index 000000000000..2642e95e5238
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/custom/Az.Metric.custom.psm1
@@ -0,0 +1,17 @@
+# region Generated
+ # Load the private module dll
+ $null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '..\bin\Az.Metric.private.dll')
+
+ # Load the internal module
+ $internalModulePath = Join-Path $PSScriptRoot '..\internal\Az.Metric.internal.psm1'
+ if(Test-Path $internalModulePath) {
+ $null = Import-Module -Name $internalModulePath
+ }
+
+ # Export nothing to clear implicit exports
+ Export-ModuleMember
+
+ # Export script cmdlets
+ Get-ChildItem -Path $PSScriptRoot -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
+ Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot) -Alias (Get-ScriptCmdlet -ScriptFolder $PSScriptRoot -AsAlias)
+# endregion
diff --git a/src/Monitor/Metric.Autorest/custom/Get-AzMetric.ps1 b/src/Monitor/Metric.Autorest/custom/Get-AzMetric.ps1
new file mode 100644
index 000000000000..eac15cee12cf
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/custom/Get-AzMetric.ps1
@@ -0,0 +1,274 @@
+
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+
+<#
+.Synopsis
+**Lists the metric values for a resource**.
+.Description
+**Lists the metric values for a resource**.
+.Example
+Get-AzMetric -Region eastus -Aggregation count -AutoAdjustTimegrain -Filter "LUN eq '0' and Microsoft.ResourceId eq '*'" -Interval "PT6H" -MetricName "Data Disk Max Burst IOPS" -MetricNamespace "microsoft.compute/virtualmachines" -Orderby "count desc" -Rollupby "LUN" -Timespan "2023-12-08T19:00:00Z/2023-12-12T01:00:00Z" -Top 10
+.Example
+Get-AzMetric -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Storage/storageAccounts/storagetasktest202402281/blobServices/default -Aggregation "average,minimum,maximum" -AutoAdjustTimegrain -Filter "Tier eq '*'" -Interval "PT6H" -MetricName "BlobCount,BlobCapacity" -MetricNamespace "Microsoft.Storage/storageAccounts/blobServices" -Orderby "average asc" -Timespan "2024-03-10T09:00:00Z/2024-03-10T14:00:00Z" -Top 1
+
+.Outputs
+Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse
+.Link
+https://learn.microsoft.com/powershell/module/az.monitor/get-azmetric
+#>
+function Get-AzMetric {
+[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse])]
+[CmdletBinding(DefaultParameterSetName='List2', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
+param(
+ [Parameter(ParameterSetName='List2', Mandatory)]
+ [Alias('ResourceId')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [System.String]
+ # The identifier of the resource.
+ ${ResourceUri},
+
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Parameter(ParameterSetName='ListViaJsonFilePath')]
+ [Parameter(ParameterSetName='ListViaJsonString')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
+ [System.String[]]
+ # The ID of the target subscription.
+ ${SubscriptionId},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Alias('AggregationType')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The list of aggregation types (comma separated) to retrieve.
+ # *Examples: average, minimum, maximum*
+ ${Aggregation},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.Management.Automation.SwitchParameter]
+ # When set to true, if the timespan passed in is not supported by this metric, the API will return the result using the closest supported timespan.
+ # When set to false, an error is returned for invalid timespan parameters.
+ # Defaults to false.
+ ${AutoAdjustTimegrain},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Alias('MetricFilter')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The **$filter** is used to reduce the set of metric data returned.
+ # Example:
+ # Metric contains metadata A, B and C.
+ # - Return all time series of C where A = a1 and B = b1 or b2
+ # **$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
+ # - Invalid variant:
+ # **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
+ # This is invalid because the logical or operator cannot separate two different metadata names.
+ # - Return all time series where A = a1, B = b1 and C = c1:
+ # **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
+ # - Return all time series where A = a1
+ # **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ ${Filter},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Alias('TimeGrain')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.DefaultInfo(Script = 'PT1M')]
+ [System.String]
+ # The interval (i.e.
+ # timegrain) of the query in ISO 8601 duration format.
+ # Defaults to PT1M.
+ # Special case for 'FULL' value that returns single datapoint for entire time span requested.
+ # *Examples: PT15M, PT1H, P1D, FULL*
+ ${Interval},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The names of the metrics (comma separated) to retrieve.
+ ${MetricName},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Metric namespace where the metrics you want reside.
+ ${MetricNamespace},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The aggregation to use for sorting results and the direction of the sort.
+ # Only one order can be specified.
+ # *Examples: sum asc*
+ ${OrderBy},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("Data", "Metadata")]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Reduces the set of data collected.
+ # The syntax allowed depends on the operation.
+ # See the operation's description for details.
+ ${ResultType},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Dimension name(s) to rollup results by.
+ # For example if you only want to see metric values with a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ ${RollUpBy},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.DateTime]
+ # Specifies the start time of the query in local time.
+ # The default is the current local time minus one hour.
+ ${StartTime},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ # [Microsoft.Azure.PowerShell.Cmdlets.SqlVirtualMachine.Runtime.DefaultInfo(Script = 'DateTime.UtcNow')]
+ [System.DateTime]
+ # Specifies the end time of the query in local time.
+ # The default is the current time.
+ ${EndTime},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.Int32]
+ # The maximum number of records to retrieve per resource ID in the request.
+ # Valid only if filter is specified.
+ # Defaults to 10.
+ ${Top},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.Management.Automation.SwitchParameter]
+ # When set to false, invalid filter parameter values will be ignored.
+ # When set to true, an error is returned for invalid filter parameters.
+ # Defaults to true.
+ ${ValidateDimension},
+
+ [Parameter(ParameterSetName='ListExpanded', Mandatory)]
+ [Parameter(ParameterSetName='ListViaJsonFilePath', Mandatory)]
+ [Parameter(ParameterSetName='ListViaJsonString', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The region where the metrics you want reside.
+ ${Region},
+
+ [Parameter(ParameterSetName='ListViaJsonFilePath', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # Path of Json file supplied to the List operation
+ ${JsonFilePath},
+
+ [Parameter(ParameterSetName='ListViaJsonString', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # Json string supplied to the List operation
+ ${JsonString},
+
+ [Parameter()]
+ [Alias('AzureRMContext', 'AzureCredential')]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Azure')]
+ [System.Management.Automation.PSObject]
+ # The DefaultProfile parameter is not functional.
+ # Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
+ ${DefaultProfile},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Wait for .NET debugger to attach
+ ${Break},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be appended to the front of the pipeline
+ ${HttpPipelineAppend},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be prepended to the front of the pipeline
+ ${HttpPipelinePrepend},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Uri]
+ # The URI for the proxy server to use
+ ${Proxy},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.PSCredential]
+ # Credentials for a proxy server to use for the remote call
+ ${ProxyCredential},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Use the default credentials for the proxy
+ ${ProxyUseDefaultCredentials}
+)
+
+process {
+ # EndTime defaults to Now
+ if ($PSBoundParameters.ContainsKey("EndTime")) {
+ $EndTimeString = $EndTime.ToUniversalTime().ToString("O")
+ $defaultStartTime = $EndTime.ToUniversalTime().AddHours(-1)
+ } else {
+ # default value of end time on server
+ $EndTimeString = [DateTime]::UtcNow.ToString("O")
+ $defaultStartTime = [DateTime]::UtcNow.AddHours(-1)
+ }
+ # StartTime defaults to EndTime - DefaultTimeRange (NOTE: EndTime defaults to Now)
+ if ($PSBoundParameters.ContainsKey("StartTime")) {
+ $StartTimeString = $StartTime.ToUniversalTime().ToString("O")
+ }
+ else {
+ # default value of start time on server
+ $StartTimeString = $defaultStartTime.ToString("O")
+ }
+ $null = $PSBoundParameters.Remove("StartTime")
+ $null = $PSBoundParameters.Remove("EndTime")
+ # The timespan of the query.
+ # It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ $Timespan = $StartTimeString+'/'+$EndTimeString
+ $null = $PSBoundParameters.Add("Timespan", $Timespan)
+
+ Az.Metric.internal\Get-AzMetric @PSBoundParameters
+}
+}
diff --git a/src/Monitor/Metric.Autorest/custom/New-AzMetricFilter.ps1 b/src/Monitor/Metric.Autorest/custom/New-AzMetricFilter.ps1
new file mode 100644
index 000000000000..f354e518d383
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/custom/New-AzMetricFilter.ps1
@@ -0,0 +1,73 @@
+
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+
+<#
+.Synopsis
+Creates a metric dimension filter that can be used to query metrics.
+.Description
+Creates a metric dimension filter that can be used to query metrics.
+.Example
+New-AzMetricFilter -Dimension City -Operator eq -Value "Seattle","New York"
+
+.Outputs
+System.String
+.Link
+https://learn.microsoft.com/powershell/module/az.monitor/new-azmetricfilter
+#>
+function New-AzMetricFilter {
+[OutputType('System.String')]
+[CmdletBinding(PositionalBinding=$false)]
+Param(
+ #
+ # Gets or sets the Dimension
+ #
+ [Parameter(HelpMessage="The dimension name")]
+ [string]
+ ${Dimension},
+
+ #
+ # Gets or sets the Operator
+ #
+ [Parameter(HelpMessage="The operator")]
+ [string]
+ ${Operator},
+
+ #
+ # Gets or sets the values list of the dimension. A comma-separated list of values for the dimension.
+ #
+ [Parameter(HelpMessage="The list of values for the dimension")]
+ [string[]]
+ ${Value}
+ )
+
+ # Process the general parameters (i.e. defined in this class) and the particular parameters (i.e. the parameters added by the descendants of this class).
+ process {
+ $buffer = [System.Text.StringBuilder]::new()
+ $metricFilter = ''
+ for ($index = 0; $index -lt $Value.count; )
+ {
+ $string = "'"+ $Value[$index] + "'"
+ $metricFilter += $Dimension +' '+$Operator+' '+$string
+ $index++
+ if ($index -lt $Value.Count) {
+ $metricFilter += ' or '
+ }
+ }
+ [void]$buffer.Append($metricFilter)
+
+ return $buffer.ToString().Trim()
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/custom/README.md b/src/Monitor/Metric.Autorest/custom/README.md
new file mode 100644
index 000000000000..6cefe17280c0
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/custom/README.md
@@ -0,0 +1,41 @@
+# Custom
+This directory contains custom implementation for non-generated cmdlets for the `Az.Metric` 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.Metric.custom.psm1`. This file should not be modified.
+
+## Info
+- Modifiable: yes
+- Generated: partial
+- Committed: yes
+- Packaged: yes
+
+## Details
+For `Az.Metric` to use custom cmdlets, it does this two different ways. We **highly recommend** creating script cmdlets, as they are easier to write and allow access to the other exported cmdlets. C# cmdlets *cannot access exported cmdlets*.
+
+For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Az.Metric.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.
+
+For script cmdlets, these are loaded via the `Az.Metric.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.
+
+## Purpose
+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.
+
+## Usage
+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:
+- Break
+- DefaultProfile
+- HttpPipelineAppend
+- HttpPipelinePrepend
+- Proxy
+- ProxyCredential
+- ProxyUseDefaultCredentials
+
+These provide functionality to our HTTP pipeline and other useful features. In script, you can forward these parameters using `$PSBoundParameters` to the other cmdlets you're calling within `Az.Metric`. For C#, follow the usage seen in the `ProcessRecordAsync` method.
+
+### Attributes
+For processing the cmdlets, we've created some additional attributes:
+- `Microsoft.Azure.PowerShell.Cmdlets.Metric.DescriptionAttribute`
+ - 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.
+- `Microsoft.Azure.PowerShell.Cmdlets.Metric.DoNotExportAttribute`
+ - Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.Metric`.
+- `Microsoft.Azure.PowerShell.Cmdlets.Metric.InternalExportAttribute`
+ - Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.Metric`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder.
+- `Microsoft.Azure.PowerShell.Cmdlets.Metric.ProfileAttribute`
+ - Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/examples/Get-AzMetric.md b/src/Monitor/Metric.Autorest/examples/Get-AzMetric.md
new file mode 100644
index 000000000000..63371446feaa
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/examples/Get-AzMetric.md
@@ -0,0 +1,155 @@
+### Example 1: List the metric data for a subscription
+```powershell
+Get-AzMetric -Region eastus -Aggregation count -AutoAdjustTimegrain -Filter "LUN eq '0' and Microsoft.ResourceId eq '*'" -Interval "PT6H" -MetricName "Data Disk Max Burst IOPS" -MetricNamespace "microsoft.compute/virtualmachines" -Orderby "count desc" -Rollupby "LUN" -StartTime "2023-12-08T19:00:00Z" -EndTime "2023-12-12T01:00:00Z" -Top 10
+```
+
+```output
+Cost : 2375
+Interval : PT6H
+Namespace : microsoft.compute/virtualmachines
+Resourceregion : eastus
+Timespan : 2023-12-10T09:23:01Z/2023-12-12T01:00:00Z
+Value : {{
+ "name": {
+ "value": "Data Disk Max Burst IOPS",
+ "localizedValue": "Data Disk Max Burst IOPS"
+ },
+ "id": "subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/providers/Microsoft.Insights/metrics/Data Disk Max Burst IOPS",
+ "type": "Microsoft.Insights/metrics",
+ "displayDescription": "Maximum IOPS Data Disk can achieve with bursting",
+ "errorCode": "Success",
+ "unit": "Count",
+ "timeseries": [ ]
+ }}
+```
+
+This command lists the metric data for a subscription.
+
+### Example 2: List the metric values for a specified resource URI
+```powershell
+Get-AzMetric -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Storage/storageAccounts/storagetasktest202402281/blobServices/default -Aggregation "average,minimum,maximum" -AutoAdjustTimegrain -Filter "Tier eq '*'" -Interval "PT6H" -MetricName "BlobCount,BlobCapacity" -MetricNamespace "Microsoft.Storage/storageAccounts/blobServices" -Orderby "average asc" -StartTime "2024-03-10T09:00:00Z" -EndTime "2024-03-10T14:00:00Z" -Top 1
+```
+
+```output
+Cost : 598
+Interval : PT1H
+Namespace : Microsoft.Storage/storageAccounts/blobServices
+Resourceregion : eastus2euap
+Timespan : 2024-03-10T09:00:00Z/2024-03-10T14:00:00Z
+Value : {{
+ "name": {
+ "value": "BlobCount",
+ "localizedValue": "Blob Count"
+ },
+ "id": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Storage/storageAccounts/storagetasktest202402281/blobServices/de
+ fault/providers/Microsoft.Insights/metrics/BlobCount",
+ "type": "Microsoft.Insights/metrics",
+ "displayDescription": "The number of blob objects stored in the storage account.",
+ "errorCode": "Success",
+ "unit": "Count",
+ "timeseries": [
+ {
+ "metadatavalues": [
+ {
+ "name": {
+ "value": "tier",
+ "localizedValue": "tier"
+ },
+ "value": "Standard"
+ }
+ ],
+ "data": [
+ {
+ "timeStamp": "2024-03-10T09:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ },
+ {
+ "timeStamp": "2024-03-10T10:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ },
+ {
+ "timeStamp": "2024-03-10T11:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ },
+ {
+ "timeStamp": "2024-03-10T12:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ },
+ {
+ "timeStamp": "2024-03-10T13:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ }
+ ]
+ }
+ ]
+ }, {
+ "name": {
+ "value": "BlobCapacity",
+ "localizedValue": "Blob Capacity"
+ },
+ "id": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Storage/storageAccounts/storagetasktest202402281/blobServices/de
+ fault/providers/Microsoft.Insights/metrics/BlobCapacity",
+ "type": "Microsoft.Insights/metrics",
+ "displayDescription": "The amount of storage used by the storage account\u0027s Blob service in bytes.",
+ "errorCode": "Success",
+ "unit": "Bytes",
+ "timeseries": [
+ {
+ "metadatavalues": [
+ {
+ "name": {
+ "value": "tier",
+ "localizedValue": "tier"
+ },
+ "value": "Premium"
+ }
+ ],
+ "data": [
+ {
+ "timeStamp": "2024-03-10T09:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ },
+ {
+ "timeStamp": "2024-03-10T10:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ },
+ {
+ "timeStamp": "2024-03-10T11:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ },
+ {
+ "timeStamp": "2024-03-10T12:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ },
+ {
+ "timeStamp": "2024-03-10T13:00:00.0000000Z",
+ "average": 0,
+ "minimum": 0,
+ "maximum": 0
+ }
+ ]
+ }
+ ]
+ }}
+```
+
+This command lists the metric values for a specified resource URI.
+
diff --git a/src/Monitor/Metric.Autorest/examples/Get-AzMetricDefinition.md b/src/Monitor/Metric.Autorest/examples/Get-AzMetricDefinition.md
new file mode 100644
index 000000000000..d6037799f6b5
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/examples/Get-AzMetricDefinition.md
@@ -0,0 +1,166 @@
+### Example 1: Get Metric definitions for a web site resource
+```powershell
+Get-AzMetricDefinition -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/Default-Web-EastUS/providers/Microsoft.Web/sites/website
+```
+
+```output
+Category DisplayDescription
+-------- ------------------
+ The amount of CPU consumed by the app, in seconds. For more information about this metric. Please see https://aka.ms/website-monitor-cpu-time-vs-cpu-percentage (CPU time vs CPU p…
+ The total number of requests regardless of their resulting HTTP status code. For WebApps and FunctionApps.
+ The amount of incoming bandwidth consumed by the app, in MiB. For WebApps and FunctionApps.
+ The amount of outgoing bandwidth consumed by the app, in MiB. For WebApps and FunctionApps.
+ The count of requests resulting in an HTTP status code 101. For WebApps and FunctionApps.
+ The count of requests resulting in an HTTP status code >= 200 but < 300. For WebApps and FunctionApps.
+ The count of requests resulting in an HTTP status code >= 300 but < 400. For WebApps and FunctionApps.
+ The count of requests resulting in HTTP 401 status code. For WebApps and FunctionApps.
+ The count of requests resulting in HTTP 403 status code. For WebApps and FunctionApps.
+ The count of requests resulting in HTTP 404 status code. For WebApps and FunctionApps.
+ The count of requests resulting in HTTP 406 status code. For WebApps and FunctionApps.
+ The count of requests resulting in an HTTP status code >= 400 but < 500. For WebApps and FunctionApps.
+ The count of requests resulting in an HTTP status code >= 500 but < 600. For WebApps and FunctionApps.
+ The current amount of memory used by the app, in MiB. For WebApps and FunctionApps.
+ The average amount of memory used by the app, in megabytes (MiB). For WebApps and FunctionApps.
+ The average time taken for the app to serve requests, in seconds. For WebApps and FunctionApps.
+ The time taken for the app to serve requests, in seconds. For WebApps and FunctionApps.
+ The number of bound sockets existing in the sandbox (w3wp.exe and its child processes). A bound socket is created by calling bind()/connect() APIs and remains until said socket i…
+ The total number of handles currently open by the app process. For WebApps and FunctionApps.
+ The number of threads currently active in the app process. For WebApps and FunctionApps.
+ Private Bytes is the current size, in bytes, of memory that the app process has allocated that can't be shared with other processes. For WebApps and FunctionApps.
+ The rate at which the app process is reading bytes from I/O operations. For WebApps and FunctionApps.
+ The rate at which the app process is writing bytes to I/O operations. For WebApps and FunctionApps.
+ The rate at which the app process is issuing bytes to I/O operations that don't involve data, such as control operations. For WebApps and FunctionApps.
+ The rate at which the app process is issuing read I/O operations. For WebApps and FunctionApps.
+ The rate at which the app process is issuing write I/O operations. For WebApps and FunctionApps.
+ The rate at which the app process is issuing I/O operations that aren't read or write operations. For WebApps and FunctionApps.
+ The number of requests in the application request queue. For WebApps and FunctionApps.
+ The current number of Assemblies loaded across all AppDomains in this application. For WebApps and FunctionApps.
+ The current number of AppDomains loaded in this application. For WebApps and FunctionApps.
+ The total number of AppDomains unloaded since the start of the application. For WebApps and FunctionApps.
+ The number of times the generation 0 objects are garbage collected since the start of the app process. Higher generation GCs include all lower generation GCs. For WebApps and Fun…
+ The number of times the generation 1 objects are garbage collected since the start of the app process. Higher generation GCs include all lower generation GCs. For WebApps and Fun…
+ The number of times the generation 2 objects are garbage collected since the start of the app process. For WebApps and FunctionApps.
+ Health check status. For WebApps and FunctionApps.
+ Percentage of filesystem quota consumed by the app. For WebApps and FunctionApps.
+```
+
+This command gets the metric definitions for the specified resource.
+
+### Example 2: List the metric definitions for a web site resource URI
+```powershell
+Get-AzMetricDefinition -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/Default-Web-EastUS/providers/Microsoft.Web/sites/website | Format-List
+```
+
+```output
+Category :
+Dimension : {{
+ "value": "Instance",
+ "localizedValue": "Instance"
+ }}
+DisplayDescription : The amount of CPU consumed by the app, in seconds. For more information about this metric. Please see https://aka.ms/website-monitor-cpu-time-vs-cpu-percentage(CPU time vs CPU percentage). For WebApps only.
+Id : /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Web/sites/joyerfirstweb/providers/microsoft.insights/metricdefinitions/CpuTime
+IsDimensionRequired : False
+MetricAvailability : {{
+ "timeGrain": "PT1M",
+ "retention": "P93D"
+ }, {
+ "timeGrain": "PT5M",
+ "retention": "P93D"
+ }, {
+ "timeGrain": "PT15M",
+ "retention": "P93D"
+ }, {
+ "timeGrain": "PT30M",
+ "retention": "P93D"
+ }…}
+MetricClass :
+NameLocalizedValue : CPU Time
+NameValue : CpuTime
+Namespace : Microsoft.Web/sites
+PrimaryAggregationType : Total
+ResourceId : /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Web/sites/joyerfirstweb
+SupportedAggregationType : {Count, Total, Minimum, Maximum}
+Unit : Seconds
+
+Category :
+Dimension : {{
+ "value": "Instance",
+ "localizedValue": "Instance"
+ }}
+DisplayDescription : The total number of requests regardless of their resulting HTTP status code. For WebApps and FunctionApps.
+Id : /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Web/sites/joyerfirstweb/providers/microsoft.insights/metricdefinitions/Requests
+IsDimensionRequired : False
+MetricAvailability : {{
+ "timeGrain": "PT1M",
+ "retention": "P93D"
+ }, {
+ "timeGrain": "PT5M",
+ "retention": "P93D"
+ }, {
+ "timeGrain": "PT15M",
+ "retention": "P93D"
+ }, {
+ "timeGrain": "PT30M",
+ "retention": "P93D"
+ }…}
+MetricClass :
+NameLocalizedValue : Requests
+NameValue : Requests
+Namespace : Microsoft.Web/sites
+PrimaryAggregationType : Total
+ResourceId : /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Web/sites/joyerfirstweb
+SupportedAggregationType : {None, Average, Minimum, Maximum…}
+Unit : Count
+
+Category :
+Dimension : {{
+ "value": "Instance",
+ "localizedValue": "Instance"
+ }}
+DisplayDescription : The amount of incoming bandwidth consumed by the app, in MiB. For WebApps and FunctionApps.
+Id : /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Web/sites/joyerfirstweb/providers/microsoft.insights/metricdefinitions/BytesReceived
+IsDimensionRequired : False
+MetricAvailability : {{
+ "timeGrain": "PT1M",
+ "retention": "P93D"
+ }, {
+ "timeGrain": "PT5M",
+ "retention": "P93D"
+ }, {
+ "timeGrain": "PT15M",
+ "retention": "P93D"
+ }, {
+ "timeGrain": "PT30M",
+ "retention": "P93D"
+ }…}
+MetricClass :
+NameLocalizedValue : Data In
+NameValue : BytesReceived
+Namespace : Microsoft.Web/sites
+PrimaryAggregationType : Total
+ResourceId : /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Web/sites/joyerfirstweb
+SupportedAggregationType : {None, Average, Minimum, Maximum…}
+Unit : Bytes
+```
+
+This command lists the metric definitions for website and the output is detailed.
+
+### Example 3: List the metric definitions with region
+```powershell
+Get-AzMetricDefinition -Region eastus2euap -MetricNamespace "Microsoft.Storage/storageAccounts"
+```
+
+```output
+Category DisplayDescription
+-------- ------------------
+Capacity The amount of storage used by the storage account. For standard storage accounts, it's the sum of capacity used by blob, table, file, and queue. For premium storage accounts a…
+Transaction The number of requests made to a storage service or the specified API operation. This number includes successful and failed requests, as well as requests which produced errors…
+Transaction The amount of ingress data, in bytes. This number includes ingress from an external client into Azure Storage as well as ingress within Azure.
+Transaction The amount of egress data. This number includes egress to external client from Azure Storage as well as egress within Azure. As a result, this number does not reflect billable…
+Transaction The average time used to process a successful request by Azure Storage. This value does not include the network latency specified in SuccessE2ELatency.
+Transaction The average end-to-end latency of successful requests made to a storage service or the specified API operation, in milliseconds. This value includes the required processing ti…
+Transaction The percentage of availability for the storage service or the specified API operation. Availability is calculated by taking the TotalBillableRequests value and dividing it by …
+```
+
+This command lists metric dimension from region for the subscription.
+
diff --git a/src/Monitor/Metric.Autorest/examples/New-AzMetricFilter.md b/src/Monitor/Metric.Autorest/examples/New-AzMetricFilter.md
new file mode 100644
index 000000000000..40b7d6922157
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/examples/New-AzMetricFilter.md
@@ -0,0 +1,11 @@
+### Example 1: Create a metric dimension filter
+```powershell
+New-AzMetricFilter -Dimension City -Operator eq -Value "Seattle","New York"
+```
+
+```output
+City eq 'Seattle' or City eq 'New York'
+```
+
+This command creates metric dimension filter of the format "City eq 'Seattle' or City eq 'New York'".
+
diff --git a/src/Monitor/Metric.Autorest/export-surface.ps1 b/src/Monitor/Metric.Autorest/export-surface.ps1
new file mode 100644
index 000000000000..0cf4a618a79c
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/export-surface.ps1
@@ -0,0 +1,41 @@
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+param([switch]$NotIsolated, [switch]$IncludeGeneralParameters, [switch]$UseExpandedFormat)
+$ErrorActionPreference = 'Stop'
+
+$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
+if(-not $NotIsolated) {
+ Write-Host -ForegroundColor Green 'Creating isolated process...'
+ & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -NotIsolated
+ return
+}
+
+$dll = Join-Path $PSScriptRoot 'bin\Az.Metric.private.dll'
+if(-not (Test-Path $dll)) {
+ Write-Error "Unable to find output assembly in '$binFolder'."
+}
+$null = Import-Module -Name $dll
+
+$moduleName = 'Az.Metric'
+$exportsFolder = Join-Path $PSScriptRoot 'exports'
+$resourcesFolder = Join-Path $PSScriptRoot 'resources'
+
+Export-CmdletSurface -ModuleName $moduleName -CmdletFolder $exportsFolder -OutputFolder $resourcesFolder -IncludeGeneralParameters $IncludeGeneralParameters.IsPresent -UseExpandedFormat $UseExpandedFormat.IsPresent
+Write-Host -ForegroundColor Green "CmdletSurface file(s) created in '$resourcesFolder'"
+
+Export-ModelSurface -OutputFolder $resourcesFolder -UseExpandedFormat $UseExpandedFormat.IsPresent
+Write-Host -ForegroundColor Green "ModelSurface file created in '$resourcesFolder'"
+
+Write-Host -ForegroundColor Green '-------------Done-------------'
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/exports/Get-AzMetric.ps1 b/src/Monitor/Metric.Autorest/exports/Get-AzMetric.ps1
new file mode 100644
index 000000000000..df2f5975e207
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/exports/Get-AzMetric.ps1
@@ -0,0 +1,338 @@
+
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+
+<#
+.Synopsis
+**Lists the metric values for a resource**.
+.Description
+**Lists the metric values for a resource**.
+.Example
+Get-AzMetric -Region eastus -Aggregation count -AutoAdjustTimegrain -Filter "LUN eq '0' and Microsoft.ResourceId eq '*'" -Interval "PT6H" -MetricName "Data Disk Max Burst IOPS" -MetricNamespace "microsoft.compute/virtualmachines" -Orderby "count desc" -Rollupby "LUN" -StartTime "2023-12-08T19:00:00Z" -EndTime "2023-12-12T01:00:00Z" -Top 10
+.Example
+Get-AzMetric -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Storage/storageAccounts/storagetasktest202402281/blobServices/default -Aggregation "average,minimum,maximum" -AutoAdjustTimegrain -Filter "Tier eq '*'" -Interval "PT6H" -MetricName "BlobCount,BlobCapacity" -MetricNamespace "Microsoft.Storage/storageAccounts/blobServices" -Orderby "average asc" -StartTime "2024-03-10T09:00:00Z" -EndTime "2024-03-10T14:00:00Z" -Top 1
+
+.Outputs
+Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse
+.Link
+https://learn.microsoft.com/powershell/module/az.monitor/get-azmetric
+#>
+function Get-AzMetric {
+[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse])]
+[CmdletBinding(DefaultParameterSetName='List2', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
+param(
+ [Parameter(ParameterSetName='List2', Mandatory)]
+ [Alias('ResourceId')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [System.String]
+ # The identifier of the resource.
+ ${ResourceUri},
+
+ [Parameter(ParameterSetName='ListViaJsonString')]
+ [Parameter(ParameterSetName='ListViaJsonFilePath')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
+ [System.String[]]
+ # The ID of the target subscription.
+ ${SubscriptionId},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Alias('AggregationType')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The list of aggregation types (comma separated) to retrieve.
+ # *Examples: average, minimum, maximum*
+ ${Aggregation},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.Management.Automation.SwitchParameter]
+ # When set to true, if the timespan passed in is not supported by this metric, the API will return the result using the closest supported timespan.
+ # When set to false, an error is returned for invalid timespan parameters.
+ # Defaults to false.
+ ${AutoAdjustTimegrain},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Alias('MetricFilter')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The **$filter** is used to reduce the set of metric data returned.
+ # Example:
+ # Metric contains metadata A, B and C.
+ # - Return all time series of C where A = a1 and B = b1 or b2
+ # **$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
+ # - Invalid variant:
+ # **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
+ # This is invalid because the logical or operator cannot separate two different metadata names.
+ # - Return all time series where A = a1, B = b1 and C = c1:
+ # **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
+ # - Return all time series where A = a1
+ # **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ ${Filter},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Alias('TimeGrain')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.DefaultInfo(Script='PT1M')]
+ [System.String]
+ # The interval (i.e.
+ # timegrain) of the query in ISO 8601 duration format.
+ # Defaults to PT1M.
+ # Special case for 'FULL' value that returns single datapoint for entire time span requested.
+ # *Examples: PT15M, PT1H, P1D, FULL*
+ ${Interval},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The names of the metrics (comma separated) to retrieve.
+ ${MetricName},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Metric namespace where the metrics you want reside.
+ ${MetricNamespace},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The aggregation to use for sorting results and the direction of the sort.
+ # Only one order can be specified.
+ # *Examples: sum asc*
+ ${OrderBy},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("Data", "Metadata")]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Reduces the set of data collected.
+ # The syntax allowed depends on the operation.
+ # See the operation's description for details.
+ ${ResultType},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Dimension name(s) to rollup results by.
+ # For example if you only want to see metric values with a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ ${RollUpBy},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.DateTime]
+ # Specifies the start time of the query in local time.
+ # The default is the current local time minus one hour.
+ ${StartTime},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.DateTime]
+ # [Microsoft.Azure.PowerShell.Cmdlets.SqlVirtualMachine.Runtime.DefaultInfo(Script = 'DateTime.UtcNow')]
+ # Specifies the end time of the query in local time.
+ # The default is the current time.
+ ${EndTime},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.Int32]
+ # The maximum number of records to retrieve per resource ID in the request.
+ # Valid only if filter is specified.
+ # Defaults to 10.
+ ${Top},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.Management.Automation.SwitchParameter]
+ # When set to false, invalid filter parameter values will be ignored.
+ # When set to true, an error is returned for invalid filter parameters.
+ # Defaults to true.
+ ${ValidateDimension},
+
+ [Parameter(ParameterSetName='ListViaJsonString', Mandatory)]
+ [Parameter(ParameterSetName='ListViaJsonFilePath', Mandatory)]
+ [Parameter(ParameterSetName='ListExpanded', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The region where the metrics you want reside.
+ ${Region},
+
+ [Parameter(ParameterSetName='ListViaJsonString', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # Json string supplied to the List operation
+ ${JsonString},
+
+ [Parameter(ParameterSetName='ListViaJsonFilePath', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # Path of Json file supplied to the List operation
+ ${JsonFilePath},
+
+ [Parameter()]
+ [Alias('AzureRMContext', 'AzureCredential')]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Azure')]
+ [System.Management.Automation.PSObject]
+ # The DefaultProfile parameter is not functional.
+ # Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
+ ${DefaultProfile},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Wait for .NET debugger to attach
+ ${Break},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be appended to the front of the pipeline
+ ${HttpPipelineAppend},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be prepended to the front of the pipeline
+ ${HttpPipelinePrepend},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Uri]
+ # The URI for the proxy server to use
+ ${Proxy},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.PSCredential]
+ # Credentials for a proxy server to use for the remote call
+ ${ProxyCredential},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Use the default credentials for the proxy
+ ${ProxyUseDefaultCredentials}
+)
+
+begin {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+ $parameterSet = $PSCmdlet.ParameterSetName
+
+ if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) {
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString()
+ }
+ $preTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ if ($preTelemetryId -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId =(New-Guid).ToString()
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Create', $MyInvocation, $parameterSet, $PSCmdlet)
+ } else {
+ $internalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ if ($internalCalledCmdlets -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $MyInvocation.MyCommand.Name
+ } else {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets += ',' + $MyInvocation.MyCommand.Name
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = 'internal'
+ }
+
+ $mapping = @{
+ List2 = 'Az.Metric.custom\Get-AzMetric';
+ ListViaJsonString = 'Az.Metric.custom\Get-AzMetric';
+ ListViaJsonFilePath = 'Az.Metric.custom\Get-AzMetric';
+ ListExpanded = 'Az.Metric.custom\Get-AzMetric';
+ }
+ if (('ListViaJsonString', 'ListViaJsonFilePath', 'ListExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
+ $testPlayback = $false
+ $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } }
+ if ($testPlayback) {
+ $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
+ } else {
+ $PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
+ }
+ }
+ if (('List2', 'ListExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('Interval') ) {
+ $PSBoundParameters['Interval'] = PT1M
+ }
+ $cmdInfo = Get-Command -Name $mapping[$parameterSet]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name)
+ }
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters}
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+
+process {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+
+ finally {
+ $backupTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ $backupInternalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+
+}
+end {
+ try {
+ $steppablePipeline.End()
+
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $backupTelemetryId
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $backupInternalCalledCmdlets
+ if ($preTelemetryId -eq '') {
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Send', $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $preTelemetryId
+
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+}
diff --git a/src/Monitor/Metric.Autorest/exports/Get-AzMetricDefinition.ps1 b/src/Monitor/Metric.Autorest/exports/Get-AzMetricDefinition.ps1
new file mode 100644
index 000000000000..5e7d4717f2b5
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/exports/Get-AzMetricDefinition.ps1
@@ -0,0 +1,201 @@
+
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+
+<#
+.Synopsis
+Lists the metric definitions for the subscription.
+.Description
+Lists the metric definitions for the subscription.
+.Example
+Get-AzMetricDefinition -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/Default-Web-EastUS/providers/Microsoft.Web/sites/website
+.Example
+Get-AzMetricDefinition -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/Default-Web-EastUS/providers/Microsoft.Web/sites/website | Format-List
+.Example
+Get-AzMetricDefinition -Region eastus2euap -MetricNamespace "Microsoft.Storage/storageAccounts"
+
+.Outputs
+Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition
+.Outputs
+Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinition
+.Link
+https://learn.microsoft.com/powershell/module/az.monitor/get-azmetricdefinition
+#>
+function Get-AzMetricDefinition {
+[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinition], [Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition])]
+[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
+param(
+ [Parameter(ParameterSetName='List')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
+ [System.String[]]
+ # The ID of the target subscription.
+ ${SubscriptionId},
+
+ [Parameter(ParameterSetName='List1', Mandatory)]
+ [Alias('ResourceId')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [System.String]
+ # The identifier of the resource.
+ ${ResourceUri},
+
+ [Parameter(ParameterSetName='List', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The region where the metrics you want reside.
+ ${Region},
+
+ [Parameter()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Metric namespace where the metrics you want reside.
+ ${MetricNamespace},
+
+ [Parameter()]
+ [Alias('AzureRMContext', 'AzureCredential')]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Azure')]
+ [System.Management.Automation.PSObject]
+ # The DefaultProfile parameter is not functional.
+ # Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
+ ${DefaultProfile},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Wait for .NET debugger to attach
+ ${Break},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be appended to the front of the pipeline
+ ${HttpPipelineAppend},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be prepended to the front of the pipeline
+ ${HttpPipelinePrepend},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Uri]
+ # The URI for the proxy server to use
+ ${Proxy},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.PSCredential]
+ # Credentials for a proxy server to use for the remote call
+ ${ProxyCredential},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Use the default credentials for the proxy
+ ${ProxyUseDefaultCredentials}
+)
+
+begin {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+ $parameterSet = $PSCmdlet.ParameterSetName
+
+ if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) {
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString()
+ }
+ $preTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ if ($preTelemetryId -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId =(New-Guid).ToString()
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Create', $MyInvocation, $parameterSet, $PSCmdlet)
+ } else {
+ $internalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ if ($internalCalledCmdlets -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $MyInvocation.MyCommand.Name
+ } else {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets += ',' + $MyInvocation.MyCommand.Name
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = 'internal'
+ }
+
+ $mapping = @{
+ List = 'Az.Metric.private\Get-AzMetricDefinition_List';
+ List1 = 'Az.Metric.private\Get-AzMetricDefinition_List1';
+ }
+ if (('List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
+ $testPlayback = $false
+ $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } }
+ if ($testPlayback) {
+ $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
+ } else {
+ $PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
+ }
+ }
+ $cmdInfo = Get-Command -Name $mapping[$parameterSet]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name)
+ }
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters}
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+
+process {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+
+ finally {
+ $backupTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ $backupInternalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+
+}
+end {
+ try {
+ $steppablePipeline.End()
+
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $backupTelemetryId
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $backupInternalCalledCmdlets
+ if ($preTelemetryId -eq '') {
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Send', $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $preTelemetryId
+
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+}
diff --git a/src/Monitor/Metric.Autorest/exports/New-AzMetricFilter.ps1 b/src/Monitor/Metric.Autorest/exports/New-AzMetricFilter.ps1
new file mode 100644
index 000000000000..5dbe49016c2f
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/exports/New-AzMetricFilter.ps1
@@ -0,0 +1,129 @@
+
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+
+<#
+.Synopsis
+Creates a metric dimension filter that can be used to query metrics.
+.Description
+Creates a metric dimension filter that can be used to query metrics.
+.Example
+New-AzMetricFilter -Dimension City -Operator eq -Value "Seattle","New York"
+
+.Outputs
+System.String
+.Link
+https://learn.microsoft.com/powershell/module/az.monitor/new-azmetricfilter
+#>
+function New-AzMetricFilter {
+[OutputType([System.String])]
+[CmdletBinding(PositionalBinding=$false)]
+param(
+ [Parameter()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # The dimension name
+ ${Dimension},
+
+ [Parameter()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # The operator
+ ${Operator},
+
+ [Parameter()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String[]]
+ # The list of values for the dimension
+ ${Value}
+)
+
+begin {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+ $parameterSet = $PSCmdlet.ParameterSetName
+
+ if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) {
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString()
+ }
+ $preTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ if ($preTelemetryId -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId =(New-Guid).ToString()
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Create', $MyInvocation, $parameterSet, $PSCmdlet)
+ } else {
+ $internalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ if ($internalCalledCmdlets -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $MyInvocation.MyCommand.Name
+ } else {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets += ',' + $MyInvocation.MyCommand.Name
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = 'internal'
+ }
+
+ $mapping = @{
+ __AllParameterSets = 'Az.Metric.custom\New-AzMetricFilter';
+ }
+ $cmdInfo = Get-Command -Name $mapping[$parameterSet]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name)
+ }
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters}
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+
+process {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+
+ finally {
+ $backupTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ $backupInternalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+
+}
+end {
+ try {
+ $steppablePipeline.End()
+
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $backupTelemetryId
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $backupInternalCalledCmdlets
+ if ($preTelemetryId -eq '') {
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Send', $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $preTelemetryId
+
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+}
diff --git a/src/Monitor/Metric.Autorest/exports/ProxyCmdletDefinitions.ps1 b/src/Monitor/Metric.Autorest/exports/ProxyCmdletDefinitions.ps1
new file mode 100644
index 000000000000..f43542a22f66
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/exports/ProxyCmdletDefinitions.ps1
@@ -0,0 +1,638 @@
+
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+
+<#
+.Synopsis
+Lists the metric definitions for the subscription.
+.Description
+Lists the metric definitions for the subscription.
+.Example
+Get-AzMetricDefinition -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/Default-Web-EastUS/providers/Microsoft.Web/sites/website
+.Example
+Get-AzMetricDefinition -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/Default-Web-EastUS/providers/Microsoft.Web/sites/website | Format-List
+.Example
+Get-AzMetricDefinition -Region eastus2euap -MetricNamespace "Microsoft.Storage/storageAccounts"
+
+.Outputs
+Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition
+.Outputs
+Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinition
+.Link
+https://learn.microsoft.com/powershell/module/az.monitor/get-azmetricdefinition
+#>
+function Get-AzMetricDefinition {
+[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinition], [Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition])]
+[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
+param(
+ [Parameter(ParameterSetName='List')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
+ [System.String[]]
+ # The ID of the target subscription.
+ ${SubscriptionId},
+
+ [Parameter(ParameterSetName='List1', Mandatory)]
+ [Alias('ResourceId')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [System.String]
+ # The identifier of the resource.
+ ${ResourceUri},
+
+ [Parameter(ParameterSetName='List', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The region where the metrics you want reside.
+ ${Region},
+
+ [Parameter()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Metric namespace where the metrics you want reside.
+ ${MetricNamespace},
+
+ [Parameter()]
+ [Alias('AzureRMContext', 'AzureCredential')]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Azure')]
+ [System.Management.Automation.PSObject]
+ # The DefaultProfile parameter is not functional.
+ # Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
+ ${DefaultProfile},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Wait for .NET debugger to attach
+ ${Break},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be appended to the front of the pipeline
+ ${HttpPipelineAppend},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be prepended to the front of the pipeline
+ ${HttpPipelinePrepend},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Uri]
+ # The URI for the proxy server to use
+ ${Proxy},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.PSCredential]
+ # Credentials for a proxy server to use for the remote call
+ ${ProxyCredential},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Use the default credentials for the proxy
+ ${ProxyUseDefaultCredentials}
+)
+
+begin {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+ $parameterSet = $PSCmdlet.ParameterSetName
+
+ if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) {
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString()
+ }
+ $preTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ if ($preTelemetryId -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId =(New-Guid).ToString()
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Create', $MyInvocation, $parameterSet, $PSCmdlet)
+ } else {
+ $internalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ if ($internalCalledCmdlets -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $MyInvocation.MyCommand.Name
+ } else {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets += ',' + $MyInvocation.MyCommand.Name
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = 'internal'
+ }
+
+ $mapping = @{
+ List = 'Az.Metric.private\Get-AzMetricDefinition_List';
+ List1 = 'Az.Metric.private\Get-AzMetricDefinition_List1';
+ }
+ if (('List') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
+ $testPlayback = $false
+ $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } }
+ if ($testPlayback) {
+ $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
+ } else {
+ $PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
+ }
+ }
+ $cmdInfo = Get-Command -Name $mapping[$parameterSet]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name)
+ }
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters}
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+
+process {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+
+ finally {
+ $backupTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ $backupInternalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+
+}
+end {
+ try {
+ $steppablePipeline.End()
+
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $backupTelemetryId
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $backupInternalCalledCmdlets
+ if ($preTelemetryId -eq '') {
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Send', $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $preTelemetryId
+
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+}
+
+<#
+.Synopsis
+**Lists the metric values for a resource**.
+.Description
+**Lists the metric values for a resource**.
+.Example
+Get-AzMetric -Region eastus -Aggregation count -AutoAdjustTimegrain -Filter "LUN eq '0' and Microsoft.ResourceId eq '*'" -Interval "PT6H" -MetricName "Data Disk Max Burst IOPS" -MetricNamespace "microsoft.compute/virtualmachines" -Orderby "count desc" -Rollupby "LUN" -StartTime "2023-12-08T19:00:00Z" -EndTime "2023-12-12T01:00:00Z" -Top 10
+.Example
+Get-AzMetric -ResourceUri /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/joyer-test/providers/Microsoft.Storage/storageAccounts/storagetasktest202402281/blobServices/default -Aggregation "average,minimum,maximum" -AutoAdjustTimegrain -Filter "Tier eq '*'" -Interval "PT6H" -MetricName "BlobCount,BlobCapacity" -MetricNamespace "Microsoft.Storage/storageAccounts/blobServices" -Orderby "average asc" -StartTime "2024-03-10T09:00:00Z" -EndTime "2024-03-10T14:00:00Z" -Top 1
+
+.Outputs
+Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse
+.Link
+https://learn.microsoft.com/powershell/module/az.monitor/get-azmetric
+#>
+function Get-AzMetric {
+[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse])]
+[CmdletBinding(DefaultParameterSetName='List2', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
+param(
+ [Parameter(ParameterSetName='List2', Mandatory)]
+ [Alias('ResourceId')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [System.String]
+ # The identifier of the resource.
+ ${ResourceUri},
+
+ [Parameter(ParameterSetName='ListViaJsonString')]
+ [Parameter(ParameterSetName='ListViaJsonFilePath')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Path')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
+ [System.String[]]
+ # The ID of the target subscription.
+ ${SubscriptionId},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Alias('AggregationType')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The list of aggregation types (comma separated) to retrieve.
+ # *Examples: average, minimum, maximum*
+ ${Aggregation},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.Management.Automation.SwitchParameter]
+ # When set to true, if the timespan passed in is not supported by this metric, the API will return the result using the closest supported timespan.
+ # When set to false, an error is returned for invalid timespan parameters.
+ # Defaults to false.
+ ${AutoAdjustTimegrain},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Alias('MetricFilter')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The **$filter** is used to reduce the set of metric data returned.
+ # Example:
+ # Metric contains metadata A, B and C.
+ # - Return all time series of C where A = a1 and B = b1 or b2
+ # **$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
+ # - Invalid variant:
+ # **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
+ # This is invalid because the logical or operator cannot separate two different metadata names.
+ # - Return all time series where A = a1, B = b1 and C = c1:
+ # **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
+ # - Return all time series where A = a1
+ # **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ ${Filter},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Alias('TimeGrain')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.DefaultInfo(Script='PT1M')]
+ [System.String]
+ # The interval (i.e.
+ # timegrain) of the query in ISO 8601 duration format.
+ # Defaults to PT1M.
+ # Special case for 'FULL' value that returns single datapoint for entire time span requested.
+ # *Examples: PT15M, PT1H, P1D, FULL*
+ ${Interval},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The names of the metrics (comma separated) to retrieve.
+ ${MetricName},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Metric namespace where the metrics you want reside.
+ ${MetricNamespace},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The aggregation to use for sorting results and the direction of the sort.
+ # Only one order can be specified.
+ # *Examples: sum asc*
+ ${OrderBy},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("Data", "Metadata")]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Reduces the set of data collected.
+ # The syntax allowed depends on the operation.
+ # See the operation's description for details.
+ ${ResultType},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # Dimension name(s) to rollup results by.
+ # For example if you only want to see metric values with a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ ${RollUpBy},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.DateTime]
+ # Specifies the start time of the query in local time.
+ # The default is the current local time minus one hour.
+ ${StartTime},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.DateTime]
+ # [Microsoft.Azure.PowerShell.Cmdlets.SqlVirtualMachine.Runtime.DefaultInfo(Script = 'DateTime.UtcNow')]
+ # Specifies the end time of the query in local time.
+ # The default is the current time.
+ ${EndTime},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.Int32]
+ # The maximum number of records to retrieve per resource ID in the request.
+ # Valid only if filter is specified.
+ # Defaults to 10.
+ ${Top},
+
+ [Parameter(ParameterSetName='List2')]
+ [Parameter(ParameterSetName='ListExpanded')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.Management.Automation.SwitchParameter]
+ # When set to false, invalid filter parameter values will be ignored.
+ # When set to true, an error is returned for invalid filter parameters.
+ # Defaults to true.
+ ${ValidateDimension},
+
+ [Parameter(ParameterSetName='ListViaJsonString', Mandatory)]
+ [Parameter(ParameterSetName='ListViaJsonFilePath', Mandatory)]
+ [Parameter(ParameterSetName='ListExpanded', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Query')]
+ [System.String]
+ # The region where the metrics you want reside.
+ ${Region},
+
+ [Parameter(ParameterSetName='ListViaJsonString', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # Json string supplied to the List operation
+ ${JsonString},
+
+ [Parameter(ParameterSetName='ListViaJsonFilePath', Mandatory)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # Path of Json file supplied to the List operation
+ ${JsonFilePath},
+
+ [Parameter()]
+ [Alias('AzureRMContext', 'AzureCredential')]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Azure')]
+ [System.Management.Automation.PSObject]
+ # The DefaultProfile parameter is not functional.
+ # Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
+ ${DefaultProfile},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Wait for .NET debugger to attach
+ ${Break},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be appended to the front of the pipeline
+ ${HttpPipelineAppend},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SendAsyncStep[]]
+ # SendAsync Pipeline Steps to be prepended to the front of the pipeline
+ ${HttpPipelinePrepend},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Uri]
+ # The URI for the proxy server to use
+ ${Proxy},
+
+ [Parameter(DontShow)]
+ [ValidateNotNull()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.PSCredential]
+ # Credentials for a proxy server to use for the remote call
+ ${ProxyCredential},
+
+ [Parameter(DontShow)]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Runtime')]
+ [System.Management.Automation.SwitchParameter]
+ # Use the default credentials for the proxy
+ ${ProxyUseDefaultCredentials}
+)
+
+begin {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+ $parameterSet = $PSCmdlet.ParameterSetName
+
+ if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) {
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString()
+ }
+ $preTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ if ($preTelemetryId -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId =(New-Guid).ToString()
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Create', $MyInvocation, $parameterSet, $PSCmdlet)
+ } else {
+ $internalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ if ($internalCalledCmdlets -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $MyInvocation.MyCommand.Name
+ } else {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets += ',' + $MyInvocation.MyCommand.Name
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = 'internal'
+ }
+
+ $mapping = @{
+ List2 = 'Az.Metric.custom\Get-AzMetric';
+ ListViaJsonString = 'Az.Metric.custom\Get-AzMetric';
+ ListViaJsonFilePath = 'Az.Metric.custom\Get-AzMetric';
+ ListExpanded = 'Az.Metric.custom\Get-AzMetric';
+ }
+ if (('ListViaJsonString', 'ListViaJsonFilePath', 'ListExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) {
+ $testPlayback = $false
+ $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } }
+ if ($testPlayback) {
+ $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')
+ } else {
+ $PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id
+ }
+ }
+ if (('List2', 'ListExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('Interval') ) {
+ $PSBoundParameters['Interval'] = PT1M
+ }
+ $cmdInfo = Get-Command -Name $mapping[$parameterSet]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name)
+ }
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters}
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+
+process {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+
+ finally {
+ $backupTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ $backupInternalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+
+}
+end {
+ try {
+ $steppablePipeline.End()
+
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $backupTelemetryId
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $backupInternalCalledCmdlets
+ if ($preTelemetryId -eq '') {
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Send', $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $preTelemetryId
+
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+}
+
+<#
+.Synopsis
+Creates a metric dimension filter that can be used to query metrics.
+.Description
+Creates a metric dimension filter that can be used to query metrics.
+.Example
+New-AzMetricFilter -Dimension City -Operator eq -Value "Seattle","New York"
+
+.Outputs
+System.String
+.Link
+https://learn.microsoft.com/powershell/module/az.monitor/new-azmetricfilter
+#>
+function New-AzMetricFilter {
+[OutputType([System.String])]
+[CmdletBinding(PositionalBinding=$false)]
+param(
+ [Parameter()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # The dimension name
+ ${Dimension},
+
+ [Parameter()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String]
+ # The operator
+ ${Operator},
+
+ [Parameter()]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Category('Body')]
+ [System.String[]]
+ # The list of values for the dimension
+ ${Value}
+)
+
+begin {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+ $parameterSet = $PSCmdlet.ParameterSetName
+
+ if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) {
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString()
+ }
+ $preTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ if ($preTelemetryId -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId =(New-Guid).ToString()
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Create', $MyInvocation, $parameterSet, $PSCmdlet)
+ } else {
+ $internalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ if ($internalCalledCmdlets -eq '') {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $MyInvocation.MyCommand.Name
+ } else {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets += ',' + $MyInvocation.MyCommand.Name
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = 'internal'
+ }
+
+ $mapping = @{
+ __AllParameterSets = 'Az.Metric.custom\New-AzMetricFilter';
+ }
+ $cmdInfo = Get-Command -Name $mapping[$parameterSet]
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name)
+ }
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters}
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+
+process {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+
+ finally {
+ $backupTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId
+ $backupInternalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+
+}
+end {
+ try {
+ $steppablePipeline.End()
+
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $backupTelemetryId
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $backupInternalCalledCmdlets
+ if ($preTelemetryId -eq '') {
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.module]::Instance.Telemetry.Invoke('Send', $MyInvocation, $parameterSet, $PSCmdlet)
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ }
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $preTelemetryId
+
+ } catch {
+ [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext()
+ throw
+ }
+}
+}
diff --git a/src/Monitor/Metric.Autorest/exports/README.md b/src/Monitor/Metric.Autorest/exports/README.md
new file mode 100644
index 000000000000..6aa48dcaec47
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/exports/README.md
@@ -0,0 +1,20 @@
+# Exports
+This directory contains the cmdlets *exported by* `Az.Metric`. No other cmdlets in this repository are directly exported. What that means is the `Az.Metric` module will run [Export-ModuleMember](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/export-modulemember) on the cmldets in this directory. The cmdlets in this directory are generated at **build-time**. Do not put any custom code, files, cmdlets, etc. into this directory. Please use `..\custom` for all custom implementation.
+
+## Info
+- Modifiable: no
+- Generated: all
+- Committed: no
+- Packaged: yes
+
+## Details
+The cmdlets generated here are created every time you run `build-module.ps1`. These cmdlets are a merge of all (excluding `InternalExport`) cmdlets from the private binary (`..\bin\Az.Metric.private.dll`) and from the `..\custom\Az.Metric.custom.psm1` module. Cmdlets that are *not merged* from those directories are decorated with the `InternalExport` attribute. This happens when you set the cmdlet to **hide** from configuration. For more information on hiding, see [cmdlet hiding](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md#cmdlet-hiding-exportation-suppression) or the [README.md](..\internal/README.md) in the `..\internal` folder.
+
+## Purpose
+We generate script cmdlets out of the binary cmdlets and custom cmdlets. The format of script cmdlets are simplistic; thus, easier to generate at build time. Generating the cmdlets is required as to allow merging of generated binary, hand-written binary, and hand-written custom cmdlets. For Azure cmdlets, having script cmdlets simplifies the mechanism for exporting Azure profiles.
+
+## Structure
+The cmdlets generated here will flat in the directory (no sub-folders) as long as there are no Azure profiles specified for any cmdlets. Azure profiles (the `Profiles` attribute) is only applied when generating with the `--azure` attribute (or `azure: true` in the configuration). When Azure profiles are applied, the folder structure has a folder per profile. Each profile folder has only those cmdlets that apply to that profile.
+
+## Usage
+When `./Az.Metric.psm1` is loaded, it dynamically exports cmdlets here based on the folder structure and on the selected profile. If there are no sub-folders, it exports all cmdlets at the root of this folder. If there are sub-folders, it checks to see the selected profile. If no profile is selected, it exports the cmdlets in the last sub-folder (alphabetically). If a profile is selected, it exports the cmdlets in the sub-folder that matches the profile name. If there is no sub-folder that matches the profile name, it exports no cmdlets and writes a warning message.
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generate-help.ps1 b/src/Monitor/Metric.Autorest/generate-help.ps1
new file mode 100644
index 000000000000..0541160e8af0
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generate-help.ps1
@@ -0,0 +1,74 @@
+# ----------------------------------------------------------------------------------
+# 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.
+# ----------------------------------------------------------------------------------
+param([switch]$NotIsolated)
+$ErrorActionPreference = 'Stop'
+
+$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
+if(-not $NotIsolated) {
+ Write-Host -ForegroundColor Green 'Creating isolated process...'
+ & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -NotIsolated
+ return
+}
+
+$exportsFolder = Join-Path $PSScriptRoot 'exports'
+if(-not (Test-Path $exportsFolder)) {
+ Write-Error "Exports folder '$exportsFolder' was not found."
+}
+
+$directories = Get-ChildItem -Directory -Path $exportsFolder
+$hasProfiles = ($directories | Measure-Object).Count -gt 0
+if(-not $hasProfiles) {
+ $directories = Get-Item -Path $exportsFolder
+}
+
+$docsFolder = Join-Path $PSScriptRoot 'docs'
+if(Test-Path $docsFolder) {
+ $null = Get-ChildItem -Path $docsFolder -Recurse -Exclude 'README.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue
+}
+$null = New-Item -ItemType Directory -Force -Path $docsFolder -ErrorAction SilentlyContinue
+$examplesFolder = Join-Path $PSScriptRoot 'examples'
+
+$modulePsd1 = Get-Item -Path (Join-Path $PSScriptRoot './Az.Metric.psd1')
+$modulePath = $modulePsd1.FullName
+$moduleName = $modulePsd1.BaseName
+
+# Load DLL to use build-time cmdlets
+Import-Module -Name $modulePath
+Import-Module -Name (Join-Path $PSScriptRoot './bin/Az.Metric.private.dll')
+$instance = [Microsoft.Azure.PowerShell.Cmdlets.Metric.Module]::Instance
+# Module info is shared per profile
+$moduleInfo = Get-Module -Name $moduleName
+
+foreach($directory in $directories)
+{
+ if($hasProfiles) {
+ Select-AzProfile -Name $directory.Name
+ }
+ # Reload module per profile
+ Import-Module -Name $modulePath -Force
+
+ $cmdletNames = Get-ScriptCmdlet -ScriptFolder $directory.FullName
+ $cmdletHelpInfo = $cmdletNames | ForEach-Object { Get-Help -Name $_ -Full }
+ $cmdletFunctionInfo = Get-ScriptCmdlet -ScriptFolder $directory.FullName -AsFunctionInfo
+
+ $docsPath = Join-Path $docsFolder $directory.Name
+ $null = New-Item -ItemType Directory -Force -Path $docsPath -ErrorAction SilentlyContinue
+ $examplesPath = Join-Path $examplesFolder $directory.Name
+ $addComplexInterfaceInfo = ![System.Convert]::ToBoolean('true')
+ Export-HelpMarkdown -ModuleInfo $moduleInfo -FunctionInfo $cmdletFunctionInfo -HelpInfo $cmdletHelpInfo -DocsFolder $docsPath -ExamplesFolder $examplesPath -AddComplexInterfaceInfo:$addComplexInterfaceInfo
+ Write-Host -ForegroundColor Green "Created documentation in '$docsPath'"
+}
+
+Write-Host -ForegroundColor Green '-------------Done-------------'
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generate-portal-ux.ps1 b/src/Monitor/Metric.Autorest/generate-portal-ux.ps1
new file mode 100644
index 000000000000..a32906dc3de1
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generate-portal-ux.ps1
@@ -0,0 +1,374 @@
+# ----------------------------------------------------------------------------------
+# 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.
+#
+# This Script will create a folder dedicated to Azure-specific content and includes metadata files essential for enhancing the user experience (UX) within the Azure portal.
+# These files are utilized by the Azure portal to effectively present the usage of cmdlets related to specific resources on portal pages.
+# ----------------------------------------------------------------------------------
+param([switch]$NotIsolated)
+$ErrorActionPreference = 'Stop'
+
+$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
+if(-not $NotIsolated) {
+ Write-Host -ForegroundColor Green 'Creating isolated process...'
+ & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -NotIsolated
+ return
+}
+
+$moduleName = 'Az.Metric'
+$rootModuleName = 'Az.Monitor'
+if ($rootModuleName -eq "")
+{
+ $rootModuleName = $moduleName
+}
+$modulePsd1 = Get-Item -Path (Join-Path $PSScriptRoot "./$moduleName.psd1")
+$modulePath = $modulePsd1.FullName
+
+# Load DLL to use build-time cmdlets
+Import-Module -Name $modulePath
+Import-Module -Name (Join-Path $PSScriptRoot "./bin/$moduleName.private.dll")
+$instance = [Microsoft.Azure.PowerShell.Cmdlets.Metric.Module]::Instance
+# Module info is shared per profile
+$moduleInfo = Get-Module -Name $moduleName
+$parameterSetsInfo = Get-Module -Name "$moduleName.private"
+
+function Test-FunctionSupported()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [string]
+ $FunctionName
+ )
+
+ If (-not $FunctionName.Contains("_")) {
+ return $false
+ }
+
+ $cmdletName, $parameterSetName = $FunctionName.Split("_")
+ 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")) {
+ return $false
+ }
+
+ $parameterSetInfo = $parameterSetsInfo.ExportedCmdlets[$FunctionName]
+ foreach ($parameterInfo in $parameterSetInfo.Parameters.Values)
+ {
+ $category = (Get-ParameterAttribute -ParameterInfo $parameterInfo -AttributeName "CategoryAttribute").Categories
+ $invalideCategory = @('Query', 'Body')
+ if ($invalideCategory -contains $category)
+ {
+ return $false
+ }
+ }
+
+ $customFiles = Get-ChildItem -Path custom -Filter "$cmdletName.*"
+ if ($customFiles.Length -ne 0)
+ {
+ Write-Host -ForegroundColor Yellow "There are come custom files for $cmdletName, skip generate UX data for it."
+ return $false
+ }
+
+ return $true
+}
+
+function Get-MappedCmdletFromFunctionName()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [string]
+ $FunctionName
+ )
+
+ $cmdletName, $parameterSetName = $FunctionName.Split("_")
+
+ return $cmdletName
+}
+
+function Get-ParameterAttribute()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [System.Management.Automation.ParameterMetadata]
+ $ParameterInfo,
+ [Parameter()]
+ [String]
+ $AttributeName
+ )
+ return $ParameterInfo.Attributes | Where-Object { $_.TypeId.Name -eq $AttributeName }
+}
+
+function Get-CmdletAttribute()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [System.Management.Automation.CommandInfo]
+ $CmdletInfo,
+ [Parameter()]
+ [String]
+ $AttributeName
+ )
+
+ return $CmdletInfo.ImplementingType.GetTypeInfo().GetCustomAttributes([System.object], $true) | Where-Object { $_.TypeId.Name -eq $AttributeName }
+}
+
+function Get-CmdletDescription()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [String]
+ $CmdletName
+ )
+ $helpInfo = Get-Help $CmdletName -Full
+
+ $description = $helpInfo.Description.Text
+ if ($null -eq $description)
+ {
+ return ""
+ }
+ return $description
+}
+
+# Test whether the parameter is from swagger http path
+function Test-ParameterFromSwagger()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [System.Management.Automation.ParameterMetadata]
+ $ParameterInfo
+ )
+ $category = (Get-ParameterAttribute -ParameterInfo $ParameterInfo -AttributeName "CategoryAttribute").Categories
+ $doNotExport = Get-ParameterAttribute -ParameterInfo $ParameterInfo -AttributeName "DoNotExportAttribute"
+ if ($null -ne $doNotExport)
+ {
+ return $false
+ }
+
+ $valideCategory = @('Path')
+ if ($valideCategory -contains $category)
+ {
+ return $true
+ }
+ return $false
+}
+
+function New-ExampleForParameterSet()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [System.Management.Automation.CommandInfo]
+ $ParameterSetInfo
+ )
+ $parameters = $ParameterSetInfo.Parameters.Values | Where-Object { Test-ParameterFromSwagger $_ }
+ $result = @()
+ foreach ($parameter in $parameters)
+ {
+ $category = (Get-ParameterAttribute -parameterInfo $parameter -AttributeName "CategoryAttribute").Categories
+ $sourceName = (Get-ParameterAttribute -parameterInfo $parameter -AttributeName "InfoAttribute").SerializedName
+ $name = $parameter.Name
+ $result += [ordered]@{
+ name = "-$Name"
+ value = "[$category.$sourceName]"
+ }
+ }
+
+ return $result
+}
+
+function New-ParameterArrayInParameterSet()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [System.Management.Automation.CommandInfo]
+ $ParameterSetInfo
+ )
+ $parameters = $ParameterSetInfo.Parameters.Values | Where-Object { Test-ParameterFromSwagger $_ }
+ $result = @()
+ foreach ($parameter in $parameters)
+ {
+ $isMandatory = (Get-ParameterAttribute -parameterInfo $parameter -AttributeName "ParameterAttribute").Mandatory
+ $parameterName = $parameter.Name
+ $parameterType = $parameter.ParameterType.ToString().Split('.')[1]
+ if ($parameter.SwitchParameter)
+ {
+ $parameterSignature = "-$parameterName"
+ }
+ else
+ {
+ $parameterSignature = "-$parameterName <$parameterType>"
+ }
+ if ($parameterName -eq "SubscriptionId")
+ {
+ $isMandatory = $false
+ }
+ if (-not $isMandatory)
+ {
+ $parameterSignature = "[$parameterSignature]"
+ }
+ $result += $parameterSignature
+ }
+
+ return $result
+}
+
+function New-MetadataForParameterSet()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [System.Management.Automation.CommandInfo]
+ $ParameterSetInfo
+ )
+ $httpAttribute = Get-CmdletAttribute -CmdletInfo $ParameterSetInfo -AttributeName "HttpPathAttribute"
+ $httpPath = $httpAttribute.Path
+ $apiVersion = $httpAttribute.ApiVersion
+ $provider = [System.Text.RegularExpressions.Regex]::New("/providers/([\w+\.]+)/").Match($httpPath).Groups[1].Value
+ $resourcePath = "/" + $httpPath.Split("$provider/")[1]
+ $resourceType = [System.Text.RegularExpressions.Regex]::New("/([\w]+)/\{\w+\}").Matches($resourcePath) | ForEach-Object {$_.groups[1].Value} | Join-String -Separator "/"
+ $cmdletName = Get-MappedCmdletFromFunctionName $ParameterSetInfo.Name
+ $description = (Get-CmdletAttribute -CmdletInfo $ParameterSetInfo -AttributeName "DescriptionAttribute").Description
+ [object[]]$example = New-ExampleForParameterSet $ParameterSetInfo
+ [string[]]$signature = New-ParameterArrayInParameterSet $ParameterSetInfo
+
+ return @{
+ Path = $httpPath
+ Provider = $provider
+ ResourceType = $resourceType
+ ApiVersion = $apiVersion
+ CmdletName = $cmdletName
+ Description = $description
+ Example = $example
+ Signature = @{
+ parameters = $signature
+ }
+ }
+}
+
+function Merge-WithExistCmdletMetadata()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [System.Collections.Specialized.OrderedDictionary]
+ $ExistedCmdletInfo,
+ [Parameter()]
+ [Hashtable]
+ $ParameterSetMetadata
+ )
+ $ExistedCmdletInfo.help.parameterSets += $ParameterSetMetadata.Signature
+ $ExistedCmdletInfo.examples += [ordered]@{
+ description = $ParameterSetMetadata.Description
+ parameters = $ParameterSetMetadata.Example
+ }
+
+ return $ExistedCmdletInfo
+}
+
+function New-MetadataForCmdlet()
+{
+ [CmdletBinding()]
+ Param (
+ [Parameter()]
+ [Hashtable]
+ $ParameterSetMetadata
+ )
+ $cmdletName = $ParameterSetMetadata.CmdletName
+ $description = Get-CmdletDescription $cmdletName
+ $result = [ordered]@{
+ name = $cmdletName
+ description = $description
+ path = $ParameterSetMetadata.Path
+ help = [ordered]@{
+ learnMore = [ordered]@{
+ url = "https://learn.microsoft.com/powershell/module/$rootModuleName/$cmdletName".ToLower()
+ }
+ parameterSets = @()
+ }
+ examples = @()
+ }
+ $result = Merge-WithExistCmdletMetadata -ExistedCmdletInfo $result -ParameterSetMetadata $ParameterSetMetadata
+ return $result
+}
+
+$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-FunctionSupported($_) }
+$resourceTypes = @{}
+foreach ($parameterSetName in $parameterSets)
+{
+ $cmdletInfo = $parameterSetsInfo.ExportedCommands[$parameterSetName]
+ $parameterSetMetadata = New-MetadataForParameterSet -ParameterSetInfo $cmdletInfo
+ $cmdletName = $parameterSetMetadata.CmdletName
+ if (-not ($moduleInfo.ExportedCommands.ContainsKey($cmdletName)))
+ {
+ continue
+ }
+ if ($resourceTypes.ContainsKey($parameterSetMetadata.ResourceType))
+ {
+ $ExistedCmdletInfo = $resourceTypes[$parameterSetMetadata.ResourceType].commands | Where-Object { $_.name -eq $cmdletName }
+ if ($ExistedCmdletInfo)
+ {
+ $ExistedCmdletInfo = Merge-WithExistCmdletMetadata -ExistedCmdletInfo $ExistedCmdletInfo -ParameterSetMetadata $parameterSetMetadata
+ }
+ else
+ {
+ $cmdletInfo = New-MetadataForCmdlet -ParameterSetMetadata $parameterSetMetadata
+ $resourceTypes[$parameterSetMetadata.ResourceType].commands += $cmdletInfo
+ }
+ }
+ else
+ {
+ $cmdletInfo = New-MetadataForCmdlet -ParameterSetMetadata $parameterSetMetadata
+ $resourceTypes[$parameterSetMetadata.ResourceType] = [ordered]@{
+ resourceType = $parameterSetMetadata.ResourceType
+ apiVersion = $parameterSetMetadata.ApiVersion
+ learnMore = @{
+ url = "https://learn.microsoft.com/powershell/module/$rootModuleName".ToLower()
+ }
+ commands = @($cmdletInfo)
+ provider = $parameterSetMetadata.Provider
+ }
+ }
+}
+
+$UXFolder = 'UX'
+if (Test-Path $UXFolder)
+{
+ Remove-Item -Path $UXFolder -Recurse
+}
+$null = New-Item -ItemType Directory -Path $UXFolder
+
+foreach ($resourceType in $resourceTypes.Keys)
+{
+ $resourceTypeFileName = $resourceType -replace "/", "-"
+ if ($resourceTypeFileName -eq "")
+ {
+ continue
+ }
+ $resourceTypeInfo = $resourceTypes[$resourceType]
+ $provider = $resourceTypeInfo.provider
+ $providerFolder = "$UXFolder/$provider"
+ if (-not (Test-Path $providerFolder))
+ {
+ $null = New-Item -ItemType Directory -Path $providerFolder
+ }
+ $resourceTypeInfo.Remove("provider")
+ $resourceTypeInfo | ConvertTo-Json -Depth 10 | Out-File "$providerFolder/$resourceTypeFileName.json"
+}
diff --git a/src/Monitor/Metric.Autorest/generated/Module.cs b/src/Monitor/Metric.Autorest/generated/Module.cs
new file mode 100644
index 000000000000..029d2403be59
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/Module.cs
@@ -0,0 +1,202 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+ using SendAsyncStepDelegate = global::System.Func, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>;
+ using PipelineChangeDelegate = global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>;
+ using GetParameterDelegate = global::System.Func;
+ using ModuleLoadPipelineDelegate = global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>, global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>>;
+ using ArgumentCompleterDelegate = global::System.Func;
+ using GetTelemetryIdDelegate = global::System.Func;
+ using TelemetryDelegate = global::System.Action;
+ using NewRequestPipelineDelegate = global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>, global::System.Action, global::System.Threading.Tasks.Task>, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>>>;
+ using SignalDelegate = global::System.Func, global::System.Threading.Tasks.Task>;
+ using EventListenerDelegate = global::System.Func, global::System.Func, global::System.Threading.Tasks.Task>, global::System.Management.Automation.InvocationInfo, string, string, string, global::System.Exception, global::System.Threading.Tasks.Task>;
+ using NextDelegate = global::System.Func, global::System.Threading.Tasks.Task>, global::System.Threading.Tasks.Task>;
+ using SanitizerDelegate = global::System.Action;
+ using GetTelemetryInfoDelegate = global::System.Func>;
+
+ /// A class that contains the module-common code and data.
+ public partial class Module
+ {
+ /// The currently selected profile.
+ public string Profile = global::System.String.Empty;
+
+ public global::System.Net.Http.HttpClientHandler _handler = new global::System.Net.Http.HttpClientHandler();
+
+ private static bool _init = false;
+
+ private static readonly global::System.Object _initLock = new global::System.Object();
+
+ private static Microsoft.Azure.PowerShell.Cmdlets.Metric.Module _instance;
+
+ /// the ISendAsync pipeline instance
+ private Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpPipeline _pipeline;
+
+ /// the ISendAsync pipeline instance (when proxy is enabled)
+ private Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpPipeline _pipelineWithProxy;
+
+ private static readonly global::System.Object _singletonLock = new global::System.Object();
+
+ public bool _useProxy = false;
+
+ public global::System.Net.WebProxy _webProxy = new global::System.Net.WebProxy();
+
+ /// Gets completion data for azure specific fields
+ public ArgumentCompleterDelegate ArgumentCompleter { get; set; }
+
+ /// The instance of the Client API
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Metric ClientAPI { get; set; }
+
+ /// A delegate that gets called for each signalled event
+ public EventListenerDelegate EventListener { get; set; }
+
+ /// The delegate to call to get parameter data from a common module.
+ public GetParameterDelegate GetParameterValue { get; set; }
+
+ /// The delegate to get the telemetry Id.
+ public GetTelemetryIdDelegate GetTelemetryId { get; set; }
+
+ /// The delegate to get the telemetry info.
+ public GetTelemetryInfoDelegate GetTelemetryInfo { get; set; }
+
+ /// the singleton of this module class
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Module Instance { get { if (_instance == null) { lock (_singletonLock) { if (_instance == null) { _instance = new Module(); }}} return _instance; } }
+
+ /// The Name of this module
+ public string Name => @"Az.Metric";
+
+ /// The delegate to call when this module is loaded (supporting a commmon module).
+ public ModuleLoadPipelineDelegate OnModuleLoad { get; set; }
+
+ /// The delegate to call before each new request (supporting a commmon module).
+ public NewRequestPipelineDelegate OnNewRequest { get; set; }
+
+ /// The name of the currently selected Azure profile
+ public global::System.String ProfileName { get; set; }
+
+ /// The ResourceID for this module (azure arm).
+ public string ResourceId => @"Az.Metric";
+
+ /// The delegate to call in WriteObject to sanitize the output object.
+ public SanitizerDelegate SanitizeOutput { get; set; }
+
+ /// The delegate for creating a telemetry.
+ public TelemetryDelegate Telemetry { get; set; }
+
+ /// The from the cmdlet
+ /// The HttpPipeline for the request
+
+ partial void AfterCreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpPipeline pipeline);
+
+ /// The from the cmdlet
+ /// The HttpPipeline for the request
+
+ partial void BeforeCreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpPipeline pipeline);
+
+ partial void CustomInit();
+
+ /// Creates an instance of the HttpPipeline for each call.
+ /// The from the cmdlet
+ /// the cmdlet's correlation id.
+ /// the cmdlet's process record correlation id.
+ /// the cmdlet's parameterset name.
+ /// a dict for extensible parameters
+ /// An instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpPipeline for the remote call.
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpPipeline CreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, string correlationId, string processRecordId, string parameterSetName = null, global::System.Collections.Generic.IDictionary extensibleParameters = null)
+ {
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpPipeline pipeline = null;
+ BeforeCreatePipeline(invocationInfo, ref pipeline);
+ pipeline = (pipeline ?? (_useProxy ? _pipelineWithProxy : _pipeline)).Clone();
+ AfterCreatePipeline(invocationInfo, ref pipeline);
+ pipeline.Append(new Runtime.CmdInfoHandler(processRecordId, invocationInfo, parameterSetName).SendAsync);
+ OnNewRequest?.Invoke( invocationInfo, correlationId,processRecordId, (step)=> { pipeline.Prepend(step); } , (step)=> { pipeline.Append(step); } );
+ return pipeline;
+ }
+
+ /// Gets parameters from a common module.
+ /// The from the cmdlet
+ /// the cmdlet's correlation id.
+ /// The name of the parameter to get the value for.
+ ///
+ /// The parameter value from the common module. (Note: this should be type converted on the way back)
+ ///
+ public object GetParameter(global::System.Management.Automation.InvocationInfo invocationInfo, string correlationId, string parameterName) => GetParameterValue?.Invoke( ResourceId, Name, invocationInfo, correlationId,parameterName );
+
+ /// Initialization steps performed after the module is loaded.
+ public void Init()
+ {
+ if (_init == false)
+ {
+ lock (_initLock) {
+ if (_init == false) {
+ OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipeline.Prepend(step); } , (step)=> { _pipeline.Append(step); } );
+ OnModuleLoad?.Invoke( ResourceId, Name ,(step)=> { _pipelineWithProxy.Prepend(step); } , (step)=> { _pipelineWithProxy.Append(step); } );
+ CustomInit();
+ _init = true;
+ }
+ }
+ }
+ }
+
+ /// Creates the module instance.
+ private Module()
+ {
+ // constructor
+ ClientAPI = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Metric();
+ _handler.Proxy = _webProxy;
+ _pipeline = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpPipeline(new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpClientFactory(new global::System.Net.Http.HttpClient()));
+ _pipelineWithProxy = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpPipeline(new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.HttpClientFactory(new global::System.Net.Http.HttpClient(_handler)));
+ }
+
+ /// The HTTP Proxy to use.
+ /// The HTTP Proxy Credentials
+ /// True if the proxy should use default credentials
+ public void SetProxyConfiguration(global::System.Uri proxy, global::System.Management.Automation.PSCredential proxyCredential, bool proxyUseDefaultCredentials)
+ {
+ _useProxy = proxy != null;
+ if (proxy == null)
+ {
+ return;
+ }
+ // set the proxy configuration
+ _webProxy.Address = proxy;
+ _webProxy.BypassProxyOnLocal = false;
+ if (proxyUseDefaultCredentials)
+ {
+ _webProxy.Credentials = null;
+ _webProxy.UseDefaultCredentials = true;
+ }
+ else
+ {
+ _webProxy.UseDefaultCredentials = false;
+ _webProxy.Credentials = proxyCredential ?.GetNetworkCredential();
+ }
+ }
+
+ /// Called to dispatch events to the common module listener
+ /// The ID of the event
+ /// The cancellation token for the event
+ /// A delegate to get the detailed event data
+ /// The callback for the event dispatcher
+ /// The from the cmdlet
+ /// the cmdlet's parameterset name.
+ /// the cmdlet's correlation id.
+ /// the cmdlet's process record correlation id.
+ /// the exception that is being thrown (if available)
+ ///
+ /// A that will be complete when handling of the event is completed.
+ ///
+ public async global::System.Threading.Tasks.Task Signal(string id, global::System.Threading.CancellationToken token, global::System.Func getEventData, SignalDelegate signal, global::System.Management.Automation.InvocationInfo invocationInfo, string parameterSetName, string correlationId, string processRecordId, global::System.Exception exception)
+ {
+ using( NoSynchronizationContext )
+ {
+ await EventListener?.Invoke(id,token,getEventData, signal, invocationInfo, parameterSetName, correlationId,processRecordId,exception);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Metric.cs b/src/Monitor/Metric.Autorest/generated/api/Metric.cs
new file mode 100644
index 000000000000..ff83516a8af7
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Metric.cs
@@ -0,0 +1,2212 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ ///
+ /// Low-level API implementation for the Metric service.
+ /// Provides APIs for getting the metric metadata for Azure resources.
+ ///
+ public partial class Metric
+ {
+
+ /// Lists the metric definitions for the resource.
+ /// The identifier of the resource.
+ /// Metric namespace where the metrics you want reside.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricDefinitionsList(string resourceUri, string metricnamespace, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/"
+ + (resourceUri)
+ + "/providers/Microsoft.Insights/metricDefinitions"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricDefinitionsList_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ /// Lists the metric definitions for the subscription.
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// Metric namespace where the metrics you want reside.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricDefinitionsListAtSubscriptionScope(string subscriptionId, string region, string metricnamespace, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + global::System.Uri.EscapeDataString(subscriptionId)
+ + "/providers/Microsoft.Insights/metricDefinitions"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricDefinitionsListAtSubscriptionScope_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ /// Lists the metric definitions for the subscription.
+ ///
+ /// The region where the metrics you want reside.
+ /// Metric namespace where the metrics you want reside.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricDefinitionsListAtSubscriptionScopeViaIdentity(global::System.String viaIdentity, string region, string metricnamespace, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/providers/Microsoft.Insights/metricDefinitions$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricDefinitions'");
+ }
+
+ // replace URI parameters with values from identity
+ var subscriptionId = _match.Groups["subscriptionId"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + subscriptionId
+ + "/providers/Microsoft.Insights/metricDefinitions"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricDefinitionsListAtSubscriptionScope_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ /// Lists the metric definitions for the subscription.
+ ///
+ /// The region where the metrics you want reside.
+ /// Metric namespace where the metrics you want reside.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricDefinitionsListAtSubscriptionScopeViaIdentityWithResult(global::System.String viaIdentity, string region, string metricnamespace, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/providers/Microsoft.Insights/metricDefinitions$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricDefinitions'");
+ }
+
+ // replace URI parameters with values from identity
+ var subscriptionId = _match.Groups["subscriptionId"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + subscriptionId
+ + "/providers/Microsoft.Insights/metricDefinitions"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricDefinitionsListAtSubscriptionScopeWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ /// Lists the metric definitions for the subscription.
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// Metric namespace where the metrics you want reside.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricDefinitionsListAtSubscriptionScopeWithResult(string subscriptionId, string region, string metricnamespace, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + global::System.Uri.EscapeDataString(subscriptionId)
+ + "/providers/Microsoft.Insights/metricDefinitions"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricDefinitionsListAtSubscriptionScopeWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ ///
+ /// Actual wire call for method.
+ ///
+ /// the prepared HttpRequestMessage to send.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricDefinitionsListAtSubscriptionScopeWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.SubscriptionScopeMetricDefinitionCollection.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ return await _result;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorContract.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ // Error Response : default
+ var code = (await _result)?.Code;
+ var message = (await _result)?.Message;
+ if ((null == code || null == message))
+ {
+ // Unrecognized Response. Create an error record based on what we have.
+ var ex = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.RestException(_response, await _result);
+ throw ex;
+ }
+ else
+ {
+ throw new global::System.Exception($"[{code}] : {message}");
+ }
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ ///
+ /// Actual wire call for method.
+ ///
+ /// the prepared HttpRequestMessage to send.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricDefinitionsListAtSubscriptionScope_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.SubscriptionScopeMetricDefinitionCollection.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorContract.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ ///
+ /// Validation method for method. Call this like the actual call,
+ /// but you will get validation events back.
+ ///
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// Metric namespace where the metrics you want reside.
+ /// an instance that will receive events.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricDefinitionsListAtSubscriptionScope_Validate(string subscriptionId, string region, string metricnamespace, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener)
+ {
+ using( NoSynchronizationContext )
+ {
+ await eventListener.AssertNotNull(nameof(subscriptionId),subscriptionId);
+ await eventListener.AssertMinimumLength(nameof(subscriptionId),subscriptionId,1);
+ await eventListener.AssertNotNull(nameof(region),region);
+ await eventListener.AssertNotNull(nameof(metricnamespace),metricnamespace);
+ }
+ }
+
+ /// Lists the metric definitions for the resource.
+ ///
+ /// Metric namespace where the metrics you want reside.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricDefinitionsListViaIdentity(global::System.String viaIdentity, string metricnamespace, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/(?[^/]+)/providers/Microsoft.Insights/metricDefinitions$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/{resourceUri}/providers/Microsoft.Insights/metricDefinitions'");
+ }
+
+ // replace URI parameters with values from identity
+ var resourceUri = _match.Groups["resourceUri"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/"
+ + resourceUri
+ + "/providers/Microsoft.Insights/metricDefinitions"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricDefinitionsList_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ /// Lists the metric definitions for the resource.
+ ///
+ /// Metric namespace where the metrics you want reside.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricDefinitionsListViaIdentityWithResult(global::System.String viaIdentity, string metricnamespace, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/(?[^/]+)/providers/Microsoft.Insights/metricDefinitions$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/{resourceUri}/providers/Microsoft.Insights/metricDefinitions'");
+ }
+
+ // replace URI parameters with values from identity
+ var resourceUri = _match.Groups["resourceUri"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/"
+ + resourceUri
+ + "/providers/Microsoft.Insights/metricDefinitions"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricDefinitionsListWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ /// Lists the metric definitions for the resource.
+ /// The identifier of the resource.
+ /// Metric namespace where the metrics you want reside.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricDefinitionsListWithResult(string resourceUri, string metricnamespace, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/"
+ + (resourceUri)
+ + "/providers/Microsoft.Insights/metricDefinitions"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricDefinitionsListWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ /// Actual wire call for method.
+ /// the prepared HttpRequestMessage to send.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricDefinitionsListWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricDefinitionCollection.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ return await _result;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ // Error Response : default
+ var code = (await _result)?.Code;
+ var message = (await _result)?.Message;
+ if ((null == code || null == message))
+ {
+ // Unrecognized Response. Create an error record based on what we have.
+ var ex = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.RestException(_response, await _result);
+ throw ex;
+ }
+ else
+ {
+ throw new global::System.Exception($"[{code}] : {message}");
+ }
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ /// Actual wire call for method.
+ /// the prepared HttpRequestMessage to send.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricDefinitionsList_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricDefinitionCollection.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ ///
+ /// Validation method for method. Call this like the actual call, but you will get validation
+ /// events back.
+ ///
+ /// The identifier of the resource.
+ /// Metric namespace where the metrics you want reside.
+ /// an instance that will receive events.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricDefinitionsList_Validate(string resourceUri, string metricnamespace, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener)
+ {
+ using( NoSynchronizationContext )
+ {
+ await eventListener.AssertNotNull(nameof(resourceUri),resourceUri);
+ await eventListener.AssertNotNull(nameof(metricnamespace),metricnamespace);
+ }
+ }
+
+ /// **Lists the metric values for a resource**.
+ /// The identifier of the resource.
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsList(string resourceUri, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/"
+ + (resourceUri)
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + (string.IsNullOrEmpty(timespan) ? global::System.String.Empty : "timespan=" + global::System.Uri.EscapeDataString(timespan))
+ + "&"
+ + (string.IsNullOrEmpty(interval) ? global::System.String.Empty : "interval=" + global::System.Uri.EscapeDataString(interval))
+ + "&"
+ + (string.IsNullOrEmpty(metricnames) ? global::System.String.Empty : "metricnames=" + global::System.Uri.EscapeDataString(metricnames))
+ + "&"
+ + (string.IsNullOrEmpty(aggregation) ? global::System.String.Empty : "aggregation=" + global::System.Uri.EscapeDataString(aggregation))
+ + "&"
+ + (null == top ? global::System.String.Empty : "top=" + global::System.Uri.EscapeDataString(top.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(orderby) ? global::System.String.Empty : "orderby=" + global::System.Uri.EscapeDataString(orderby))
+ + "&"
+ + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter))
+ + "&"
+ + (string.IsNullOrEmpty(resultType) ? global::System.String.Empty : "resultType=" + global::System.Uri.EscapeDataString(resultType))
+ + "&"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ + "&"
+ + (null == autoAdjustTimegrain ? global::System.String.Empty : "AutoAdjustTimegrain=" + global::System.Uri.EscapeDataString(autoAdjustTimegrain.ToString()))
+ + "&"
+ + (null == validateDimensions ? global::System.String.Empty : "ValidateDimensions=" + global::System.Uri.EscapeDataString(validateDimensions.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(rollupby) ? global::System.String.Empty : "rollupby=" + global::System.Uri.EscapeDataString(rollupby))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricsList_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ /// **Lists the metric data for a subscription**.
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScope(string subscriptionId, string region, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + global::System.Uri.EscapeDataString(subscriptionId)
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ + "&"
+ + (string.IsNullOrEmpty(timespan) ? global::System.String.Empty : "timespan=" + global::System.Uri.EscapeDataString(timespan))
+ + "&"
+ + (string.IsNullOrEmpty(interval) ? global::System.String.Empty : "interval=" + global::System.Uri.EscapeDataString(interval))
+ + "&"
+ + (string.IsNullOrEmpty(metricnames) ? global::System.String.Empty : "metricnames=" + global::System.Uri.EscapeDataString(metricnames))
+ + "&"
+ + (string.IsNullOrEmpty(aggregation) ? global::System.String.Empty : "aggregation=" + global::System.Uri.EscapeDataString(aggregation))
+ + "&"
+ + (null == top ? global::System.String.Empty : "top=" + global::System.Uri.EscapeDataString(top.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(orderby) ? global::System.String.Empty : "orderby=" + global::System.Uri.EscapeDataString(orderby))
+ + "&"
+ + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter))
+ + "&"
+ + (string.IsNullOrEmpty(resultType) ? global::System.String.Empty : "resultType=" + global::System.Uri.EscapeDataString(resultType))
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ + "&"
+ + (null == autoAdjustTimegrain ? global::System.String.Empty : "AutoAdjustTimegrain=" + global::System.Uri.EscapeDataString(autoAdjustTimegrain.ToString()))
+ + "&"
+ + (null == validateDimensions ? global::System.String.Empty : "ValidateDimensions=" + global::System.Uri.EscapeDataString(validateDimensions.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(rollupby) ? global::System.String.Empty : "rollupby=" + global::System.Uri.EscapeDataString(rollupby))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricsListAtSubscriptionScope_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ ///
+ /// **Lists the metric data for a subscription**. Parameters can be specified on either query params or the body.
+ ///
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// Parameters serialized in the body
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopePost(string subscriptionId, string region, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricsRequestBodyParameters body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeUpdate)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + global::System.Uri.EscapeDataString(subscriptionId)
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Post, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // set body content
+ request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null, serializationMode).ToString() : @"{}", global::System.Text.Encoding.UTF8);
+ request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricsListAtSubscriptionScopePost_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ ///
+ /// **Lists the metric data for a subscription**. Parameters can be specified on either query params or the body.
+ ///
+ ///
+ /// The region where the metrics you want reside.
+ /// Parameters serialized in the body
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopePostViaIdentity(global::System.String viaIdentity, string region, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricsRequestBodyParameters body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeUpdate)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/providers/Microsoft.Insights$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/providers/Microsoft.Insights'");
+ }
+
+ // replace URI parameters with values from identity
+ var subscriptionId = _match.Groups["subscriptionId"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + subscriptionId
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Post, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // set body content
+ request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null, serializationMode).ToString() : @"{}", global::System.Text.Encoding.UTF8);
+ request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricsListAtSubscriptionScopePost_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ ///
+ /// **Lists the metric data for a subscription**. Parameters can be specified on either query params or the body.
+ ///
+ ///
+ /// The region where the metrics you want reside.
+ /// Parameters serialized in the body
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopePostViaIdentityWithResult(global::System.String viaIdentity, string region, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricsRequestBodyParameters body, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeUpdate)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/providers/Microsoft.Insights$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/providers/Microsoft.Insights'");
+ }
+
+ // replace URI parameters with values from identity
+ var subscriptionId = _match.Groups["subscriptionId"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + subscriptionId
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Post, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // set body content
+ request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null, serializationMode).ToString() : @"{}", global::System.Text.Encoding.UTF8);
+ request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricsListAtSubscriptionScopePostWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ ///
+ /// **Lists the metric data for a subscription**. Parameters can be specified on either query params or the body.
+ ///
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// Json string supplied to the MetricsListAtSubscriptionScopePost operation
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopePostViaJsonString(string subscriptionId, string region, global::System.String jsonString, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + global::System.Uri.EscapeDataString(subscriptionId)
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Post, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // set body content
+ request.Content = new global::System.Net.Http.StringContent(jsonString, global::System.Text.Encoding.UTF8);
+ request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricsListAtSubscriptionScopePost_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ ///
+ /// **Lists the metric data for a subscription**. Parameters can be specified on either query params or the body.
+ ///
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// Json string supplied to the MetricsListAtSubscriptionScopePost operation
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopePostViaJsonStringWithResult(string subscriptionId, string region, global::System.String jsonString, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + global::System.Uri.EscapeDataString(subscriptionId)
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Post, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // set body content
+ request.Content = new global::System.Net.Http.StringContent(jsonString, global::System.Text.Encoding.UTF8);
+ request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricsListAtSubscriptionScopePostWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ ///
+ /// **Lists the metric data for a subscription**. Parameters can be specified on either query params or the body.
+ ///
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// Parameters serialized in the body
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopePostWithResult(string subscriptionId, string region, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricsRequestBodyParameters body, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeUpdate)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + global::System.Uri.EscapeDataString(subscriptionId)
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Post, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // set body content
+ request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null, serializationMode).ToString() : @"{}", global::System.Text.Encoding.UTF8);
+ request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricsListAtSubscriptionScopePostWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ ///
+ /// Actual wire call for method.
+ ///
+ /// the prepared HttpRequestMessage to send.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopePostWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Response.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ return await _result;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorContract.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ // Error Response : default
+ var code = (await _result)?.Code;
+ var message = (await _result)?.Message;
+ if ((null == code || null == message))
+ {
+ // Unrecognized Response. Create an error record based on what we have.
+ var ex = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.RestException(_response, await _result);
+ throw ex;
+ }
+ else
+ {
+ throw new global::System.Exception($"[{code}] : {message}");
+ }
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ /// Actual wire call for method.
+ /// the prepared HttpRequestMessage to send.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopePost_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Response.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorContract.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ ///
+ /// Validation method for method. Call this like the actual call, but you
+ /// will get validation events back.
+ ///
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// Parameters serialized in the body
+ /// an instance that will receive events.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopePost_Validate(string subscriptionId, string region, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricsRequestBodyParameters body, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener)
+ {
+ using( NoSynchronizationContext )
+ {
+ await eventListener.AssertNotNull(nameof(subscriptionId),subscriptionId);
+ await eventListener.AssertMinimumLength(nameof(subscriptionId),subscriptionId,1);
+ await eventListener.AssertNotNull(nameof(region),region);
+ await eventListener.AssertNotNull(nameof(body), body);
+ await eventListener.AssertObjectIsValid(nameof(body), body);
+ }
+ }
+
+ /// **Lists the metric data for a subscription**.
+ ///
+ /// The region where the metrics you want reside.
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopeViaIdentity(global::System.String viaIdentity, string region, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/providers/Microsoft.Insights/metrics$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics'");
+ }
+
+ // replace URI parameters with values from identity
+ var subscriptionId = _match.Groups["subscriptionId"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + subscriptionId
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ + "&"
+ + (string.IsNullOrEmpty(timespan) ? global::System.String.Empty : "timespan=" + global::System.Uri.EscapeDataString(timespan))
+ + "&"
+ + (string.IsNullOrEmpty(interval) ? global::System.String.Empty : "interval=" + global::System.Uri.EscapeDataString(interval))
+ + "&"
+ + (string.IsNullOrEmpty(metricnames) ? global::System.String.Empty : "metricnames=" + global::System.Uri.EscapeDataString(metricnames))
+ + "&"
+ + (string.IsNullOrEmpty(aggregation) ? global::System.String.Empty : "aggregation=" + global::System.Uri.EscapeDataString(aggregation))
+ + "&"
+ + (null == top ? global::System.String.Empty : "top=" + global::System.Uri.EscapeDataString(top.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(orderby) ? global::System.String.Empty : "orderby=" + global::System.Uri.EscapeDataString(orderby))
+ + "&"
+ + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter))
+ + "&"
+ + (string.IsNullOrEmpty(resultType) ? global::System.String.Empty : "resultType=" + global::System.Uri.EscapeDataString(resultType))
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ + "&"
+ + (null == autoAdjustTimegrain ? global::System.String.Empty : "AutoAdjustTimegrain=" + global::System.Uri.EscapeDataString(autoAdjustTimegrain.ToString()))
+ + "&"
+ + (null == validateDimensions ? global::System.String.Empty : "ValidateDimensions=" + global::System.Uri.EscapeDataString(validateDimensions.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(rollupby) ? global::System.String.Empty : "rollupby=" + global::System.Uri.EscapeDataString(rollupby))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricsListAtSubscriptionScope_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ /// **Lists the metric data for a subscription**.
+ ///
+ /// The region where the metrics you want reside.
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopeViaIdentityWithResult(global::System.String viaIdentity, string region, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/providers/Microsoft.Insights/metrics$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics'");
+ }
+
+ // replace URI parameters with values from identity
+ var subscriptionId = _match.Groups["subscriptionId"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + subscriptionId
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ + "&"
+ + (string.IsNullOrEmpty(timespan) ? global::System.String.Empty : "timespan=" + global::System.Uri.EscapeDataString(timespan))
+ + "&"
+ + (string.IsNullOrEmpty(interval) ? global::System.String.Empty : "interval=" + global::System.Uri.EscapeDataString(interval))
+ + "&"
+ + (string.IsNullOrEmpty(metricnames) ? global::System.String.Empty : "metricnames=" + global::System.Uri.EscapeDataString(metricnames))
+ + "&"
+ + (string.IsNullOrEmpty(aggregation) ? global::System.String.Empty : "aggregation=" + global::System.Uri.EscapeDataString(aggregation))
+ + "&"
+ + (null == top ? global::System.String.Empty : "top=" + global::System.Uri.EscapeDataString(top.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(orderby) ? global::System.String.Empty : "orderby=" + global::System.Uri.EscapeDataString(orderby))
+ + "&"
+ + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter))
+ + "&"
+ + (string.IsNullOrEmpty(resultType) ? global::System.String.Empty : "resultType=" + global::System.Uri.EscapeDataString(resultType))
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ + "&"
+ + (null == autoAdjustTimegrain ? global::System.String.Empty : "AutoAdjustTimegrain=" + global::System.Uri.EscapeDataString(autoAdjustTimegrain.ToString()))
+ + "&"
+ + (null == validateDimensions ? global::System.String.Empty : "ValidateDimensions=" + global::System.Uri.EscapeDataString(validateDimensions.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(rollupby) ? global::System.String.Empty : "rollupby=" + global::System.Uri.EscapeDataString(rollupby))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricsListAtSubscriptionScopeWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ /// **Lists the metric data for a subscription**.
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopeWithResult(string subscriptionId, string region, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/subscriptions/"
+ + global::System.Uri.EscapeDataString(subscriptionId)
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + "region=" + global::System.Uri.EscapeDataString(region)
+ + "&"
+ + (string.IsNullOrEmpty(timespan) ? global::System.String.Empty : "timespan=" + global::System.Uri.EscapeDataString(timespan))
+ + "&"
+ + (string.IsNullOrEmpty(interval) ? global::System.String.Empty : "interval=" + global::System.Uri.EscapeDataString(interval))
+ + "&"
+ + (string.IsNullOrEmpty(metricnames) ? global::System.String.Empty : "metricnames=" + global::System.Uri.EscapeDataString(metricnames))
+ + "&"
+ + (string.IsNullOrEmpty(aggregation) ? global::System.String.Empty : "aggregation=" + global::System.Uri.EscapeDataString(aggregation))
+ + "&"
+ + (null == top ? global::System.String.Empty : "top=" + global::System.Uri.EscapeDataString(top.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(orderby) ? global::System.String.Empty : "orderby=" + global::System.Uri.EscapeDataString(orderby))
+ + "&"
+ + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter))
+ + "&"
+ + (string.IsNullOrEmpty(resultType) ? global::System.String.Empty : "resultType=" + global::System.Uri.EscapeDataString(resultType))
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ + "&"
+ + (null == autoAdjustTimegrain ? global::System.String.Empty : "AutoAdjustTimegrain=" + global::System.Uri.EscapeDataString(autoAdjustTimegrain.ToString()))
+ + "&"
+ + (null == validateDimensions ? global::System.String.Empty : "ValidateDimensions=" + global::System.Uri.EscapeDataString(validateDimensions.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(rollupby) ? global::System.String.Empty : "rollupby=" + global::System.Uri.EscapeDataString(rollupby))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricsListAtSubscriptionScopeWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ ///
+ /// Actual wire call for method.
+ ///
+ /// the prepared HttpRequestMessage to send.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScopeWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Response.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ return await _result;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorContract.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ // Error Response : default
+ var code = (await _result)?.Code;
+ var message = (await _result)?.Message;
+ if ((null == code || null == message))
+ {
+ // Unrecognized Response. Create an error record based on what we have.
+ var ex = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.RestException(_response, await _result);
+ throw ex;
+ }
+ else
+ {
+ throw new global::System.Exception($"[{code}] : {message}");
+ }
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ /// Actual wire call for method.
+ /// the prepared HttpRequestMessage to send.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScope_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Response.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorContract.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ ///
+ /// Validation method for method. Call this like the actual call, but you will
+ /// get validation events back.
+ ///
+ /// The ID of the target subscription.
+ /// The region where the metrics you want reside.
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// an instance that will receive events.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricsListAtSubscriptionScope_Validate(string subscriptionId, string region, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener)
+ {
+ using( NoSynchronizationContext )
+ {
+ await eventListener.AssertNotNull(nameof(subscriptionId),subscriptionId);
+ await eventListener.AssertMinimumLength(nameof(subscriptionId),subscriptionId,1);
+ await eventListener.AssertNotNull(nameof(region),region);
+ await eventListener.AssertNotNull(nameof(timespan),timespan);
+ await eventListener.AssertNotNull(nameof(interval),interval);
+ await eventListener.AssertNotNull(nameof(metricnames),metricnames);
+ await eventListener.AssertNotNull(nameof(aggregation),aggregation);
+ await eventListener.AssertNotNull(nameof(orderby),orderby);
+ await eventListener.AssertNotNull(nameof(Filter),Filter);
+ await eventListener.AssertNotNull(nameof(resultType),resultType);
+ await eventListener.AssertNotNull(nameof(metricnamespace),metricnamespace);
+ await eventListener.AssertNotNull(nameof(rollupby),rollupby);
+ }
+ }
+
+ /// **Lists the metric values for a resource**.
+ ///
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListViaIdentity(global::System.String viaIdentity, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/(?[^/]+)/providers/Microsoft.Insights/metrics$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/{resourceUri}/providers/Microsoft.Insights/metrics'");
+ }
+
+ // replace URI parameters with values from identity
+ var resourceUri = _match.Groups["resourceUri"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/"
+ + resourceUri
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + (string.IsNullOrEmpty(timespan) ? global::System.String.Empty : "timespan=" + global::System.Uri.EscapeDataString(timespan))
+ + "&"
+ + (string.IsNullOrEmpty(interval) ? global::System.String.Empty : "interval=" + global::System.Uri.EscapeDataString(interval))
+ + "&"
+ + (string.IsNullOrEmpty(metricnames) ? global::System.String.Empty : "metricnames=" + global::System.Uri.EscapeDataString(metricnames))
+ + "&"
+ + (string.IsNullOrEmpty(aggregation) ? global::System.String.Empty : "aggregation=" + global::System.Uri.EscapeDataString(aggregation))
+ + "&"
+ + (null == top ? global::System.String.Empty : "top=" + global::System.Uri.EscapeDataString(top.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(orderby) ? global::System.String.Empty : "orderby=" + global::System.Uri.EscapeDataString(orderby))
+ + "&"
+ + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter))
+ + "&"
+ + (string.IsNullOrEmpty(resultType) ? global::System.String.Empty : "resultType=" + global::System.Uri.EscapeDataString(resultType))
+ + "&"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ + "&"
+ + (null == autoAdjustTimegrain ? global::System.String.Empty : "AutoAdjustTimegrain=" + global::System.Uri.EscapeDataString(autoAdjustTimegrain.ToString()))
+ + "&"
+ + (null == validateDimensions ? global::System.String.Empty : "ValidateDimensions=" + global::System.Uri.EscapeDataString(validateDimensions.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(rollupby) ? global::System.String.Empty : "rollupby=" + global::System.Uri.EscapeDataString(rollupby))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
+ // make the call
+ await this.MetricsList_Call (request, onOk,onDefault,eventListener,sender);
+ }
+ }
+
+ /// **Lists the metric values for a resource**.
+ ///
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListViaIdentityWithResult(global::System.String viaIdentity, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // verify that Identity format is an exact match for uri
+
+ var _match = new global::System.Text.RegularExpressions.Regex("^/(?[^/]+)/providers/Microsoft.Insights/metrics$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity);
+ if (!_match.Success)
+ {
+ throw new global::System.Exception("Invalid identity for URI '/{resourceUri}/providers/Microsoft.Insights/metrics'");
+ }
+
+ // replace URI parameters with values from identity
+ var resourceUri = _match.Groups["resourceUri"].Value;
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/"
+ + resourceUri
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + (string.IsNullOrEmpty(timespan) ? global::System.String.Empty : "timespan=" + global::System.Uri.EscapeDataString(timespan))
+ + "&"
+ + (string.IsNullOrEmpty(interval) ? global::System.String.Empty : "interval=" + global::System.Uri.EscapeDataString(interval))
+ + "&"
+ + (string.IsNullOrEmpty(metricnames) ? global::System.String.Empty : "metricnames=" + global::System.Uri.EscapeDataString(metricnames))
+ + "&"
+ + (string.IsNullOrEmpty(aggregation) ? global::System.String.Empty : "aggregation=" + global::System.Uri.EscapeDataString(aggregation))
+ + "&"
+ + (null == top ? global::System.String.Empty : "top=" + global::System.Uri.EscapeDataString(top.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(orderby) ? global::System.String.Empty : "orderby=" + global::System.Uri.EscapeDataString(orderby))
+ + "&"
+ + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter))
+ + "&"
+ + (string.IsNullOrEmpty(resultType) ? global::System.String.Empty : "resultType=" + global::System.Uri.EscapeDataString(resultType))
+ + "&"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ + "&"
+ + (null == autoAdjustTimegrain ? global::System.String.Empty : "AutoAdjustTimegrain=" + global::System.Uri.EscapeDataString(autoAdjustTimegrain.ToString()))
+ + "&"
+ + (null == validateDimensions ? global::System.String.Empty : "ValidateDimensions=" + global::System.Uri.EscapeDataString(validateDimensions.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(rollupby) ? global::System.String.Empty : "rollupby=" + global::System.Uri.EscapeDataString(rollupby))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricsListWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ /// **Lists the metric values for a resource**.
+ /// The identifier of the resource.
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ public async global::System.Threading.Tasks.Task MetricsListWithResult(string resourceUri, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ var apiVersion = @"2023-10-01";
+ // Constant Parameters
+ using( NoSynchronizationContext )
+ {
+ // construct URL
+ var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
+ "/"
+ + (resourceUri)
+ + "/providers/Microsoft.Insights/metrics"
+ + "?"
+ + (string.IsNullOrEmpty(timespan) ? global::System.String.Empty : "timespan=" + global::System.Uri.EscapeDataString(timespan))
+ + "&"
+ + (string.IsNullOrEmpty(interval) ? global::System.String.Empty : "interval=" + global::System.Uri.EscapeDataString(interval))
+ + "&"
+ + (string.IsNullOrEmpty(metricnames) ? global::System.String.Empty : "metricnames=" + global::System.Uri.EscapeDataString(metricnames))
+ + "&"
+ + (string.IsNullOrEmpty(aggregation) ? global::System.String.Empty : "aggregation=" + global::System.Uri.EscapeDataString(aggregation))
+ + "&"
+ + (null == top ? global::System.String.Empty : "top=" + global::System.Uri.EscapeDataString(top.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(orderby) ? global::System.String.Empty : "orderby=" + global::System.Uri.EscapeDataString(orderby))
+ + "&"
+ + (string.IsNullOrEmpty(Filter) ? global::System.String.Empty : "$filter=" + global::System.Uri.EscapeDataString(Filter))
+ + "&"
+ + (string.IsNullOrEmpty(resultType) ? global::System.String.Empty : "resultType=" + global::System.Uri.EscapeDataString(resultType))
+ + "&"
+ + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
+ + "&"
+ + (string.IsNullOrEmpty(metricnamespace) ? global::System.String.Empty : "metricnamespace=" + global::System.Uri.EscapeDataString(metricnamespace))
+ + "&"
+ + (null == autoAdjustTimegrain ? global::System.String.Empty : "AutoAdjustTimegrain=" + global::System.Uri.EscapeDataString(autoAdjustTimegrain.ToString()))
+ + "&"
+ + (null == validateDimensions ? global::System.String.Empty : "ValidateDimensions=" + global::System.Uri.EscapeDataString(validateDimensions.ToString()))
+ + "&"
+ + (string.IsNullOrEmpty(rollupby) ? global::System.String.Empty : "rollupby=" + global::System.Uri.EscapeDataString(rollupby))
+ ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ // generate request object
+ var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
+ var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Method.Get, _url);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; }
+
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ // make the call
+ return await this.MetricsListWithResult_Call (request, eventListener,sender);
+ }
+ }
+
+ /// Actual wire call for method.
+ /// the prepared HttpRequestMessage to send.
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that
+ /// will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricsListWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Response.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ return await _result;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; }
+ var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) );
+ // Error Response : default
+ var code = (await _result)?.Code;
+ var message = (await _result)?.Message;
+ if ((null == code || null == message))
+ {
+ // Unrecognized Response. Create an error record based on what we have.
+ var ex = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.RestException(_response, await _result);
+ throw ex;
+ }
+ else
+ {
+ throw new global::System.Exception($"[{code}] : {message}");
+ }
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ /// Actual wire call for method.
+ /// the prepared HttpRequestMessage to send.
+ /// a delegate that is called when the remote service returns 200 (OK).
+ /// a delegate that is called when the remote service returns default (any response code not handled
+ /// elsewhere).
+ /// an instance that will receive events.
+ /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync pipeline to use to make the request.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricsList_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.ISendAsync sender)
+ {
+ using( NoSynchronizationContext )
+ {
+ global::System.Net.Http.HttpResponseMessage _response = null;
+ try
+ {
+ var sendTask = sender.SendAsync(request, eventListener);
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; }
+ _response = await sendTask;
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; }
+ var _contentType = _response.Content.Headers.ContentType?.MediaType;
+
+ switch ( _response.StatusCode )
+ {
+ case global::System.Net.HttpStatusCode.OK:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Response.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ default:
+ {
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; }
+ await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(body.Result)) ));
+ break;
+ }
+ }
+ }
+ finally
+ {
+ // finally statements
+ await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Events.Finally, request, _response);
+ _response?.Dispose();
+ request?.Dispose();
+ }
+ }
+ }
+
+ ///
+ /// Validation method for method. Call this like the actual call, but you will get validation events
+ /// back.
+ ///
+ /// The identifier of the resource.
+ /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
+ /// The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special
+ /// case for 'FULL' value that returns single datapoint for entire time span requested.
+ /// *Examples: PT15M, PT1H, P1D, FULL*
+ /// The names of the metrics (comma separated) to retrieve.
+ /// The list of aggregation types (comma separated) to retrieve.
+ /// *Examples: average, minimum, maximum*
+ /// The maximum number of records to retrieve per resource ID in the request.
+ /// Valid only if filter is specified.
+ /// Defaults to 10.
+ /// The aggregation to use for sorting results and the direction of the sort.
+ /// Only one order can be specified.
+ /// *Examples: sum asc*
+ /// The **$filter** is used to reduce the set of metric data returned. Example: Metric contains
+ /// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq ‘a1’ and B eq ‘b1’
+ /// or B eq ‘b2’ and C eq ‘*’** - Invalid variant: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’** This
+ /// is invalid because the logical or operator cannot separate two different metadata names. - Return all time series where
+ /// A = a1, B = b1 and C = c1: **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’** - Return all time series where A =
+ /// a1 **$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
+ /// Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's
+ /// description for details.
+ /// Metric namespace where the metrics you want reside.
+ /// When set to true, if the timespan passed in is not supported by this metric, the API
+ /// will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan
+ /// parameters. Defaults to false.
+ /// When set to false, invalid filter parameter values will be ignored. When set to true,
+ /// an error is returned for invalid filter parameters. Defaults to true.
+ /// Dimension name(s) to rollup results by. For example if you only want to see metric values with
+ /// a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify
+ /// 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
+ /// an instance that will receive events.
+ ///
+ /// A that will be complete when handling of the response is completed.
+ ///
+ internal async global::System.Threading.Tasks.Task MetricsList_Validate(string resourceUri, string timespan, string interval, string metricnames, string aggregation, int? top, string orderby, string Filter, string resultType, string metricnamespace, bool? autoAdjustTimegrain, bool? validateDimensions, string rollupby, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IEventListener eventListener)
+ {
+ using( NoSynchronizationContext )
+ {
+ await eventListener.AssertNotNull(nameof(resourceUri),resourceUri);
+ await eventListener.AssertNotNull(nameof(timespan),timespan);
+ await eventListener.AssertNotNull(nameof(interval),interval);
+ await eventListener.AssertNotNull(nameof(metricnames),metricnames);
+ await eventListener.AssertNotNull(nameof(aggregation),aggregation);
+ await eventListener.AssertNotNull(nameof(orderby),orderby);
+ await eventListener.AssertNotNull(nameof(Filter),Filter);
+ await eventListener.AssertNotNull(nameof(resultType),resultType);
+ await eventListener.AssertNotNull(nameof(metricnamespace),metricnamespace);
+ await eventListener.AssertNotNull(nameof(rollupby),rollupby);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Any.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Any.PowerShell.cs
new file mode 100644
index 000000000000..cb6c32812774
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Any.PowerShell.cs
@@ -0,0 +1,156 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// Anything
+ [System.ComponentModel.TypeConverter(typeof(AnyTypeConverter))]
+ public partial class Any
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal Any(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal Any(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ AfterDeserializePSObject(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new Any(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new Any(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// Anything
+ [System.ComponentModel.TypeConverter(typeof(AnyTypeConverter))]
+ public partial interface IAny
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Any.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Any.TypeConverter.cs
new file mode 100644
index 000000000000..7fb3ceba7860
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Any.TypeConverter.cs
@@ -0,0 +1,146 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class AnyTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return Any.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return Any.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return Any.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Any.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Any.cs
new file mode 100644
index 000000000000..ad7965d6f27a
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Any.cs
@@ -0,0 +1,34 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Anything
+ public partial class Any :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAnyInternal
+ {
+
+ /// Creates an new instance.
+ public Any()
+ {
+
+ }
+ }
+ /// Anything
+ public partial interface IAny :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+
+ }
+ /// Anything
+ internal partial interface IAnyInternal
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Any.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Any.json.cs
new file mode 100644
index 000000000000..ad56dde32d23
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Any.json.cs
@@ -0,0 +1,104 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Anything
+ public partial class Any
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal Any(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny.
+ ///
+ /// a to deserialize from.
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new Any(json) : null;
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.PowerShell.cs
new file mode 100644
index 000000000000..721291c66ca2
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.PowerShell.cs
@@ -0,0 +1,172 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// The resource management error additional info.
+ [System.ComponentModel.TypeConverter(typeof(ErrorAdditionalInfoTypeConverter))]
+ public partial class ErrorAdditionalInfo
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new ErrorAdditionalInfo(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new ErrorAdditionalInfo(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal ErrorAdditionalInfo(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Type"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal)this).Type, global::System.Convert.ToString);
+ }
+ if (content.Contains("Info"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal)this).Info = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny) content.GetValueForProperty("Info",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal)this).Info, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.AnyTypeConverter.ConvertFrom);
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal ErrorAdditionalInfo(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Type"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal)this).Type, global::System.Convert.ToString);
+ }
+ if (content.Contains("Info"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal)this).Info = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny) content.GetValueForProperty("Info",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal)this).Info, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.AnyTypeConverter.ConvertFrom);
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// The resource management error additional info.
+ [System.ComponentModel.TypeConverter(typeof(ErrorAdditionalInfoTypeConverter))]
+ public partial interface IErrorAdditionalInfo
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.TypeConverter.cs
new file mode 100644
index 000000000000..eaef54056d6c
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.TypeConverter.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class ErrorAdditionalInfoTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return ErrorAdditionalInfo.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return ErrorAdditionalInfo.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return ErrorAdditionalInfo.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.cs
new file mode 100644
index 000000000000..14aff86a9d3a
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.cs
@@ -0,0 +1,80 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// The resource management error additional info.
+ public partial class ErrorAdditionalInfo :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal
+ {
+
+ /// Backing field for property.
+ private Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny _info;
+
+ /// The additional info.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny Info { get => (this._info = this._info ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Any()); }
+
+ /// Internal Acessors for Info
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal.Info { get => (this._info = this._info ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Any()); set { {_info = value;} } }
+
+ /// Internal Acessors for Type
+ string Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfoInternal.Type { get => this._type; set { {_type = value;} } }
+
+ /// Backing field for property.
+ private string _type;
+
+ /// The additional info type.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Type { get => this._type; }
+
+ /// Creates an new instance.
+ public ErrorAdditionalInfo()
+ {
+
+ }
+ }
+ /// The resource management error additional info.
+ public partial interface IErrorAdditionalInfo :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// The additional info.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The additional info.",
+ SerializedName = @"info",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny) })]
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny Info { get; }
+ /// The additional info type.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The additional info type.",
+ SerializedName = @"type",
+ PossibleTypes = new [] { typeof(string) })]
+ string Type { get; }
+
+ }
+ /// The resource management error additional info.
+ internal partial interface IErrorAdditionalInfoInternal
+
+ {
+ /// The additional info.
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IAny Info { get; set; }
+ /// The additional info type.
+ string Type { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.json.cs
new file mode 100644
index 000000000000..9b3f8b01c5d8
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorAdditionalInfo.json.cs
@@ -0,0 +1,116 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// The resource management error additional info.
+ public partial class ErrorAdditionalInfo
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal ErrorAdditionalInfo(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)_type;}
+ {_info = If( json?.PropertyT("info"), out var __jsonInfo) ? Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Any.FromJson(__jsonInfo) : _info;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo.
+ ///
+ /// a to deserialize from.
+ ///
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new ErrorAdditionalInfo(json) : null;
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeRead))
+ {
+ AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add );
+ }
+ if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeRead))
+ {
+ AddIf( null != this._info ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) this._info.ToJson(null,serializationMode) : null, "info" ,container.Add );
+ }
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.PowerShell.cs
new file mode 100644
index 000000000000..0246a49f6f97
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.PowerShell.cs
@@ -0,0 +1,208 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ ///
+ [System.ComponentModel.TypeConverter(typeof(ErrorContractTypeConverter))]
+ public partial class ErrorContract
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContract DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new ErrorContract(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContract DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new ErrorContract(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal ErrorContract(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Error"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponseTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("Code"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Code, global::System.Convert.ToString);
+ }
+ if (content.Contains("Message"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Message, global::System.Convert.ToString);
+ }
+ if (content.Contains("Target"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Target = (string) content.GetValueForProperty("Target",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Target, global::System.Convert.ToString);
+ }
+ if (content.Contains("Detail"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Detail = (System.Collections.Generic.List) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Detail, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponseTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("AdditionalInfo"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).AdditionalInfo = (System.Collections.Generic.List) content.GetValueForProperty("AdditionalInfo",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).AdditionalInfo, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorAdditionalInfoTypeConverter.ConvertFrom));
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal ErrorContract(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Error"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponseTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("Code"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Code, global::System.Convert.ToString);
+ }
+ if (content.Contains("Message"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Message, global::System.Convert.ToString);
+ }
+ if (content.Contains("Target"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Target = (string) content.GetValueForProperty("Target",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Target, global::System.Convert.ToString);
+ }
+ if (content.Contains("Detail"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Detail = (System.Collections.Generic.List) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).Detail, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponseTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("AdditionalInfo"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).AdditionalInfo = (System.Collections.Generic.List) content.GetValueForProperty("AdditionalInfo",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal)this).AdditionalInfo, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorAdditionalInfoTypeConverter.ConvertFrom));
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContract FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ [System.ComponentModel.TypeConverter(typeof(ErrorContractTypeConverter))]
+ public partial interface IErrorContract
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.TypeConverter.cs
new file mode 100644
index 000000000000..469b9e93ddae
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.TypeConverter.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class ErrorContractTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContract ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContract).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return ErrorContract.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return ErrorContract.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return ErrorContract.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.cs
new file mode 100644
index 000000000000..4bfb3eebff45
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.cs
@@ -0,0 +1,151 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ ///
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ ///
+ public partial class ErrorContract :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContract,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal
+ {
+
+ /// The error additional info.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public System.Collections.Generic.List AdditionalInfo { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).AdditionalInfo; }
+
+ /// The error code.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public string Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Code; }
+
+ /// The error details.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public System.Collections.Generic.List Detail { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Detail; }
+
+ /// Backing field for property.
+ private Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse _error;
+
+ /// The error object.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ internal Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse()); set => this._error = value; }
+
+ /// The error message.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public string Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Message; }
+
+ /// Internal Acessors for AdditionalInfo
+ System.Collections.Generic.List Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal.AdditionalInfo { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).AdditionalInfo; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).AdditionalInfo = value; }
+
+ /// Internal Acessors for Code
+ string Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal.Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Code; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Code = value; }
+
+ /// Internal Acessors for Detail
+ System.Collections.Generic.List Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal.Detail { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Detail; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Detail = value; }
+
+ /// Internal Acessors for Error
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal.Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse()); set { {_error = value;} } }
+
+ /// Internal Acessors for Message
+ string Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal.Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Message; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Message = value; }
+
+ /// Internal Acessors for Target
+ string Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContractInternal.Target { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Target; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Target = value; }
+
+ /// The error target.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public string Target { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)Error).Target; }
+
+ /// Creates an new instance.
+ public ErrorContract()
+ {
+
+ }
+ }
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ public partial interface IErrorContract :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// The error additional info.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error additional info.",
+ SerializedName = @"additionalInfo",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo) })]
+ System.Collections.Generic.List AdditionalInfo { get; }
+ /// The error code.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error code.",
+ SerializedName = @"code",
+ PossibleTypes = new [] { typeof(string) })]
+ string Code { get; }
+ /// The error details.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error details.",
+ SerializedName = @"details",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse) })]
+ System.Collections.Generic.List Detail { get; }
+ /// The error message.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error message.",
+ SerializedName = @"message",
+ PossibleTypes = new [] { typeof(string) })]
+ string Message { get; }
+ /// The error target.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error target.",
+ SerializedName = @"target",
+ PossibleTypes = new [] { typeof(string) })]
+ string Target { get; }
+
+ }
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ internal partial interface IErrorContractInternal
+
+ {
+ /// The error additional info.
+ System.Collections.Generic.List AdditionalInfo { get; set; }
+ /// The error code.
+ string Code { get; set; }
+ /// The error details.
+ System.Collections.Generic.List Detail { get; set; }
+ /// The error object.
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse Error { get; set; }
+ /// The error message.
+ string Message { get; set; }
+ /// The error target.
+ string Target { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.json.cs
new file mode 100644
index 000000000000..6b936355b1a4
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorContract.json.cs
@@ -0,0 +1,109 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ ///
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ ///
+ public partial class ErrorContract
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal ErrorContract(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_error = If( json?.PropertyT("error"), out var __jsonError) ? Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse.FromJson(__jsonError) : _error;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContract.
+ ///
+ /// a to deserialize from.
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContract.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorContract FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new ErrorContract(json) : null;
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AddIf( null != this._error ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) this._error.ToJson(null,serializationMode) : null, "error" ,container.Add );
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.PowerShell.cs
new file mode 100644
index 000000000000..7ab0ed02ccb9
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.PowerShell.cs
@@ -0,0 +1,200 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ ///
+ [System.ComponentModel.TypeConverter(typeof(ErrorResponseTypeConverter))]
+ public partial class ErrorResponse
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new ErrorResponse(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new ErrorResponse(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal ErrorResponse(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Code"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Code, global::System.Convert.ToString);
+ }
+ if (content.Contains("Message"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Message, global::System.Convert.ToString);
+ }
+ if (content.Contains("Target"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Target = (string) content.GetValueForProperty("Target",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Target, global::System.Convert.ToString);
+ }
+ if (content.Contains("Detail"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Detail = (System.Collections.Generic.List) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponseTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("AdditionalInfo"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).AdditionalInfo = (System.Collections.Generic.List) content.GetValueForProperty("AdditionalInfo",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).AdditionalInfo, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorAdditionalInfoTypeConverter.ConvertFrom));
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal ErrorResponse(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Code"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Code, global::System.Convert.ToString);
+ }
+ if (content.Contains("Message"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Message, global::System.Convert.ToString);
+ }
+ if (content.Contains("Target"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Target = (string) content.GetValueForProperty("Target",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Target, global::System.Convert.ToString);
+ }
+ if (content.Contains("Detail"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Detail = (System.Collections.Generic.List) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponseTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("AdditionalInfo"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).AdditionalInfo = (System.Collections.Generic.List) content.GetValueForProperty("AdditionalInfo",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal)this).AdditionalInfo, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorAdditionalInfoTypeConverter.ConvertFrom));
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ [System.ComponentModel.TypeConverter(typeof(ErrorResponseTypeConverter))]
+ public partial interface IErrorResponse
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.TypeConverter.cs
new file mode 100644
index 000000000000..f173dc22c153
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.TypeConverter.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class ErrorResponseTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return ErrorResponse.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return ErrorResponse.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return ErrorResponse.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.cs
new file mode 100644
index 000000000000..41a306930003
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.cs
@@ -0,0 +1,154 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ ///
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ ///
+ public partial class ErrorResponse :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal
+ {
+
+ /// Backing field for property.
+ private System.Collections.Generic.List _additionalInfo;
+
+ /// The error additional info.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public System.Collections.Generic.List AdditionalInfo { get => this._additionalInfo; }
+
+ /// Backing field for property.
+ private string _code;
+
+ /// The error code.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Code { get => this._code; }
+
+ /// Backing field for property.
+ private System.Collections.Generic.List _detail;
+
+ /// The error details.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public System.Collections.Generic.List Detail { get => this._detail; }
+
+ /// Backing field for property.
+ private string _message;
+
+ /// The error message.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Message { get => this._message; }
+
+ /// Internal Acessors for AdditionalInfo
+ System.Collections.Generic.List Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal.AdditionalInfo { get => this._additionalInfo; set { {_additionalInfo = value;} } }
+
+ /// Internal Acessors for Code
+ string Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal.Code { get => this._code; set { {_code = value;} } }
+
+ /// Internal Acessors for Detail
+ System.Collections.Generic.List Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal.Detail { get => this._detail; set { {_detail = value;} } }
+
+ /// Internal Acessors for Message
+ string Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal.Message { get => this._message; set { {_message = value;} } }
+
+ /// Internal Acessors for Target
+ string Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponseInternal.Target { get => this._target; set { {_target = value;} } }
+
+ /// Backing field for property.
+ private string _target;
+
+ /// The error target.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Target { get => this._target; }
+
+ /// Creates an new instance.
+ public ErrorResponse()
+ {
+
+ }
+ }
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ public partial interface IErrorResponse :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// The error additional info.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error additional info.",
+ SerializedName = @"additionalInfo",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo) })]
+ System.Collections.Generic.List AdditionalInfo { get; }
+ /// The error code.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error code.",
+ SerializedName = @"code",
+ PossibleTypes = new [] { typeof(string) })]
+ string Code { get; }
+ /// The error details.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error details.",
+ SerializedName = @"details",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse) })]
+ System.Collections.Generic.List Detail { get; }
+ /// The error message.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error message.",
+ SerializedName = @"message",
+ PossibleTypes = new [] { typeof(string) })]
+ string Message { get; }
+ /// The error target.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = true,
+ Read = true,
+ Create = false,
+ Update = false,
+ Description = @"The error target.",
+ SerializedName = @"target",
+ PossibleTypes = new [] { typeof(string) })]
+ string Target { get; }
+
+ }
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ internal partial interface IErrorResponseInternal
+
+ {
+ /// The error additional info.
+ System.Collections.Generic.List AdditionalInfo { get; set; }
+ /// The error code.
+ string Code { get; set; }
+ /// The error details.
+ System.Collections.Generic.List Detail { get; set; }
+ /// The error message.
+ string Message { get; set; }
+ /// The error target.
+ string Target { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.json.cs
new file mode 100644
index 000000000000..ae018b7206a7
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/ErrorResponse.json.cs
@@ -0,0 +1,148 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ ///
+ /// Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows
+ /// the OData error response format.)
+ ///
+ public partial class ErrorResponse
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal ErrorResponse(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_code = If( json?.PropertyT("code"), out var __jsonCode) ? (string)__jsonCode : (string)_code;}
+ {_message = If( json?.PropertyT("message"), out var __jsonMessage) ? (string)__jsonMessage : (string)_message;}
+ {_target = If( json?.PropertyT("target"), out var __jsonTarget) ? (string)__jsonTarget : (string)_target;}
+ {_detail = If( json?.PropertyT("details"), out var __jsonDetails) ? If( __jsonDetails as Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonArray, out var __v) ? new global::System.Func>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse) (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorResponse.FromJson(__u) )) ))() : null : _detail;}
+ {_additionalInfo = If( json?.PropertyT("additionalInfo"), out var __jsonAdditionalInfo) ? If( __jsonAdditionalInfo as Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonArray, out var __q) ? new global::System.Func>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__q, (__p)=>(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorAdditionalInfo) (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ErrorAdditionalInfo.FromJson(__p) )) ))() : null : _additionalInfo;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse.
+ ///
+ /// a to deserialize from.
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IErrorResponse FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new ErrorResponse(json) : null;
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeRead))
+ {
+ AddIf( null != (((object)this._code)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._code.ToString()) : null, "code" ,container.Add );
+ }
+ if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeRead))
+ {
+ AddIf( null != (((object)this._message)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._message.ToString()) : null, "message" ,container.Add );
+ }
+ if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeRead))
+ {
+ AddIf( null != (((object)this._target)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._target.ToString()) : null, "target" ,container.Add );
+ }
+ if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeRead))
+ {
+ if (null != this._detail)
+ {
+ var __w = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.XNodeArray();
+ foreach( var __x in this._detail )
+ {
+ AddIf(__x?.ToJson(null, serializationMode) ,__w.Add);
+ }
+ container.Add("details",__w);
+ }
+ }
+ if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeRead))
+ {
+ if (null != this._additionalInfo)
+ {
+ var __r = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.XNodeArray();
+ foreach( var __s in this._additionalInfo )
+ {
+ AddIf(__s?.ToJson(null, serializationMode) ,__r.Add);
+ }
+ container.Add("additionalInfo",__r);
+ }
+ }
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.PowerShell.cs
new file mode 100644
index 000000000000..10244dedc9f4
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.PowerShell.cs
@@ -0,0 +1,172 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// The localizable string class.
+ [System.ComponentModel.TypeConverter(typeof(LocalizableStringTypeConverter))]
+ public partial class LocalizableString
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new LocalizableString(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new LocalizableString(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal LocalizableString(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Value"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)this).Value = (string) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)this).Value, global::System.Convert.ToString);
+ }
+ if (content.Contains("LocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)this).LocalizedValue = (string) content.GetValueForProperty("LocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)this).LocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal LocalizableString(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Value"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)this).Value = (string) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)this).Value, global::System.Convert.ToString);
+ }
+ if (content.Contains("LocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)this).LocalizedValue = (string) content.GetValueForProperty("LocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)this).LocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// The localizable string class.
+ [System.ComponentModel.TypeConverter(typeof(LocalizableStringTypeConverter))]
+ public partial interface ILocalizableString
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.TypeConverter.cs
new file mode 100644
index 000000000000..9ae921946911
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.TypeConverter.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class LocalizableStringTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return LocalizableString.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return LocalizableString.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return LocalizableString.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.cs b/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.cs
new file mode 100644
index 000000000000..5535ff44e285
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.cs
@@ -0,0 +1,74 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// The localizable string class.
+ public partial class LocalizableString :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal
+ {
+
+ /// Backing field for property.
+ private string _localizedValue;
+
+ /// The display name.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string LocalizedValue { get => this._localizedValue; set => this._localizedValue = value; }
+
+ /// Backing field for property.
+ private string _value;
+
+ /// The invariant value.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Value { get => this._value; set => this._value = value; }
+
+ /// Creates an new instance.
+ public LocalizableString()
+ {
+
+ }
+ }
+ /// The localizable string class.
+ public partial interface ILocalizableString :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// The display name.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The display name.",
+ SerializedName = @"localizedValue",
+ PossibleTypes = new [] { typeof(string) })]
+ string LocalizedValue { get; set; }
+ /// The invariant value.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The invariant value.",
+ SerializedName = @"value",
+ PossibleTypes = new [] { typeof(string) })]
+ string Value { get; set; }
+
+ }
+ /// The localizable string class.
+ internal partial interface ILocalizableStringInternal
+
+ {
+ /// The display name.
+ string LocalizedValue { get; set; }
+ /// The invariant value.
+ string Value { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.json.cs
new file mode 100644
index 000000000000..dc05fada26f8
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/LocalizableString.json.cs
@@ -0,0 +1,110 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// The localizable string class.
+ public partial class LocalizableString
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString.
+ ///
+ /// a to deserialize from.
+ ///
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new LocalizableString(json) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal LocalizableString(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_value = If( json?.PropertyT("value"), out var __jsonValue) ? (string)__jsonValue : (string)_value;}
+ {_localizedValue = If( json?.PropertyT("localizedValue"), out var __jsonLocalizedValue) ? (string)__jsonLocalizedValue : (string)_localizedValue;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AddIf( null != (((object)this._value)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._value.ToString()) : null, "value" ,container.Add );
+ AddIf( null != (((object)this._localizedValue)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._localizedValue.ToString()) : null, "localizedValue" ,container.Add );
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.PowerShell.cs
new file mode 100644
index 000000000000..3fa351cf471b
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.PowerShell.cs
@@ -0,0 +1,188 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// Represents a metric metadata value.
+ [System.ComponentModel.TypeConverter(typeof(MetadataValueTypeConverter))]
+ public partial class MetadataValue
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValue DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new MetadataValue(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValue DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new MetadataValue(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValue FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal MetadataValue(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Name"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).Name = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).Name, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("Value"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).Value = (string) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).Value, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).NameValue = (string) content.GetValueForProperty("NameValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).NameValue, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameLocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).NameLocalizedValue = (string) content.GetValueForProperty("NameLocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).NameLocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal MetadataValue(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Name"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).Name = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).Name, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("Value"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).Value = (string) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).Value, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).NameValue = (string) content.GetValueForProperty("NameValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).NameValue, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameLocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).NameLocalizedValue = (string) content.GetValueForProperty("NameLocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal)this).NameLocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// Represents a metric metadata value.
+ [System.ComponentModel.TypeConverter(typeof(MetadataValueTypeConverter))]
+ public partial interface IMetadataValue
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.TypeConverter.cs
new file mode 100644
index 000000000000..414b19adc1a6
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.TypeConverter.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class MetadataValueTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValue ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValue).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return MetadataValue.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return MetadataValue.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return MetadataValue.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.cs
new file mode 100644
index 000000000000..66d38027901a
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.cs
@@ -0,0 +1,100 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Represents a metric metadata value.
+ public partial class MetadataValue :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValue,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal
+ {
+
+ /// Internal Acessors for Name
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValueInternal.Name { get => (this._name = this._name ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString()); set { {_name = value;} } }
+
+ /// Backing field for property.
+ private Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString _name;
+
+ /// The name of the metadata.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ internal Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString Name { get => (this._name = this._name ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString()); set => this._name = value; }
+
+ /// The display name.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public string NameLocalizedValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).LocalizedValue; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).LocalizedValue = value ?? null; }
+
+ /// The invariant value.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public string NameValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).Value; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).Value = value ?? null; }
+
+ /// Backing field for property.
+ private string _value;
+
+ /// The value of the metadata.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Value { get => this._value; set => this._value = value; }
+
+ /// Creates an new instance.
+ public MetadataValue()
+ {
+
+ }
+ }
+ /// Represents a metric metadata value.
+ public partial interface IMetadataValue :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// The display name.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The display name.",
+ SerializedName = @"localizedValue",
+ PossibleTypes = new [] { typeof(string) })]
+ string NameLocalizedValue { get; set; }
+ /// The invariant value.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The invariant value.",
+ SerializedName = @"value",
+ PossibleTypes = new [] { typeof(string) })]
+ string NameValue { get; set; }
+ /// The value of the metadata.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The value of the metadata.",
+ SerializedName = @"value",
+ PossibleTypes = new [] { typeof(string) })]
+ string Value { get; set; }
+
+ }
+ /// Represents a metric metadata value.
+ internal partial interface IMetadataValueInternal
+
+ {
+ /// The name of the metadata.
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString Name { get; set; }
+ /// The display name.
+ string NameLocalizedValue { get; set; }
+ /// The invariant value.
+ string NameValue { get; set; }
+ /// The value of the metadata.
+ string Value { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.json.cs
new file mode 100644
index 000000000000..da1312b9f690
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetadataValue.json.cs
@@ -0,0 +1,108 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Represents a metric metadata value.
+ public partial class MetadataValue
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValue.
+ ///
+ /// a to deserialize from.
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValue.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetadataValue FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new MetadataValue(json) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal MetadataValue(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_name = If( json?.PropertyT("name"), out var __jsonName) ? Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString.FromJson(__jsonName) : _name;}
+ {_value = If( json?.PropertyT("value"), out var __jsonValue) ? (string)__jsonValue : (string)_value;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AddIf( null != this._name ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) this._name.ToJson(null,serializationMode) : null, "name" ,container.Add );
+ AddIf( null != (((object)this._value)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._value.ToString()) : null, "value" ,container.Add );
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Metric.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Metric.PowerShell.cs
new file mode 100644
index 000000000000..8262ec233962
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Metric.PowerShell.cs
@@ -0,0 +1,236 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// The result data of a query.
+ [System.ComponentModel.TypeConverter(typeof(MetricTypeConverter))]
+ public partial class Metric
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new Metric(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new Metric(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal Metric(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Name"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Name = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Name, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Id, global::System.Convert.ToString);
+ }
+ if (content.Contains("Type"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Type, global::System.Convert.ToString);
+ }
+ if (content.Contains("DisplayDescription"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).DisplayDescription, global::System.Convert.ToString);
+ }
+ if (content.Contains("ErrorCode"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).ErrorCode = (string) content.GetValueForProperty("ErrorCode",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).ErrorCode, global::System.Convert.ToString);
+ }
+ if (content.Contains("ErrorMessage"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).ErrorMessage = (string) content.GetValueForProperty("ErrorMessage",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).ErrorMessage, global::System.Convert.ToString);
+ }
+ if (content.Contains("Unit"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Unit = (string) content.GetValueForProperty("Unit",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Unit, global::System.Convert.ToString);
+ }
+ if (content.Contains("Timesery"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Timesery = (System.Collections.Generic.List) content.GetValueForProperty("Timesery",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Timesery, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.TimeSeriesElementTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("NameValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).NameValue = (string) content.GetValueForProperty("NameValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).NameValue, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameLocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).NameLocalizedValue = (string) content.GetValueForProperty("NameLocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).NameLocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal Metric(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Name"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Name = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Name, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Id, global::System.Convert.ToString);
+ }
+ if (content.Contains("Type"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Type, global::System.Convert.ToString);
+ }
+ if (content.Contains("DisplayDescription"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).DisplayDescription, global::System.Convert.ToString);
+ }
+ if (content.Contains("ErrorCode"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).ErrorCode = (string) content.GetValueForProperty("ErrorCode",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).ErrorCode, global::System.Convert.ToString);
+ }
+ if (content.Contains("ErrorMessage"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).ErrorMessage = (string) content.GetValueForProperty("ErrorMessage",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).ErrorMessage, global::System.Convert.ToString);
+ }
+ if (content.Contains("Unit"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Unit = (string) content.GetValueForProperty("Unit",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Unit, global::System.Convert.ToString);
+ }
+ if (content.Contains("Timesery"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Timesery = (System.Collections.Generic.List) content.GetValueForProperty("Timesery",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).Timesery, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.TimeSeriesElementTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("NameValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).NameValue = (string) content.GetValueForProperty("NameValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).NameValue, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameLocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).NameLocalizedValue = (string) content.GetValueForProperty("NameLocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal)this).NameLocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// The result data of a query.
+ [System.ComponentModel.TypeConverter(typeof(MetricTypeConverter))]
+ public partial interface IMetric
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Metric.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Metric.TypeConverter.cs
new file mode 100644
index 000000000000..dc66899ece61
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Metric.TypeConverter.cs
@@ -0,0 +1,146 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class MetricTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return Metric.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return Metric.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return Metric.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Metric.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Metric.cs
new file mode 100644
index 000000000000..e7ed45ed9754
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Metric.cs
@@ -0,0 +1,222 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// The result data of a query.
+ public partial class Metric :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal
+ {
+
+ /// Backing field for property.
+ private string _displayDescription;
+
+ /// Detailed description of this metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string DisplayDescription { get => this._displayDescription; set => this._displayDescription = value; }
+
+ /// Backing field for property.
+ private string _errorCode;
+
+ /// 'Success' or the error details on query failures for this metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string ErrorCode { get => this._errorCode; set => this._errorCode = value; }
+
+ /// Backing field for property.
+ private string _errorMessage;
+
+ /// Error message encountered querying this specific metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string ErrorMessage { get => this._errorMessage; set => this._errorMessage = value; }
+
+ /// Backing field for property.
+ private string _id;
+
+ /// The metric Id.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Id { get => this._id; set => this._id = value; }
+
+ /// Internal Acessors for Name
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricInternal.Name { get => (this._name = this._name ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString()); set { {_name = value;} } }
+
+ /// Backing field for property.
+ private Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString _name;
+
+ /// The name and the display name of the metric, i.e. it is localizable string.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ internal Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString Name { get => (this._name = this._name ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString()); set => this._name = value; }
+
+ /// The display name.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public string NameLocalizedValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).LocalizedValue; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).LocalizedValue = value ?? null; }
+
+ /// The invariant value.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public string NameValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).Value; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).Value = value ; }
+
+ /// Backing field for property.
+ private System.Collections.Generic.List _timesery;
+
+ /// The time series returned when a data query is performed.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public System.Collections.Generic.List Timesery { get => this._timesery; set => this._timesery = value; }
+
+ /// Backing field for property.
+ private string _type;
+
+ /// The resource type of the metric resource.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Type { get => this._type; set => this._type = value; }
+
+ /// Backing field for property.
+ private string _unit;
+
+ /// The unit of the metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Unit { get => this._unit; set => this._unit = value; }
+
+ /// Creates an new instance.
+ public Metric()
+ {
+
+ }
+ }
+ /// The result data of a query.
+ public partial interface IMetric :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// Detailed description of this metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"Detailed description of this metric.",
+ SerializedName = @"displayDescription",
+ PossibleTypes = new [] { typeof(string) })]
+ string DisplayDescription { get; set; }
+ /// 'Success' or the error details on query failures for this metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"'Success' or the error details on query failures for this metric.",
+ SerializedName = @"errorCode",
+ PossibleTypes = new [] { typeof(string) })]
+ string ErrorCode { get; set; }
+ /// Error message encountered querying this specific metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"Error message encountered querying this specific metric.",
+ SerializedName = @"errorMessage",
+ PossibleTypes = new [] { typeof(string) })]
+ string ErrorMessage { get; set; }
+ /// The metric Id.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The metric Id.",
+ SerializedName = @"id",
+ PossibleTypes = new [] { typeof(string) })]
+ string Id { get; set; }
+ /// The display name.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The display name.",
+ SerializedName = @"localizedValue",
+ PossibleTypes = new [] { typeof(string) })]
+ string NameLocalizedValue { get; set; }
+ /// The invariant value.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The invariant value.",
+ SerializedName = @"value",
+ PossibleTypes = new [] { typeof(string) })]
+ string NameValue { get; set; }
+ /// The time series returned when a data query is performed.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The time series returned when a data query is performed.",
+ SerializedName = @"timeseries",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ITimeSeriesElement) })]
+ System.Collections.Generic.List Timesery { get; set; }
+ /// The resource type of the metric resource.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The resource type of the metric resource.",
+ SerializedName = @"type",
+ PossibleTypes = new [] { typeof(string) })]
+ string Type { get; set; }
+ /// The unit of the metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The unit of the metric.",
+ SerializedName = @"unit",
+ PossibleTypes = new [] { typeof(string) })]
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond")]
+ string Unit { get; set; }
+
+ }
+ /// The result data of a query.
+ internal partial interface IMetricInternal
+
+ {
+ /// Detailed description of this metric.
+ string DisplayDescription { get; set; }
+ /// 'Success' or the error details on query failures for this metric.
+ string ErrorCode { get; set; }
+ /// Error message encountered querying this specific metric.
+ string ErrorMessage { get; set; }
+ /// The metric Id.
+ string Id { get; set; }
+ /// The name and the display name of the metric, i.e. it is localizable string.
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString Name { get; set; }
+ /// The display name.
+ string NameLocalizedValue { get; set; }
+ /// The invariant value.
+ string NameValue { get; set; }
+ /// The time series returned when a data query is performed.
+ System.Collections.Generic.List Timesery { get; set; }
+ /// The resource type of the metric resource.
+ string Type { get; set; }
+ /// The unit of the metric.
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond")]
+ string Unit { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Metric.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Metric.json.cs
new file mode 100644
index 000000000000..2b4be1a12bef
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Metric.json.cs
@@ -0,0 +1,128 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// The result data of a query.
+ public partial class Metric
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric.
+ ///
+ /// a to deserialize from.
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new Metric(json) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal Metric(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_name = If( json?.PropertyT("name"), out var __jsonName) ? Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString.FromJson(__jsonName) : _name;}
+ {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)_id;}
+ {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)_type;}
+ {_displayDescription = If( json?.PropertyT("displayDescription"), out var __jsonDisplayDescription) ? (string)__jsonDisplayDescription : (string)_displayDescription;}
+ {_errorCode = If( json?.PropertyT("errorCode"), out var __jsonErrorCode) ? (string)__jsonErrorCode : (string)_errorCode;}
+ {_errorMessage = If( json?.PropertyT("errorMessage"), out var __jsonErrorMessage) ? (string)__jsonErrorMessage : (string)_errorMessage;}
+ {_unit = If( json?.PropertyT("unit"), out var __jsonUnit) ? (string)__jsonUnit : (string)_unit;}
+ {_timesery = If( json?.PropertyT("timeseries"), out var __jsonTimeseries) ? If( __jsonTimeseries as Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonArray, out var __v) ? new global::System.Func>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ITimeSeriesElement) (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.TimeSeriesElement.FromJson(__u) )) ))() : null : _timesery;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AddIf( null != this._name ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) this._name.ToJson(null,serializationMode) : null, "name" ,container.Add );
+ AddIf( null != (((object)this._id)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._id.ToString()) : null, "id" ,container.Add );
+ AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add );
+ AddIf( null != (((object)this._displayDescription)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._displayDescription.ToString()) : null, "displayDescription" ,container.Add );
+ AddIf( null != (((object)this._errorCode)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._errorCode.ToString()) : null, "errorCode" ,container.Add );
+ AddIf( null != (((object)this._errorMessage)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._errorMessage.ToString()) : null, "errorMessage" ,container.Add );
+ AddIf( null != (((object)this._unit)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._unit.ToString()) : null, "unit" ,container.Add );
+ if (null != this._timesery)
+ {
+ var __w = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.XNodeArray();
+ foreach( var __x in this._timesery )
+ {
+ AddIf(__x?.ToJson(null, serializationMode) ,__w.Add);
+ }
+ container.Add("timeseries",__w);
+ }
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.PowerShell.cs
new file mode 100644
index 000000000000..c02f937197af
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.PowerShell.cs
@@ -0,0 +1,176 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time
+ /// grain.
+ ///
+ [System.ComponentModel.TypeConverter(typeof(MetricAvailabilityTypeConverter))]
+ public partial class MetricAvailability
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new MetricAvailability(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new MetricAvailability(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal MetricAvailability(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("TimeGrain"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailabilityInternal)this).TimeGrain = (global::System.TimeSpan?) content.GetValueForProperty("TimeGrain",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailabilityInternal)this).TimeGrain, (v) => v is global::System.TimeSpan _v ? _v : global::System.Xml.XmlConvert.ToTimeSpan( v.ToString() ));
+ }
+ if (content.Contains("Retention"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailabilityInternal)this).Retention = (global::System.TimeSpan?) content.GetValueForProperty("Retention",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailabilityInternal)this).Retention, (v) => v is global::System.TimeSpan _v ? _v : global::System.Xml.XmlConvert.ToTimeSpan( v.ToString() ));
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal MetricAvailability(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("TimeGrain"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailabilityInternal)this).TimeGrain = (global::System.TimeSpan?) content.GetValueForProperty("TimeGrain",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailabilityInternal)this).TimeGrain, (v) => v is global::System.TimeSpan _v ? _v : global::System.Xml.XmlConvert.ToTimeSpan( v.ToString() ));
+ }
+ if (content.Contains("Retention"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailabilityInternal)this).Retention = (global::System.TimeSpan?) content.GetValueForProperty("Retention",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailabilityInternal)this).Retention, (v) => v is global::System.TimeSpan _v ? _v : global::System.Xml.XmlConvert.ToTimeSpan( v.ToString() ));
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time
+ /// grain.
+ [System.ComponentModel.TypeConverter(typeof(MetricAvailabilityTypeConverter))]
+ public partial interface IMetricAvailability
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.TypeConverter.cs
new file mode 100644
index 000000000000..aab05b48394f
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.TypeConverter.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class MetricAvailabilityTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return MetricAvailability.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return MetricAvailability.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return MetricAvailability.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.cs
new file mode 100644
index 000000000000..2a23930f9685
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.cs
@@ -0,0 +1,91 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ ///
+ /// Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time
+ /// grain.
+ ///
+ public partial class MetricAvailability :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailabilityInternal
+ {
+
+ /// Backing field for property.
+ private global::System.TimeSpan? _retention;
+
+ ///
+ /// The retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public global::System.TimeSpan? Retention { get => this._retention; set => this._retention = value; }
+
+ /// Backing field for property.
+ private global::System.TimeSpan? _timeGrain;
+
+ ///
+ /// The time grain specifies a supported aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public global::System.TimeSpan? TimeGrain { get => this._timeGrain; set => this._timeGrain = value; }
+
+ /// Creates an new instance.
+ public MetricAvailability()
+ {
+
+ }
+ }
+ /// Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time
+ /// grain.
+ public partial interface IMetricAvailability :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ ///
+ /// The retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc.",
+ SerializedName = @"retention",
+ PossibleTypes = new [] { typeof(global::System.TimeSpan) })]
+ global::System.TimeSpan? Retention { get; set; }
+ ///
+ /// The time grain specifies a supported aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The time grain specifies a supported aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc.",
+ SerializedName = @"timeGrain",
+ PossibleTypes = new [] { typeof(global::System.TimeSpan) })]
+ global::System.TimeSpan? TimeGrain { get; set; }
+
+ }
+ /// Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time
+ /// grain.
+ internal partial interface IMetricAvailabilityInternal
+
+ {
+ ///
+ /// The retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc.
+ ///
+ global::System.TimeSpan? Retention { get; set; }
+ ///
+ /// The time grain specifies a supported aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc.
+ ///
+ global::System.TimeSpan? TimeGrain { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.json.cs
new file mode 100644
index 000000000000..a6572934f64c
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricAvailability.json.cs
@@ -0,0 +1,113 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ ///
+ /// Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time
+ /// grain.
+ ///
+ public partial class MetricAvailability
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability.
+ ///
+ /// a to deserialize from.
+ ///
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new MetricAvailability(json) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal MetricAvailability(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_timeGrain = If( json?.PropertyT("timeGrain"), out var __jsonTimeGrain) ? global::System.Xml.XmlConvert.ToTimeSpan( __jsonTimeGrain ) : _timeGrain;}
+ {_retention = If( json?.PropertyT("retention"), out var __jsonRetention) ? global::System.Xml.XmlConvert.ToTimeSpan( __jsonRetention ) : _retention;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AddIf( (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode)(null != this._timeGrain ? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(global::System.Xml.XmlConvert.ToString((global::System.TimeSpan)this._timeGrain)): null), "timeGrain" ,container.Add );
+ AddIf( (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode)(null != this._retention ? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(global::System.Xml.XmlConvert.ToString((global::System.TimeSpan)this._retention)): null), "retention" ,container.Add );
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.PowerShell.cs
new file mode 100644
index 000000000000..5ceabc711fbd
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.PowerShell.cs
@@ -0,0 +1,276 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// Metric definition class specifies the metadata for a metric.
+ [System.ComponentModel.TypeConverter(typeof(MetricDefinitionTypeConverter))]
+ public partial class MetricDefinition
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new MetricDefinition(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new MetricDefinition(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal MetricDefinition(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Name"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Name = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Name, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("IsDimensionRequired"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).IsDimensionRequired = (bool?) content.GetValueForProperty("IsDimensionRequired",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).IsDimensionRequired, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool)));
+ }
+ if (content.Contains("ResourceId"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).ResourceId = (string) content.GetValueForProperty("ResourceId",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).ResourceId, global::System.Convert.ToString);
+ }
+ if (content.Contains("Namespace"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Namespace = (string) content.GetValueForProperty("Namespace",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Namespace, global::System.Convert.ToString);
+ }
+ if (content.Contains("DisplayDescription"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).DisplayDescription, global::System.Convert.ToString);
+ }
+ if (content.Contains("Category"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Category = (string) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Category, global::System.Convert.ToString);
+ }
+ if (content.Contains("MetricClass"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).MetricClass = (string) content.GetValueForProperty("MetricClass",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).MetricClass, global::System.Convert.ToString);
+ }
+ if (content.Contains("Unit"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Unit = (string) content.GetValueForProperty("Unit",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Unit, global::System.Convert.ToString);
+ }
+ if (content.Contains("PrimaryAggregationType"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).PrimaryAggregationType = (string) content.GetValueForProperty("PrimaryAggregationType",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).PrimaryAggregationType, global::System.Convert.ToString);
+ }
+ if (content.Contains("SupportedAggregationType"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).SupportedAggregationType = (System.Collections.Generic.List) content.GetValueForProperty("SupportedAggregationType",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).SupportedAggregationType, __y => TypeConverterExtensions.SelectToList(__y, global::System.Convert.ToString));
+ }
+ if (content.Contains("MetricAvailability"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).MetricAvailability = (System.Collections.Generic.List) content.GetValueForProperty("MetricAvailability",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).MetricAvailability, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricAvailabilityTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Id, global::System.Convert.ToString);
+ }
+ if (content.Contains("Dimension"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Dimension = (System.Collections.Generic.List) content.GetValueForProperty("Dimension",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Dimension, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("NameValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).NameValue = (string) content.GetValueForProperty("NameValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).NameValue, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameLocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).NameLocalizedValue = (string) content.GetValueForProperty("NameLocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).NameLocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal MetricDefinition(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Name"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Name = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Name, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("IsDimensionRequired"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).IsDimensionRequired = (bool?) content.GetValueForProperty("IsDimensionRequired",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).IsDimensionRequired, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool)));
+ }
+ if (content.Contains("ResourceId"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).ResourceId = (string) content.GetValueForProperty("ResourceId",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).ResourceId, global::System.Convert.ToString);
+ }
+ if (content.Contains("Namespace"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Namespace = (string) content.GetValueForProperty("Namespace",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Namespace, global::System.Convert.ToString);
+ }
+ if (content.Contains("DisplayDescription"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).DisplayDescription, global::System.Convert.ToString);
+ }
+ if (content.Contains("Category"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Category = (string) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Category, global::System.Convert.ToString);
+ }
+ if (content.Contains("MetricClass"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).MetricClass = (string) content.GetValueForProperty("MetricClass",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).MetricClass, global::System.Convert.ToString);
+ }
+ if (content.Contains("Unit"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Unit = (string) content.GetValueForProperty("Unit",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Unit, global::System.Convert.ToString);
+ }
+ if (content.Contains("PrimaryAggregationType"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).PrimaryAggregationType = (string) content.GetValueForProperty("PrimaryAggregationType",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).PrimaryAggregationType, global::System.Convert.ToString);
+ }
+ if (content.Contains("SupportedAggregationType"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).SupportedAggregationType = (System.Collections.Generic.List) content.GetValueForProperty("SupportedAggregationType",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).SupportedAggregationType, __y => TypeConverterExtensions.SelectToList(__y, global::System.Convert.ToString));
+ }
+ if (content.Contains("MetricAvailability"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).MetricAvailability = (System.Collections.Generic.List) content.GetValueForProperty("MetricAvailability",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).MetricAvailability, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricAvailabilityTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Id, global::System.Convert.ToString);
+ }
+ if (content.Contains("Dimension"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Dimension = (System.Collections.Generic.List) content.GetValueForProperty("Dimension",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).Dimension, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("NameValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).NameValue = (string) content.GetValueForProperty("NameValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).NameValue, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameLocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).NameLocalizedValue = (string) content.GetValueForProperty("NameLocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal)this).NameLocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// Metric definition class specifies the metadata for a metric.
+ [System.ComponentModel.TypeConverter(typeof(MetricDefinitionTypeConverter))]
+ public partial interface IMetricDefinition
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.TypeConverter.cs
new file mode 100644
index 000000000000..31a266c7cc9d
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.TypeConverter.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class MetricDefinitionTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return MetricDefinition.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return MetricDefinition.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return MetricDefinition.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.cs
new file mode 100644
index 000000000000..0014d0365e78
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.cs
@@ -0,0 +1,334 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Metric definition class specifies the metadata for a metric.
+ public partial class MetricDefinition :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal
+ {
+
+ /// Backing field for property.
+ private string _category;
+
+ /// Custom category name for this metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Category { get => this._category; set => this._category = value; }
+
+ /// Backing field for property.
+ private System.Collections.Generic.List _dimension;
+
+ ///
+ /// The name and the display name of the dimension, i.e. it is a localizable string.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public System.Collections.Generic.List Dimension { get => this._dimension; set => this._dimension = value; }
+
+ /// Backing field for property.
+ private string _displayDescription;
+
+ /// Detailed description of this metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string DisplayDescription { get => this._displayDescription; set => this._displayDescription = value; }
+
+ /// Backing field for property.
+ private string _id;
+
+ /// The resource identifier of the metric definition.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Id { get => this._id; set => this._id = value; }
+
+ /// Backing field for property.
+ private bool? _isDimensionRequired;
+
+ /// Flag to indicate whether the dimension is required.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public bool? IsDimensionRequired { get => this._isDimensionRequired; set => this._isDimensionRequired = value; }
+
+ /// Backing field for property.
+ private System.Collections.Generic.List _metricAvailability;
+
+ /// The collection of what aggregation intervals are available to be queried.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public System.Collections.Generic.List MetricAvailability { get => this._metricAvailability; set => this._metricAvailability = value; }
+
+ /// Backing field for property.
+ private string _metricClass;
+
+ /// The class of the metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string MetricClass { get => this._metricClass; set => this._metricClass = value; }
+
+ /// Internal Acessors for Name
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionInternal.Name { get => (this._name = this._name ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString()); set { {_name = value;} } }
+
+ /// Backing field for property.
+ private Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString _name;
+
+ /// The name and the display name of the metric, i.e. it is a localizable string.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ internal Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString Name { get => (this._name = this._name ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString()); set => this._name = value; }
+
+ /// The display name.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public string NameLocalizedValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).LocalizedValue; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).LocalizedValue = value ?? null; }
+
+ /// The invariant value.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Inlined)]
+ public string NameValue { get => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).Value; set => ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableStringInternal)Name).Value = value ?? null; }
+
+ /// Backing field for property.
+ private string _namespace;
+
+ /// The namespace the metric belongs to.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Namespace { get => this._namespace; set => this._namespace = value; }
+
+ /// Backing field for property.
+ private string _primaryAggregationType;
+
+ /// The primary aggregation type value defining how to use the values for display.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string PrimaryAggregationType { get => this._primaryAggregationType; set => this._primaryAggregationType = value; }
+
+ /// Backing field for property.
+ private string _resourceId;
+
+ /// The resource identifier of the resource that emitted the metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string ResourceId { get => this._resourceId; set => this._resourceId = value; }
+
+ /// Backing field for property.
+ private System.Collections.Generic.List _supportedAggregationType;
+
+ /// The collection of what aggregation types are supported.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public System.Collections.Generic.List SupportedAggregationType { get => this._supportedAggregationType; set => this._supportedAggregationType = value; }
+
+ /// Backing field for property.
+ private string _unit;
+
+ /// The unit of the metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Unit { get => this._unit; set => this._unit = value; }
+
+ /// Creates an new instance.
+ public MetricDefinition()
+ {
+
+ }
+ }
+ /// Metric definition class specifies the metadata for a metric.
+ public partial interface IMetricDefinition :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// Custom category name for this metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"Custom category name for this metric.",
+ SerializedName = @"category",
+ PossibleTypes = new [] { typeof(string) })]
+ string Category { get; set; }
+ ///
+ /// The name and the display name of the dimension, i.e. it is a localizable string.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The name and the display name of the dimension, i.e. it is a localizable string.",
+ SerializedName = @"dimensions",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) })]
+ System.Collections.Generic.List Dimension { get; set; }
+ /// Detailed description of this metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"Detailed description of this metric.",
+ SerializedName = @"displayDescription",
+ PossibleTypes = new [] { typeof(string) })]
+ string DisplayDescription { get; set; }
+ /// The resource identifier of the metric definition.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The resource identifier of the metric definition.",
+ SerializedName = @"id",
+ PossibleTypes = new [] { typeof(string) })]
+ string Id { get; set; }
+ /// Flag to indicate whether the dimension is required.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"Flag to indicate whether the dimension is required.",
+ SerializedName = @"isDimensionRequired",
+ PossibleTypes = new [] { typeof(bool) })]
+ bool? IsDimensionRequired { get; set; }
+ /// The collection of what aggregation intervals are available to be queried.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The collection of what aggregation intervals are available to be queried.",
+ SerializedName = @"metricAvailabilities",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability) })]
+ System.Collections.Generic.List MetricAvailability { get; set; }
+ /// The class of the metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The class of the metric.",
+ SerializedName = @"metricClass",
+ PossibleTypes = new [] { typeof(string) })]
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("Availability", "Transactions", "Errors", "Latency", "Saturation")]
+ string MetricClass { get; set; }
+ /// The display name.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The display name.",
+ SerializedName = @"localizedValue",
+ PossibleTypes = new [] { typeof(string) })]
+ string NameLocalizedValue { get; set; }
+ /// The invariant value.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The invariant value.",
+ SerializedName = @"value",
+ PossibleTypes = new [] { typeof(string) })]
+ string NameValue { get; set; }
+ /// The namespace the metric belongs to.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The namespace the metric belongs to.",
+ SerializedName = @"namespace",
+ PossibleTypes = new [] { typeof(string) })]
+ string Namespace { get; set; }
+ /// The primary aggregation type value defining how to use the values for display.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The primary aggregation type value defining how to use the values for display.",
+ SerializedName = @"primaryAggregationType",
+ PossibleTypes = new [] { typeof(string) })]
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("None", "Average", "Count", "Minimum", "Maximum", "Total")]
+ string PrimaryAggregationType { get; set; }
+ /// The resource identifier of the resource that emitted the metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The resource identifier of the resource that emitted the metric.",
+ SerializedName = @"resourceId",
+ PossibleTypes = new [] { typeof(string) })]
+ string ResourceId { get; set; }
+ /// The collection of what aggregation types are supported.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The collection of what aggregation types are supported.",
+ SerializedName = @"supportedAggregationTypes",
+ PossibleTypes = new [] { typeof(string) })]
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("None", "Average", "Count", "Minimum", "Maximum", "Total")]
+ System.Collections.Generic.List SupportedAggregationType { get; set; }
+ /// The unit of the metric.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The unit of the metric.",
+ SerializedName = @"unit",
+ PossibleTypes = new [] { typeof(string) })]
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond")]
+ string Unit { get; set; }
+
+ }
+ /// Metric definition class specifies the metadata for a metric.
+ internal partial interface IMetricDefinitionInternal
+
+ {
+ /// Custom category name for this metric.
+ string Category { get; set; }
+ ///
+ /// The name and the display name of the dimension, i.e. it is a localizable string.
+ ///
+ System.Collections.Generic.List Dimension { get; set; }
+ /// Detailed description of this metric.
+ string DisplayDescription { get; set; }
+ /// The resource identifier of the metric definition.
+ string Id { get; set; }
+ /// Flag to indicate whether the dimension is required.
+ bool? IsDimensionRequired { get; set; }
+ /// The collection of what aggregation intervals are available to be queried.
+ System.Collections.Generic.List MetricAvailability { get; set; }
+ /// The class of the metric.
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("Availability", "Transactions", "Errors", "Latency", "Saturation")]
+ string MetricClass { get; set; }
+ /// The name and the display name of the metric, i.e. it is a localizable string.
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString Name { get; set; }
+ /// The display name.
+ string NameLocalizedValue { get; set; }
+ /// The invariant value.
+ string NameValue { get; set; }
+ /// The namespace the metric belongs to.
+ string Namespace { get; set; }
+ /// The primary aggregation type value defining how to use the values for display.
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("None", "Average", "Count", "Minimum", "Maximum", "Total")]
+ string PrimaryAggregationType { get; set; }
+ /// The resource identifier of the resource that emitted the metric.
+ string ResourceId { get; set; }
+ /// The collection of what aggregation types are supported.
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("None", "Average", "Count", "Minimum", "Maximum", "Total")]
+ System.Collections.Generic.List SupportedAggregationType { get; set; }
+ /// The unit of the metric.
+ [global::Microsoft.Azure.PowerShell.Cmdlets.Metric.PSArgumentCompleterAttribute("Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond")]
+ string Unit { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.json.cs
new file mode 100644
index 000000000000..f9583cb2659a
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinition.json.cs
@@ -0,0 +1,156 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Metric definition class specifies the metadata for a metric.
+ public partial class MetricDefinition
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition.
+ ///
+ /// a to deserialize from.
+ ///
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new MetricDefinition(json) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal MetricDefinition(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_name = If( json?.PropertyT("name"), out var __jsonName) ? Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString.FromJson(__jsonName) : _name;}
+ {_isDimensionRequired = If( json?.PropertyT("isDimensionRequired"), out var __jsonIsDimensionRequired) ? (bool?)__jsonIsDimensionRequired : _isDimensionRequired;}
+ {_resourceId = If( json?.PropertyT("resourceId"), out var __jsonResourceId) ? (string)__jsonResourceId : (string)_resourceId;}
+ {_namespace = If( json?.PropertyT("namespace"), out var __jsonNamespace) ? (string)__jsonNamespace : (string)_namespace;}
+ {_displayDescription = If( json?.PropertyT("displayDescription"), out var __jsonDisplayDescription) ? (string)__jsonDisplayDescription : (string)_displayDescription;}
+ {_category = If( json?.PropertyT("category"), out var __jsonCategory) ? (string)__jsonCategory : (string)_category;}
+ {_metricClass = If( json?.PropertyT("metricClass"), out var __jsonMetricClass) ? (string)__jsonMetricClass : (string)_metricClass;}
+ {_unit = If( json?.PropertyT("unit"), out var __jsonUnit) ? (string)__jsonUnit : (string)_unit;}
+ {_primaryAggregationType = If( json?.PropertyT("primaryAggregationType"), out var __jsonPrimaryAggregationType) ? (string)__jsonPrimaryAggregationType : (string)_primaryAggregationType;}
+ {_supportedAggregationType = If( json?.PropertyT("supportedAggregationTypes"), out var __jsonSupportedAggregationTypes) ? If( __jsonSupportedAggregationTypes as Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonArray, out var __v) ? new global::System.Func>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__v, (__u)=>(string) (__u is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString __t ? (string)(__t.ToString()) : null)) ))() : null : _supportedAggregationType;}
+ {_metricAvailability = If( json?.PropertyT("metricAvailabilities"), out var __jsonMetricAvailabilities) ? If( __jsonMetricAvailabilities as Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonArray, out var __q) ? new global::System.Func>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__q, (__p)=>(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricAvailability) (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricAvailability.FromJson(__p) )) ))() : null : _metricAvailability;}
+ {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)_id;}
+ {_dimension = If( json?.PropertyT("dimensions"), out var __jsonDimensions) ? If( __jsonDimensions as Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonArray, out var __l) ? new global::System.Func>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__l, (__k)=>(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableString.FromJson(__k) )) ))() : null : _dimension;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AddIf( null != this._name ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) this._name.ToJson(null,serializationMode) : null, "name" ,container.Add );
+ AddIf( null != this._isDimensionRequired ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonBoolean((bool)this._isDimensionRequired) : null, "isDimensionRequired" ,container.Add );
+ AddIf( null != (((object)this._resourceId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._resourceId.ToString()) : null, "resourceId" ,container.Add );
+ AddIf( null != (((object)this._namespace)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._namespace.ToString()) : null, "namespace" ,container.Add );
+ AddIf( null != (((object)this._displayDescription)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._displayDescription.ToString()) : null, "displayDescription" ,container.Add );
+ AddIf( null != (((object)this._category)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._category.ToString()) : null, "category" ,container.Add );
+ AddIf( null != (((object)this._metricClass)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._metricClass.ToString()) : null, "metricClass" ,container.Add );
+ AddIf( null != (((object)this._unit)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._unit.ToString()) : null, "unit" ,container.Add );
+ AddIf( null != (((object)this._primaryAggregationType)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._primaryAggregationType.ToString()) : null, "primaryAggregationType" ,container.Add );
+ if (null != this._supportedAggregationType)
+ {
+ var __w = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.XNodeArray();
+ foreach( var __x in this._supportedAggregationType )
+ {
+ AddIf(null != (((object)__x)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(__x.ToString()) : null ,__w.Add);
+ }
+ container.Add("supportedAggregationTypes",__w);
+ }
+ if (null != this._metricAvailability)
+ {
+ var __r = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.XNodeArray();
+ foreach( var __s in this._metricAvailability )
+ {
+ AddIf(__s?.ToJson(null, serializationMode) ,__r.Add);
+ }
+ container.Add("metricAvailabilities",__r);
+ }
+ AddIf( null != (((object)this._id)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._id.ToString()) : null, "id" ,container.Add );
+ if (null != this._dimension)
+ {
+ var __m = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.XNodeArray();
+ foreach( var __n in this._dimension )
+ {
+ AddIf(__n?.ToJson(null, serializationMode) ,__m.Add);
+ }
+ container.Add("dimensions",__m);
+ }
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.PowerShell.cs
new file mode 100644
index 000000000000..a16372c177c8
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.PowerShell.cs
@@ -0,0 +1,164 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// Represents collection of metric definitions.
+ [System.ComponentModel.TypeConverter(typeof(MetricDefinitionCollectionTypeConverter))]
+ public partial class MetricDefinitionCollection
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollection DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new MetricDefinitionCollection(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollection DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new MetricDefinitionCollection(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollection FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal MetricDefinitionCollection(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Value"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollectionInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollectionInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricDefinitionTypeConverter.ConvertFrom));
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal MetricDefinitionCollection(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Value"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollectionInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollectionInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricDefinitionTypeConverter.ConvertFrom));
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// Represents collection of metric definitions.
+ [System.ComponentModel.TypeConverter(typeof(MetricDefinitionCollectionTypeConverter))]
+ public partial interface IMetricDefinitionCollection
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.TypeConverter.cs
new file mode 100644
index 000000000000..ddb2d15705ec
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.TypeConverter.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class MetricDefinitionCollectionTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollection ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollection).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return MetricDefinitionCollection.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return MetricDefinitionCollection.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return MetricDefinitionCollection.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.cs
new file mode 100644
index 000000000000..e7b164e8506c
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.cs
@@ -0,0 +1,54 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Represents collection of metric definitions.
+ public partial class MetricDefinitionCollection :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollection,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollectionInternal
+ {
+
+ /// Backing field for property.
+ private System.Collections.Generic.List _value;
+
+ /// The values for the metric definitions.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public System.Collections.Generic.List Value { get => this._value; set => this._value = value; }
+
+ /// Creates an new instance.
+ public MetricDefinitionCollection()
+ {
+
+ }
+ }
+ /// Represents collection of metric definitions.
+ public partial interface IMetricDefinitionCollection :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// The values for the metric definitions.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The values for the metric definitions.",
+ SerializedName = @"value",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition) })]
+ System.Collections.Generic.List Value { get; set; }
+
+ }
+ /// Represents collection of metric definitions.
+ internal partial interface IMetricDefinitionCollectionInternal
+
+ {
+ /// The values for the metric definitions.
+ System.Collections.Generic.List Value { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.json.cs
new file mode 100644
index 000000000000..7136b907b287
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricDefinitionCollection.json.cs
@@ -0,0 +1,116 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Represents collection of metric definitions.
+ public partial class MetricDefinitionCollection
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollection.
+ ///
+ /// a to deserialize from.
+ ///
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollection.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinitionCollection FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new MetricDefinitionCollection(json) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal MetricDefinitionCollection(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonArray, out var __v) ? new global::System.Func>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricDefinition) (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricDefinition.FromJson(__u) )) ))() : null : _value;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ if (null != this._value)
+ {
+ var __w = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.XNodeArray();
+ foreach( var __x in this._value )
+ {
+ AddIf(__x?.ToJson(null, serializationMode) ,__w.Add);
+ }
+ container.Add("value",__w);
+ }
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.PowerShell.cs
new file mode 100644
index 000000000000..bdbacd4362bf
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.PowerShell.cs
@@ -0,0 +1,178 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ [System.ComponentModel.TypeConverter(typeof(MetricIdentityTypeConverter))]
+ public partial class MetricIdentity
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentity DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new MetricIdentity(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentity DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new MetricIdentity(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentity FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal MetricIdentity(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("SubscriptionId"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).SubscriptionId = (string) content.GetValueForProperty("SubscriptionId",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).SubscriptionId, global::System.Convert.ToString);
+ }
+ if (content.Contains("ResourceUri"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).ResourceUri = (string) content.GetValueForProperty("ResourceUri",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).ResourceUri, global::System.Convert.ToString);
+ }
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).Id, global::System.Convert.ToString);
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal MetricIdentity(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("SubscriptionId"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).SubscriptionId = (string) content.GetValueForProperty("SubscriptionId",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).SubscriptionId, global::System.Convert.ToString);
+ }
+ if (content.Contains("ResourceUri"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).ResourceUri = (string) content.GetValueForProperty("ResourceUri",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).ResourceUri, global::System.Convert.ToString);
+ }
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal)this).Id, global::System.Convert.ToString);
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ [System.ComponentModel.TypeConverter(typeof(MetricIdentityTypeConverter))]
+ public partial interface IMetricIdentity
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.TypeConverter.cs
new file mode 100644
index 000000000000..932221a0d579
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.TypeConverter.cs
@@ -0,0 +1,157 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class MetricIdentityTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ // we allow string conversion too.
+ if (type == typeof(global::System.String))
+ {
+ return true;
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentity ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ // support direct string to id type conversion.
+ if (type == typeof(global::System.String))
+ {
+ return new MetricIdentity { Id = sourceValue };
+ }
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentity).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return MetricIdentity.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return MetricIdentity.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return MetricIdentity.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.cs
new file mode 100644
index 000000000000..48613765ad83
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.cs
@@ -0,0 +1,91 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ public partial class MetricIdentity :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentity,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentityInternal
+ {
+
+ /// Backing field for property.
+ private string _id;
+
+ /// Resource identity path
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Id { get => this._id; set => this._id = value; }
+
+ /// Backing field for property.
+ private string _resourceUri;
+
+ /// The identifier of the resource.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string ResourceUri { get => this._resourceUri; set => this._resourceUri = value; }
+
+ /// Backing field for property.
+ private string _subscriptionId;
+
+ /// The ID of the target subscription.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; }
+
+ /// Creates an new instance.
+ public MetricIdentity()
+ {
+
+ }
+ }
+ public partial interface IMetricIdentity :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// Resource identity path
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"Resource identity path",
+ SerializedName = @"id",
+ PossibleTypes = new [] { typeof(string) })]
+ string Id { get; set; }
+ /// The identifier of the resource.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The identifier of the resource.",
+ SerializedName = @"resourceUri",
+ PossibleTypes = new [] { typeof(string) })]
+ string ResourceUri { get; set; }
+ /// The ID of the target subscription.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The ID of the target subscription.",
+ SerializedName = @"subscriptionId",
+ PossibleTypes = new [] { typeof(string) })]
+ string SubscriptionId { get; set; }
+
+ }
+ internal partial interface IMetricIdentityInternal
+
+ {
+ /// Resource identity path
+ string Id { get; set; }
+ /// The identifier of the resource.
+ string ResourceUri { get; set; }
+ /// The ID of the target subscription.
+ string SubscriptionId { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.json.cs
new file mode 100644
index 000000000000..017ecb9e9ff1
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricIdentity.json.cs
@@ -0,0 +1,111 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ public partial class MetricIdentity
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentity.
+ ///
+ /// a to deserialize from.
+ ///
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentity.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricIdentity FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new MetricIdentity(json) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal MetricIdentity(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_subscriptionId = If( json?.PropertyT("subscriptionId"), out var __jsonSubscriptionId) ? (string)__jsonSubscriptionId : (string)_subscriptionId;}
+ {_resourceUri = If( json?.PropertyT("resourceUri"), out var __jsonResourceUri) ? (string)__jsonResourceUri : (string)_resourceUri;}
+ {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)_id;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AddIf( null != (((object)this._subscriptionId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._subscriptionId.ToString()) : null, "subscriptionId" ,container.Add );
+ AddIf( null != (((object)this._resourceUri)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._resourceUri.ToString()) : null, "resourceUri" ,container.Add );
+ AddIf( null != (((object)this._id)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._id.ToString()) : null, "id" ,container.Add );
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.PowerShell.cs
new file mode 100644
index 000000000000..1e9d5e8d6224
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.PowerShell.cs
@@ -0,0 +1,204 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// Represents a metric value.
+ [System.ComponentModel.TypeConverter(typeof(MetricValueTypeConverter))]
+ public partial class MetricValue
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValue DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new MetricValue(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValue DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new MetricValue(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValue FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal MetricValue(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("TimeStamp"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).TimeStamp = (global::System.DateTime) content.GetValueForProperty("TimeStamp",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).TimeStamp, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified));
+ }
+ if (content.Contains("Average"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Average = (double?) content.GetValueForProperty("Average",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Average, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ if (content.Contains("Minimum"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Minimum = (double?) content.GetValueForProperty("Minimum",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Minimum, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ if (content.Contains("Maximum"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Maximum = (double?) content.GetValueForProperty("Maximum",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Maximum, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ if (content.Contains("Total"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Total = (double?) content.GetValueForProperty("Total",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Total, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ if (content.Contains("Count"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Count = (double?) content.GetValueForProperty("Count",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Count, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal MetricValue(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("TimeStamp"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).TimeStamp = (global::System.DateTime) content.GetValueForProperty("TimeStamp",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).TimeStamp, (v) => v is global::System.DateTime _v ? _v : global::System.Xml.XmlConvert.ToDateTime( v.ToString() , global::System.Xml.XmlDateTimeSerializationMode.Unspecified));
+ }
+ if (content.Contains("Average"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Average = (double?) content.GetValueForProperty("Average",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Average, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ if (content.Contains("Minimum"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Minimum = (double?) content.GetValueForProperty("Minimum",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Minimum, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ if (content.Contains("Maximum"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Maximum = (double?) content.GetValueForProperty("Maximum",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Maximum, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ if (content.Contains("Total"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Total = (double?) content.GetValueForProperty("Total",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Total, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ if (content.Contains("Count"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Count = (double?) content.GetValueForProperty("Count",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal)this).Count, (__y)=> (double) global::System.Convert.ChangeType(__y, typeof(double)));
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// Represents a metric value.
+ [System.ComponentModel.TypeConverter(typeof(MetricValueTypeConverter))]
+ public partial interface IMetricValue
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.TypeConverter.cs
new file mode 100644
index 000000000000..67b7db65661d
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.TypeConverter.cs
@@ -0,0 +1,147 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class MetricValueTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the
+ /// type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValue ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValue).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return MetricValue.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return MetricValue.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return MetricValue.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.cs
new file mode 100644
index 000000000000..d66852ad2c4e
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.cs
@@ -0,0 +1,163 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Represents a metric value.
+ public partial class MetricValue :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValue,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValueInternal
+ {
+
+ /// Backing field for property.
+ private double? _average;
+
+ /// The average value in the time range.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public double? Average { get => this._average; set => this._average = value; }
+
+ /// Backing field for property.
+ private double? _count;
+
+ ///
+ /// The number of samples in the time range. Can be used to determine the number of values that contributed to the average
+ /// value.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public double? Count { get => this._count; set => this._count = value; }
+
+ /// Backing field for property.
+ private double? _maximum;
+
+ /// The greatest value in the time range.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public double? Maximum { get => this._maximum; set => this._maximum = value; }
+
+ /// Backing field for property.
+ private double? _minimum;
+
+ /// The least value in the time range.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public double? Minimum { get => this._minimum; set => this._minimum = value; }
+
+ /// Backing field for property.
+ private global::System.DateTime _timeStamp;
+
+ /// The timestamp for the metric value in ISO 8601 format.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public global::System.DateTime TimeStamp { get => this._timeStamp; set => this._timeStamp = value; }
+
+ /// Backing field for property.
+ private double? _total;
+
+ /// The sum of all of the values in the time range.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public double? Total { get => this._total; set => this._total = value; }
+
+ /// Creates an new instance.
+ public MetricValue()
+ {
+
+ }
+ }
+ /// Represents a metric value.
+ public partial interface IMetricValue :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// The average value in the time range.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The average value in the time range.",
+ SerializedName = @"average",
+ PossibleTypes = new [] { typeof(double) })]
+ double? Average { get; set; }
+ ///
+ /// The number of samples in the time range. Can be used to determine the number of values that contributed to the average
+ /// value.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The number of samples in the time range. Can be used to determine the number of values that contributed to the average value.",
+ SerializedName = @"count",
+ PossibleTypes = new [] { typeof(double) })]
+ double? Count { get; set; }
+ /// The greatest value in the time range.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The greatest value in the time range.",
+ SerializedName = @"maximum",
+ PossibleTypes = new [] { typeof(double) })]
+ double? Maximum { get; set; }
+ /// The least value in the time range.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The least value in the time range.",
+ SerializedName = @"minimum",
+ PossibleTypes = new [] { typeof(double) })]
+ double? Minimum { get; set; }
+ /// The timestamp for the metric value in ISO 8601 format.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The timestamp for the metric value in ISO 8601 format.",
+ SerializedName = @"timeStamp",
+ PossibleTypes = new [] { typeof(global::System.DateTime) })]
+ global::System.DateTime TimeStamp { get; set; }
+ /// The sum of all of the values in the time range.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The sum of all of the values in the time range.",
+ SerializedName = @"total",
+ PossibleTypes = new [] { typeof(double) })]
+ double? Total { get; set; }
+
+ }
+ /// Represents a metric value.
+ internal partial interface IMetricValueInternal
+
+ {
+ /// The average value in the time range.
+ double? Average { get; set; }
+ ///
+ /// The number of samples in the time range. Can be used to determine the number of values that contributed to the average
+ /// value.
+ ///
+ double? Count { get; set; }
+ /// The greatest value in the time range.
+ double? Maximum { get; set; }
+ /// The least value in the time range.
+ double? Minimum { get; set; }
+ /// The timestamp for the metric value in ISO 8601 format.
+ global::System.DateTime TimeStamp { get; set; }
+ /// The sum of all of the values in the time range.
+ double? Total { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.json.cs
new file mode 100644
index 000000000000..2ad6a2951b03
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/MetricValue.json.cs
@@ -0,0 +1,116 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// Represents a metric value.
+ public partial class MetricValue
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValue.
+ ///
+ /// a to deserialize from.
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValue.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetricValue FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new MetricValue(json) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal MetricValue(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_timeStamp = If( json?.PropertyT("timeStamp"), out var __jsonTimeStamp) ? global::System.DateTime.TryParse((string)__jsonTimeStamp, global::System.Globalization.CultureInfo.InvariantCulture, global::System.Globalization.DateTimeStyles.AdjustToUniversal, out var __jsonTimeStampValue) ? __jsonTimeStampValue : _timeStamp : _timeStamp;}
+ {_average = If( json?.PropertyT("average"), out var __jsonAverage) ? (double?)__jsonAverage : _average;}
+ {_minimum = If( json?.PropertyT("minimum"), out var __jsonMinimum) ? (double?)__jsonMinimum : _minimum;}
+ {_maximum = If( json?.PropertyT("maximum"), out var __jsonMaximum) ? (double?)__jsonMaximum : _maximum;}
+ {_total = If( json?.PropertyT("total"), out var __jsonTotal) ? (double?)__jsonTotal : _total;}
+ {_count = If( json?.PropertyT("count"), out var __jsonCount) ? (double?)__jsonCount : _count;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AddIf( (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._timeStamp.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK",global::System.Globalization.CultureInfo.InvariantCulture)), "timeStamp" ,container.Add );
+ AddIf( null != this._average ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNumber((double)this._average) : null, "average" ,container.Add );
+ AddIf( null != this._minimum ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNumber((double)this._minimum) : null, "minimum" ,container.Add );
+ AddIf( null != this._maximum ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNumber((double)this._maximum) : null, "maximum" ,container.Add );
+ AddIf( null != this._total ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNumber((double)this._total) : null, "total" ,container.Add );
+ AddIf( null != this._count ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNumber((double)this._count) : null, "count" ,container.Add );
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Response.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Response.PowerShell.cs
new file mode 100644
index 000000000000..4fd6cecbfcc6
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Response.PowerShell.cs
@@ -0,0 +1,204 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// The response to a metrics query.
+ [System.ComponentModel.TypeConverter(typeof(ResponseTypeConverter))]
+ public partial class Response
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new Response(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new Response(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ /// an instance of the model class.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal Response(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Cost"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Cost = (int?) content.GetValueForProperty("Cost",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Cost, (__y)=> (int) global::System.Convert.ChangeType(__y, typeof(int)));
+ }
+ if (content.Contains("Timespan"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Timespan = (string) content.GetValueForProperty("Timespan",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Timespan, global::System.Convert.ToString);
+ }
+ if (content.Contains("Interval"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Interval = (string) content.GetValueForProperty("Interval",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Interval, global::System.Convert.ToString);
+ }
+ if (content.Contains("Namespace"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Namespace = (string) content.GetValueForProperty("Namespace",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Namespace, global::System.Convert.ToString);
+ }
+ if (content.Contains("Resourceregion"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Resourceregion = (string) content.GetValueForProperty("Resourceregion",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Resourceregion, global::System.Convert.ToString);
+ }
+ if (content.Contains("Value"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricTypeConverter.ConvertFrom));
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal Response(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Cost"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Cost = (int?) content.GetValueForProperty("Cost",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Cost, (__y)=> (int) global::System.Convert.ChangeType(__y, typeof(int)));
+ }
+ if (content.Contains("Timespan"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Timespan = (string) content.GetValueForProperty("Timespan",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Timespan, global::System.Convert.ToString);
+ }
+ if (content.Contains("Interval"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Interval = (string) content.GetValueForProperty("Interval",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Interval, global::System.Convert.ToString);
+ }
+ if (content.Contains("Namespace"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Namespace = (string) content.GetValueForProperty("Namespace",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Namespace, global::System.Convert.ToString);
+ }
+ if (content.Contains("Resourceregion"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Resourceregion = (string) content.GetValueForProperty("Resourceregion",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Resourceregion, global::System.Convert.ToString);
+ }
+ if (content.Contains("Value"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricTypeConverter.ConvertFrom));
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ /// Serializes this instance to a json string.
+
+ /// a containing this model serialized to JSON text.
+ public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode.IncludeAll)?.ToString();
+
+ public override string ToString()
+ {
+ var returnNow = false;
+ var result = global::System.String.Empty;
+ OverrideToString(ref result, ref returnNow);
+ if (returnNow)
+ {
+ return result;
+ }
+ return ToJsonString();
+ }
+ }
+ /// The response to a metrics query.
+ [System.ComponentModel.TypeConverter(typeof(ResponseTypeConverter))]
+ public partial interface IResponse
+
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Response.TypeConverter.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Response.TypeConverter.cs
new file mode 100644
index 000000000000..353e8a68db11
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Response.TypeConverter.cs
@@ -0,0 +1,146 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ ///
+ /// A PowerShell PSTypeConverter to support converting to an instance of
+ ///
+ public partial class ResponseTypeConverter : global::System.Management.Automation.PSTypeConverter
+ {
+
+ ///
+ /// Determines if the converter can convert the parameter to the parameter.
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false .
+ ///
+ public override bool CanConvertFrom(object sourceValue, global::System.Type destinationType) => CanConvertFrom(sourceValue);
+
+ ///
+ /// Determines if the converter can convert the parameter to the type.
+ ///
+ /// the instance to check if it can be converted to the type.
+ ///
+ /// true if the instance could be converted to a type, otherwise false
+ ///
+ public static bool CanConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return true;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ // we say yest to PSObjects
+ return true;
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ // we say yest to Hashtables/dictionaries
+ return true;
+ }
+ try
+ {
+ if (null != sourceValue.ToJsonString())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ // Not one of our objects
+ }
+ try
+ {
+ string text = sourceValue.ToString()?.Trim();
+ return true == text?.StartsWith("{") && true == text?.EndsWith("}") && Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(text).Type == Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonType.Object;
+ }
+ catch
+ {
+ // Doesn't look like it can be treated as JSON
+ }
+ return false;
+ }
+
+ ///
+ /// Determines if the parameter can be converted to the
+ /// parameter
+ ///
+ /// the to convert from
+ /// the to convert to
+ ///
+ /// true if the converter can convert the parameter to the parameter, otherwise false
+ ///
+ public override bool CanConvertTo(object sourceValue, global::System.Type destinationType) => false;
+
+ ///
+ /// Converts the parameter to the parameter using and
+ ///
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => ConvertFrom(sourceValue);
+
+ ///
+ /// Converts the parameter into an instance of
+ ///
+ /// the value to convert into an instance of .
+ ///
+ /// an instance of , or null if there is no suitable conversion.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse ConvertFrom(dynamic sourceValue)
+ {
+ if (null == sourceValue)
+ {
+ return null;
+ }
+ global::System.Type type = sourceValue.GetType();
+ if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse).IsAssignableFrom(type))
+ {
+ return sourceValue;
+ }
+ try
+ {
+ return Response.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());;
+ }
+ catch
+ {
+ // Unable to use JSON pattern
+ }
+ if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
+ {
+ return Response.DeserializeFromPSObject(sourceValue);
+ }
+ if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
+ {
+ return Response.DeserializeFromDictionary(sourceValue);
+ }
+ return null;
+ }
+
+ /// NotImplemented -- this will return null
+ /// the to convert from
+ /// the to convert to
+ /// not used by this TypeConverter.
+ /// when set to true , will ignore the case when converting.
+ /// will always return null .
+ public override object ConvertTo(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => null;
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Response.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Response.cs
new file mode 100644
index 000000000000..65459148e456
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Response.cs
@@ -0,0 +1,179 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// The response to a metrics query.
+ public partial class Response :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse,
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponseInternal
+ {
+
+ /// Backing field for property.
+ private int? _cost;
+
+ /// The integer value representing the relative cost of the query.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public int? Cost { get => this._cost; set => this._cost = value; }
+
+ /// Backing field for property.
+ private string _interval;
+
+ ///
+ /// The interval (window size) for which the metric data was returned in ISO 8601 duration format with a special case for
+ /// 'FULL' value that returns single datapoint for entire time span requested (*Examples: PT15M, PT1H, P1D, FULL*).
+ /// This may be adjusted and different from what was originally requested if AutoAdjustTimegrain=true is specified. This is
+ /// not present if a metadata request was made.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Interval { get => this._interval; set => this._interval = value; }
+
+ /// Backing field for property.
+ private string _namespace;
+
+ /// The namespace of the metrics being queried
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Namespace { get => this._namespace; set => this._namespace = value; }
+
+ /// Backing field for property.
+ private string _resourceregion;
+
+ /// The region of the resource being queried for metrics.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Resourceregion { get => this._resourceregion; set => this._resourceregion = value; }
+
+ /// Backing field for property.
+ private string _timespan;
+
+ ///
+ /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This
+ /// may be adjusted in the future and returned back from what was originally requested.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public string Timespan { get => this._timespan; set => this._timespan = value; }
+
+ /// Backing field for property.
+ private System.Collections.Generic.List _value;
+
+ /// The value of the collection.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Origin(Microsoft.Azure.PowerShell.Cmdlets.Metric.PropertyOrigin.Owned)]
+ public System.Collections.Generic.List Value { get => this._value; set => this._value = value; }
+
+ /// Creates an new instance.
+ public Response()
+ {
+
+ }
+ }
+ /// The response to a metrics query.
+ public partial interface IResponse :
+ Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.IJsonSerializable
+ {
+ /// The integer value representing the relative cost of the query.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The integer value representing the relative cost of the query.",
+ SerializedName = @"cost",
+ PossibleTypes = new [] { typeof(int) })]
+ int? Cost { get; set; }
+ ///
+ /// The interval (window size) for which the metric data was returned in ISO 8601 duration format with a special case for
+ /// 'FULL' value that returns single datapoint for entire time span requested (*Examples: PT15M, PT1H, P1D, FULL*).
+ /// This may be adjusted and different from what was originally requested if AutoAdjustTimegrain=true is specified. This is
+ /// not present if a metadata request was made.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The interval (window size) for which the metric data was returned in ISO 8601 duration format with a special case for 'FULL' value that returns single datapoint for entire time span requested (*Examples: PT15M, PT1H, P1D, FULL*).
+ This may be adjusted and different from what was originally requested if AutoAdjustTimegrain=true is specified. This is not present if a metadata request was made.",
+ SerializedName = @"interval",
+ PossibleTypes = new [] { typeof(string) })]
+ string Interval { get; set; }
+ /// The namespace of the metrics being queried
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The namespace of the metrics being queried",
+ SerializedName = @"namespace",
+ PossibleTypes = new [] { typeof(string) })]
+ string Namespace { get; set; }
+ /// The region of the resource being queried for metrics.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = false,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The region of the resource being queried for metrics.",
+ SerializedName = @"resourceregion",
+ PossibleTypes = new [] { typeof(string) })]
+ string Resourceregion { get; set; }
+ ///
+ /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This
+ /// may be adjusted in the future and returned back from what was originally requested.
+ ///
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested.",
+ SerializedName = @"timespan",
+ PossibleTypes = new [] { typeof(string) })]
+ string Timespan { get; set; }
+ /// The value of the collection.
+ [Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Info(
+ Required = true,
+ ReadOnly = false,
+ Read = true,
+ Create = true,
+ Update = true,
+ Description = @"The value of the collection.",
+ SerializedName = @"value",
+ PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric) })]
+ System.Collections.Generic.List Value { get; set; }
+
+ }
+ /// The response to a metrics query.
+ internal partial interface IResponseInternal
+
+ {
+ /// The integer value representing the relative cost of the query.
+ int? Cost { get; set; }
+ ///
+ /// The interval (window size) for which the metric data was returned in ISO 8601 duration format with a special case for
+ /// 'FULL' value that returns single datapoint for entire time span requested (*Examples: PT15M, PT1H, P1D, FULL*).
+ /// This may be adjusted and different from what was originally requested if AutoAdjustTimegrain=true is specified. This is
+ /// not present if a metadata request was made.
+ ///
+ string Interval { get; set; }
+ /// The namespace of the metrics being queried
+ string Namespace { get; set; }
+ /// The region of the resource being queried for metrics.
+ string Resourceregion { get; set; }
+ ///
+ /// The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This
+ /// may be adjusted in the future and returned back from what was originally requested.
+ ///
+ string Timespan { get; set; }
+ /// The value of the collection.
+ System.Collections.Generic.List Value { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/Response.json.cs b/src/Monitor/Metric.Autorest/generated/api/Models/Response.json.cs
new file mode 100644
index 000000000000..671802b15d32
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/Response.json.cs
@@ -0,0 +1,124 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using static Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Extensions;
+
+ /// The response to a metrics query.
+ public partial class Response
+ {
+
+ ///
+ /// AfterFromJson will be called after the json deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JsonNode that should be deserialized into this object.
+
+ partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json);
+
+ ///
+ /// AfterToJson will be called after the json serialization has finished, allowing customization of the before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The JSON container that the serialization result will be placed in.
+
+ partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container);
+
+ ///
+ /// BeforeFromJson will be called before the json deserialization has commenced, allowing complete customization of
+ /// the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the
+ /// output parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JsonNode that should be deserialized into this object.
+ /// Determines if the rest of the deserialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json, ref bool returnNow);
+
+ ///
+ /// BeforeToJson will be called before the json serialization has commenced, allowing complete customization of the
+ /// object before it is serialized.
+ /// If you wish to disable the default serialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The JSON container that the serialization result will be placed in.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse.
+ ///
+ /// a to deserialize from.
+ /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse.
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IResponse FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode node)
+ {
+ return node is Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json ? new Response(json) : null;
+ }
+
+ ///
+ /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject into a new instance of .
+ ///
+ /// A Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject instance to deserialize from.
+ internal Response(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject json)
+ {
+ bool returnNow = false;
+ BeforeFromJson(json, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ {_cost = If( json?.PropertyT("cost"), out var __jsonCost) ? (int?)__jsonCost : _cost;}
+ {_timespan = If( json?.PropertyT("timespan"), out var __jsonTimespan) ? (string)__jsonTimespan : (string)_timespan;}
+ {_interval = If( json?.PropertyT("interval"), out var __jsonInterval) ? (string)__jsonInterval : (string)_interval;}
+ {_namespace = If( json?.PropertyT("namespace"), out var __jsonNamespace) ? (string)__jsonNamespace : (string)_namespace;}
+ {_resourceregion = If( json?.PropertyT("resourceregion"), out var __jsonResourceregion) ? (string)__jsonResourceregion : (string)_resourceregion;}
+ {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonArray, out var __v) ? new global::System.Func>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.IMetric) (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.Metric.FromJson(__u) )) ))() : null : _value;}
+ AfterFromJson(json);
+ }
+
+ ///
+ /// Serializes this instance of into a .
+ ///
+ /// The container to serialize this object into. If the caller
+ /// passes in null , a new instance will be created and returned to the caller.
+ /// Allows the caller to choose the depth of the serialization. See .
+ ///
+ /// a serialized instance of as a .
+ ///
+ public Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.SerializationMode serializationMode)
+ {
+ container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonObject();
+
+ bool returnNow = false;
+ BeforeToJson(ref container, ref returnNow);
+ if (returnNow)
+ {
+ return container;
+ }
+ AddIf( null != this._cost ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode)new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNumber((int)this._cost) : null, "cost" ,container.Add );
+ AddIf( null != (((object)this._timespan)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._timespan.ToString()) : null, "timespan" ,container.Add );
+ AddIf( null != (((object)this._interval)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._interval.ToString()) : null, "interval" ,container.Add );
+ AddIf( null != (((object)this._namespace)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._namespace.ToString()) : null, "namespace" ,container.Add );
+ AddIf( null != (((object)this._resourceregion)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonString(this._resourceregion.ToString()) : null, "resourceregion" ,container.Add );
+ if (null != this._value)
+ {
+ var __w = new Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.XNodeArray();
+ foreach( var __x in this._value )
+ {
+ AddIf(__x?.ToJson(null, serializationMode) ,__w.Add);
+ }
+ container.Add("value",__w);
+ }
+ AfterToJson(ref container);
+ return container;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Monitor/Metric.Autorest/generated/api/Models/SubscriptionScopeMetricDefinition.PowerShell.cs b/src/Monitor/Metric.Autorest/generated/api/Models/SubscriptionScopeMetricDefinition.PowerShell.cs
new file mode 100644
index 000000000000..e786ccb103d9
--- /dev/null
+++ b/src/Monitor/Metric.Autorest/generated/api/Models/SubscriptionScopeMetricDefinition.PowerShell.cs
@@ -0,0 +1,278 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+namespace Microsoft.Azure.PowerShell.Cmdlets.Metric.Models
+{
+ using Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.PowerShell;
+
+ /// Metric definition class specifies the metadata for a metric.
+ [System.ComponentModel.TypeConverter(typeof(SubscriptionScopeMetricDefinitionTypeConverter))]
+ public partial class SubscriptionScopeMetricDefinition
+ {
+
+ ///
+ /// AfterDeserializeDictionary will be called after the deserialization has finished, allowing customization of the
+ /// object before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+
+ partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content);
+
+ ///
+ /// AfterDeserializePSObject will be called after the deserialization has finished, allowing customization of the object
+ /// before it is returned. Implement this method in a partial class to enable this behavior
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+
+ partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content);
+
+ ///
+ /// BeforeDeserializeDictionary will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow);
+
+ ///
+ /// BeforeDeserializePSObject will be called before the deserialization has commenced, allowing complete customization
+ /// of the object before it is deserialized.
+ /// If you wish to disable the default deserialization entirely, return true in the output
+ /// parameter.
+ /// Implement this method in a partial class to enable this behavior.
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ /// Determines if the rest of the serialization should be processed, or if the method should return
+ /// instantly.
+
+ partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow);
+
+ ///
+ /// OverrideToString will be called if it is implemented. Implement this method in a partial class to enable this behavior
+ ///
+ /// /// instance serialized to a string, normally it is a Json
+ /// /// set returnNow to true if you provide a customized OverrideToString function
+
+ partial void OverrideToString(ref string stringResult, ref bool returnNow);
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content)
+ {
+ return new SubscriptionScopeMetricDefinition(content);
+ }
+
+ ///
+ /// Deserializes a into an instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ ///
+ /// an instance of .
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content)
+ {
+ return new SubscriptionScopeMetricDefinition(content);
+ }
+
+ ///
+ /// Creates a new instance of , deserializing the content from a json string.
+ ///
+ /// a string containing a JSON serialized instance of this model.
+ ///
+ /// an instance of the model class.
+ ///
+ public static Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.Metric.Runtime.Json.JsonNode.Parse(jsonText));
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Collections.IDictionary content that should be used.
+ internal SubscriptionScopeMetricDefinition(global::System.Collections.IDictionary content)
+ {
+ bool returnNow = false;
+ BeforeDeserializeDictionary(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Name"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Name = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Name, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("IsDimensionRequired"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).IsDimensionRequired = (bool?) content.GetValueForProperty("IsDimensionRequired",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).IsDimensionRequired, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool)));
+ }
+ if (content.Contains("ResourceId"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).ResourceId = (string) content.GetValueForProperty("ResourceId",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).ResourceId, global::System.Convert.ToString);
+ }
+ if (content.Contains("Namespace"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Namespace = (string) content.GetValueForProperty("Namespace",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Namespace, global::System.Convert.ToString);
+ }
+ if (content.Contains("DisplayDescription"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).DisplayDescription, global::System.Convert.ToString);
+ }
+ if (content.Contains("Category"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Category = (string) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Category, global::System.Convert.ToString);
+ }
+ if (content.Contains("MetricClass"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).MetricClass = (string) content.GetValueForProperty("MetricClass",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).MetricClass, global::System.Convert.ToString);
+ }
+ if (content.Contains("Unit"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Unit = (string) content.GetValueForProperty("Unit",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Unit, global::System.Convert.ToString);
+ }
+ if (content.Contains("PrimaryAggregationType"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).PrimaryAggregationType = (string) content.GetValueForProperty("PrimaryAggregationType",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).PrimaryAggregationType, global::System.Convert.ToString);
+ }
+ if (content.Contains("SupportedAggregationType"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).SupportedAggregationType = (System.Collections.Generic.List) content.GetValueForProperty("SupportedAggregationType",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).SupportedAggregationType, __y => TypeConverterExtensions.SelectToList(__y, global::System.Convert.ToString));
+ }
+ if (content.Contains("MetricAvailability"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).MetricAvailability = (System.Collections.Generic.List) content.GetValueForProperty("MetricAvailability",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).MetricAvailability, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricAvailabilityTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Id, global::System.Convert.ToString);
+ }
+ if (content.Contains("Dimension"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Dimension = (System.Collections.Generic.List) content.GetValueForProperty("Dimension",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Dimension, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("NameValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).NameValue = (string) content.GetValueForProperty("NameValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).NameValue, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameLocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).NameLocalizedValue = (string) content.GetValueForProperty("NameLocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).NameLocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializeDictionary(content);
+ }
+
+ ///
+ /// Deserializes a into a new instance of .
+ ///
+ /// The global::System.Management.Automation.PSObject content that should be used.
+ internal SubscriptionScopeMetricDefinition(global::System.Management.Automation.PSObject content)
+ {
+ bool returnNow = false;
+ BeforeDeserializePSObject(content, ref returnNow);
+ if (returnNow)
+ {
+ return;
+ }
+ // actually deserialize
+ if (content.Contains("Name"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Name = (Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ILocalizableString) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Name, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom);
+ }
+ if (content.Contains("IsDimensionRequired"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).IsDimensionRequired = (bool?) content.GetValueForProperty("IsDimensionRequired",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).IsDimensionRequired, (__y)=> (bool) global::System.Convert.ChangeType(__y, typeof(bool)));
+ }
+ if (content.Contains("ResourceId"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).ResourceId = (string) content.GetValueForProperty("ResourceId",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).ResourceId, global::System.Convert.ToString);
+ }
+ if (content.Contains("Namespace"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Namespace = (string) content.GetValueForProperty("Namespace",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Namespace, global::System.Convert.ToString);
+ }
+ if (content.Contains("DisplayDescription"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).DisplayDescription, global::System.Convert.ToString);
+ }
+ if (content.Contains("Category"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Category = (string) content.GetValueForProperty("Category",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Category, global::System.Convert.ToString);
+ }
+ if (content.Contains("MetricClass"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).MetricClass = (string) content.GetValueForProperty("MetricClass",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).MetricClass, global::System.Convert.ToString);
+ }
+ if (content.Contains("Unit"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Unit = (string) content.GetValueForProperty("Unit",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Unit, global::System.Convert.ToString);
+ }
+ if (content.Contains("PrimaryAggregationType"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).PrimaryAggregationType = (string) content.GetValueForProperty("PrimaryAggregationType",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).PrimaryAggregationType, global::System.Convert.ToString);
+ }
+ if (content.Contains("SupportedAggregationType"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).SupportedAggregationType = (System.Collections.Generic.List) content.GetValueForProperty("SupportedAggregationType",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).SupportedAggregationType, __y => TypeConverterExtensions.SelectToList(__y, global::System.Convert.ToString));
+ }
+ if (content.Contains("MetricAvailability"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).MetricAvailability = (System.Collections.Generic.List) content.GetValueForProperty("MetricAvailability",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).MetricAvailability, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.MetricAvailabilityTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("Id"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Id, global::System.Convert.ToString);
+ }
+ if (content.Contains("Dimension"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Dimension = (System.Collections.Generic.List) content.GetValueForProperty("Dimension",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).Dimension, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.LocalizableStringTypeConverter.ConvertFrom));
+ }
+ if (content.Contains("NameValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).NameValue = (string) content.GetValueForProperty("NameValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).NameValue, global::System.Convert.ToString);
+ }
+ if (content.Contains("NameLocalizedValue"))
+ {
+ ((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).NameLocalizedValue = (string) content.GetValueForProperty("NameLocalizedValue",((Microsoft.Azure.PowerShell.Cmdlets.Metric.Models.ISubscriptionScopeMetricDefinitionInternal)this).NameLocalizedValue, global::System.Convert.ToString);
+ }
+ AfterDeserializePSObject(content);
+ }
+
+ ///