diff --git a/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.csproj b/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.csproj index ea34b0621aac..c766cf07539b 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.csproj +++ b/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.csproj @@ -2,9 +2,9 @@ CustomProviders CustomProviders + CustomProviders.Autorest - diff --git a/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.format.ps1xml b/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.format.ps1xml index 90ef2b20da43..44a685d195d2 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.format.ps1xml +++ b/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.format.ps1xml @@ -2,67 +2,55 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomProvidersIdentity + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomProvidersIdentity + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association#Multiple - + - - - - - - - - - - AssociationName + Name ResourceGroupName - - ResourceProviderName - - - Scope - - - SubscriptionId - - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Association + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationProperties - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Association + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationProperties#Multiple - + + + + - Name + ProvisioningState + + + TargetResourceId @@ -70,27 +58,21 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationProperties + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationsList - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationProperties + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationsList#Multiple - - - - + - ProvisioningState - - - TargetResourceId + NextLink @@ -98,21 +80,45 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationsList + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomProvidersIdentity - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationsList + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomProvidersIdentity#Multiple - + + + + + + + + + + + + + - NextLink + AssociationName + + + ResourceGroupName + + + ResourceProviderName + + + Scope + + + SubscriptionId @@ -120,9 +126,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpActionRouteDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpActionRouteDefinition - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpActionRouteDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpActionRouteDefinition#Multiple @@ -154,9 +160,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifest + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifest + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest#Multiple @@ -166,6 +172,9 @@ + + + @@ -176,15 +185,18 @@ Name + + ResourceGroupName + - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifestProperties + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifestProperties - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifestProperties + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifestProperties#Multiple @@ -204,9 +216,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpResourceTypeRouteDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpResourceTypeRouteDefinition - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpResourceTypeRouteDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpResourceTypeRouteDefinition#Multiple @@ -238,9 +250,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpRouteDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpRouteDefinition - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpRouteDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpRouteDefinition#Multiple @@ -266,9 +278,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpValidations + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpValidations - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpValidations + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpValidations#Multiple @@ -294,9 +306,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinition - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinition#Multiple @@ -322,9 +334,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ListByCustomRpManifest + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ListByCustomRpManifest - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ListByCustomRpManifest + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ListByCustomRpManifest#Multiple @@ -344,9 +356,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Resource + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Resource - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Resource + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Resource#Multiple @@ -372,9 +384,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperation + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperation - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperation + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperation#Multiple @@ -394,9 +406,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationDisplay + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationDisplay - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationDisplay + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationDisplay#Multiple @@ -434,9 +446,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationList + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationList - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationList + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationList#Multiple @@ -456,9 +468,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProvidersUpdateTags + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProvidersUpdateTags - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProvidersUpdateTags + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProvidersUpdateTags#Multiple @@ -478,9 +490,9 @@ - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTags + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceTags - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTags + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceTags#Multiple diff --git a/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.psd1 b/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.psd1 index a1b9b7ffc68c..6f74f1f8d557 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.psd1 +++ b/generated/CustomProviders/CustomProviders.Autorest/Az.CustomProviders.psd1 @@ -11,8 +11,7 @@ DotNetFrameworkVersion = '4.7.2' RequiredAssemblies = './bin/Az.CustomProviders.private.dll' FormatsToProcess = './Az.CustomProviders.format.ps1xml' - FunctionsToExport = 'Get-AzCustomProvider', 'Get-AzCustomProviderAssociation', 'New-AzCustomProvider', 'New-AzCustomProviderAssociation', 'Remove-AzCustomProvider', 'Remove-AzCustomProviderAssociation', 'Update-AzCustomProvider', '*' - AliasesToExport = '*' + FunctionsToExport = 'Get-AzCustomProvider', 'Get-AzCustomProviderAssociation', 'New-AzCustomProvider', 'New-AzCustomProviderAssociation', 'Remove-AzCustomProvider', 'Remove-AzCustomProviderAssociation', 'Update-AzCustomProvider', 'Update-AzCustomProviderAssociation' PrivateData = @{ PSData = @{ Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'CustomProviders' diff --git a/generated/CustomProviders/CustomProviders.Autorest/Properties/AssemblyInfo.cs b/generated/CustomProviders/CustomProviders.Autorest/Properties/AssemblyInfo.cs index a7897af13570..b39a609080b2 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/Properties/AssemblyInfo.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/Properties/AssemblyInfo.cs @@ -1,28 +1,26 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); +// 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, +// distributed under the License is distributed on an ""AS IS"" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// ---------------------------------------------------------------------------------- +// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +// is regenerated. using System; using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("Microsoft Azure Powershell - CustomProviders")] -[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] -[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] -[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] - -[assembly: ComVisible(false)] -[assembly: CLSCompliant(false)] -[assembly: Guid("01fe683e-d13f-4059-98c4-dd84dd28e6be")] -[assembly: AssemblyVersion("0.1.2")] -[assembly: AssemblyFileVersion("0.1.2")] +[assembly: System.Reflection.AssemblyCompanyAttribute("Microsoft")] +[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")] +[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")] +[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - CustomProviders")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("0.1.2")] +[assembly: System.Reflection.AssemblyVersionAttribute("0.1.2")] +[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)] +[assembly: System.CLSCompliantAttribute(false)] diff --git a/generated/CustomProviders/CustomProviders.Autorest/check-dependencies.ps1 b/generated/CustomProviders/CustomProviders.Autorest/check-dependencies.ps1 index c29591c7bfe1..90ca9867ae40 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/check-dependencies.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/check-dependencies.ps1 @@ -12,13 +12,13 @@ # Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code # is regenerated. # ---------------------------------------------------------------------------------- -param([switch]$Isolated, [switch]$Accounts, [switch]$Pester, [switch]$Resources) +param([switch]$NotIsolated, [switch]$Accounts, [switch]$Pester, [switch]$Resources) $ErrorActionPreference = 'Stop' -if(-not $Isolated) { +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 -Isolated + & "$pwsh" -NoExit -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -NotIsolated return } diff --git a/generated/CustomProviders/CustomProviders.Autorest/exports/Get-AzCustomProvider.ps1 b/generated/CustomProviders/CustomProviders.Autorest/exports/Get-AzCustomProvider.ps1 index b1ef6303bed3..8b717bd36faf 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/exports/Get-AzCustomProvider.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/exports/Get-AzCustomProvider.ps1 @@ -27,7 +27,7 @@ Get-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type | Format-List .Inputs Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest .Notes COMPLEX PARAMETER PROPERTIES @@ -44,7 +44,7 @@ INPUTOBJECT : Identity Parameter https://learn.microsoft.com/powershell/module/az.customproviders/get-azcustomprovider #> function Get-AzCustomProvider { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest])] [CmdletBinding(DefaultParameterSetName='List1', PositionalBinding=$false)] param( [Parameter(ParameterSetName='Get', Mandatory)] @@ -76,7 +76,6 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, [Parameter()] @@ -135,6 +134,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -159,9 +167,7 @@ begin { List = 'Az.CustomProviders.private\Get-AzCustomProvider_List'; List1 = 'Az.CustomProviders.private\Get-AzCustomProvider_List1'; } - if (('Get', 'List', 'List1') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) { - $testPlayback = $false - $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + if (('Get', 'List', 'List1') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) { if ($testPlayback) { $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') } else { @@ -175,6 +181,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/exports/Get-AzCustomProviderAssociation.ps1 b/generated/CustomProviders/CustomProviders.Autorest/exports/Get-AzCustomProviderAssociation.ps1 index 877b762a4b56..f3f285426ad5 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/exports/Get-AzCustomProviderAssociation.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/exports/Get-AzCustomProviderAssociation.ps1 @@ -27,7 +27,7 @@ Get-AzCustomProviderAssociation -Scope $resourceId -Name MyAssoc .Inputs Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation .Notes COMPLEX PARAMETER PROPERTIES @@ -44,7 +44,7 @@ INPUTOBJECT : Identity Parameter https://learn.microsoft.com/powershell/module/az.customproviders/get-azcustomproviderassociation #> function Get-AzCustomProviderAssociation { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation])] [CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] param( [Parameter(ParameterSetName='Get', Mandatory)] @@ -65,7 +65,6 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, [Parameter()] @@ -124,6 +123,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -154,6 +162,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/exports/New-AzCustomProvider.ps1 b/generated/CustomProviders/CustomProviders.Autorest/exports/New-AzCustomProvider.ps1 index 68f82f8e9258..9fbb4b8e65ba 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/exports/New-AzCustomProvider.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/exports/New-AzCustomProvider.ps1 @@ -16,16 +16,16 @@ <# .Synopsis -Creates or updates the custom resource provider. +create the custom resource provider. .Description -Creates or updates the custom resource provider. +create the custom resource provider. .Example New-AzCustomProvider -ResourceGroupName myRG -Name Namespace.Type -Location "West US 2" -ResourceType @{Name="CustomRoute1"; Endpoint="https://www.contoso.com/"} .Example New-AzCustomProvider -ResourceGroupName myRG -Name Namespace2.Type -Location "West US 2" -ResourceType @{Name="CustomRoute1"; Endpoint="https://www.contoso.com/"}, @{Name="Associations"; Endpoint="https://contoso.com/myService"; RoutingType="Proxy,Cache,Extension"} .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest .Notes COMPLEX PARAMETER PROPERTIES @@ -34,21 +34,21 @@ To create the parameters described below, construct a hash table containing the ACTION : A list of actions that the custom resource provider implements. Endpoint : The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}') Name : The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') - [RoutingType ]: The routing types that are supported for action requests. + [RoutingType ]: The routing types that are supported for action requests. RESOURCETYPE : A list of resource types that the custom resource provider implements. Endpoint : The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}') Name : The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') - [RoutingType ]: The routing types that are supported for resource requests. + [RoutingType ]: The routing types that are supported for resource requests. VALIDATION : A list of validations to run on the custom resource provider's requests. Specification : A link to the validation specification. The specification must be hosted on raw.githubusercontent.com. - [ValidationType ]: The type of validation to run against a matching request. + [ValidationType ]: The type of validation to run against a matching request. .Link https://learn.microsoft.com/powershell/module/az.customproviders/new-azcustomprovider #> function New-AzCustomProvider { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest])] [CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] param( [Parameter(Mandatory)] @@ -73,43 +73,52 @@ param( # 00000000-0000-0000-0000-000000000000) ${SubscriptionId}, - [Parameter(Mandatory)] + [Parameter(ParameterSetName='CreateExpanded', Mandatory)] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] [System.String] # Resource location ${Location}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [AllowEmptyCollection()] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[]] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition[]] # A list of actions that the custom resource provider implements. - # To construct, see NOTES section for ACTION properties and create a hash table. ${Action}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [AllowEmptyCollection()] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[]] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition[]] # A list of resource types that the custom resource provider implements. - # To construct, see NOTES section for RESOURCETYPE properties and create a hash table. ${ResourceType}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags]))] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags]))] [System.Collections.Hashtable] # Resource tags ${Tag}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [AllowEmptyCollection()] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[]] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations[]] # A list of validations to run on the custom resource provider's requests. - # To construct, see NOTES section for VALIDATION properties and create a hash table. ${Validation}, + [Parameter(ParameterSetName='CreateViaJsonFilePath', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Path of Json file supplied to the Create operation + ${JsonFilePath}, + + [Parameter(ParameterSetName='CreateViaJsonString', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Json string supplied to the Create operation + ${JsonString}, + [Parameter()] [Alias('AzureRMContext', 'AzureCredential')] [ValidateNotNull()] @@ -178,6 +187,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -198,10 +216,10 @@ begin { $mapping = @{ CreateExpanded = 'Az.CustomProviders.private\New-AzCustomProvider_CreateExpanded'; + CreateViaJsonFilePath = 'Az.CustomProviders.private\New-AzCustomProvider_CreateViaJsonFilePath'; + CreateViaJsonString = 'Az.CustomProviders.private\New-AzCustomProvider_CreateViaJsonString'; } - if (('CreateExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) { - $testPlayback = $false - $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + if (('CreateExpanded', 'CreateViaJsonFilePath', 'CreateViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) { if ($testPlayback) { $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') } else { @@ -215,6 +233,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/exports/New-AzCustomProviderAssociation.ps1 b/generated/CustomProviders/CustomProviders.Autorest/exports/New-AzCustomProviderAssociation.ps1 index 3652be20d71f..f987791885d7 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/exports/New-AzCustomProviderAssociation.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/exports/New-AzCustomProviderAssociation.ps1 @@ -16,20 +16,20 @@ <# .Synopsis -Create or update an association. +create an association. .Description -Create or update an association. +create an association. .Example $provider = Get-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type New-AzCustomProviderAssociation -Scope $resourceId -Name MyAssoc -TargetResourceId $provider.Id .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation .Link https://learn.microsoft.com/powershell/module/az.customproviders/new-azcustomproviderassociation #> function New-AzCustomProviderAssociation { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation])] [CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] param( [Parameter(Mandatory)] @@ -47,12 +47,24 @@ param( # For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource. ${Scope}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] [System.String] # The REST resource instance of the target resource for this association. ${TargetResourceId}, + [Parameter(ParameterSetName='CreateViaJsonFilePath', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Path of Json file supplied to the Create operation + ${JsonFilePath}, + + [Parameter(ParameterSetName='CreateViaJsonString', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Json string supplied to the Create operation + ${JsonString}, + [Parameter()] [Alias('AzureRMContext', 'AzureCredential')] [ValidateNotNull()] @@ -121,6 +133,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -141,6 +162,8 @@ begin { $mapping = @{ CreateExpanded = 'Az.CustomProviders.private\New-AzCustomProviderAssociation_CreateExpanded'; + CreateViaJsonFilePath = 'Az.CustomProviders.private\New-AzCustomProviderAssociation_CreateViaJsonFilePath'; + CreateViaJsonString = 'Az.CustomProviders.private\New-AzCustomProviderAssociation_CreateViaJsonString'; } $cmdInfo = Get-Command -Name $mapping[$parameterSet] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet) @@ -149,6 +172,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/exports/ProxyCmdletDefinitions.ps1 b/generated/CustomProviders/CustomProviders.Autorest/exports/ProxyCmdletDefinitions.ps1 index bfec6f8d358c..bc577e1533f2 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/exports/ProxyCmdletDefinitions.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/exports/ProxyCmdletDefinitions.ps1 @@ -27,7 +27,7 @@ Get-AzCustomProviderAssociation -Scope $resourceId -Name MyAssoc .Inputs Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation .Notes COMPLEX PARAMETER PROPERTIES @@ -44,7 +44,7 @@ INPUTOBJECT : Identity Parameter https://learn.microsoft.com/powershell/module/az.customproviders/get-azcustomproviderassociation #> function Get-AzCustomProviderAssociation { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation])] [CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] param( [Parameter(ParameterSetName='Get', Mandatory)] @@ -65,7 +65,6 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, [Parameter()] @@ -124,6 +123,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -154,6 +162,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) @@ -210,7 +221,7 @@ Get-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type | Format-List .Inputs Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest .Notes COMPLEX PARAMETER PROPERTIES @@ -227,7 +238,7 @@ INPUTOBJECT : Identity Parameter https://learn.microsoft.com/powershell/module/az.customproviders/get-azcustomprovider #> function Get-AzCustomProvider { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest])] [CmdletBinding(DefaultParameterSetName='List1', PositionalBinding=$false)] param( [Parameter(ParameterSetName='Get', Mandatory)] @@ -259,7 +270,6 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, [Parameter()] @@ -318,6 +328,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -342,9 +361,7 @@ begin { List = 'Az.CustomProviders.private\Get-AzCustomProvider_List'; List1 = 'Az.CustomProviders.private\Get-AzCustomProvider_List1'; } - if (('Get', 'List', 'List1') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) { - $testPlayback = $false - $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + if (('Get', 'List', 'List1') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) { if ($testPlayback) { $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') } else { @@ -358,6 +375,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) @@ -403,20 +423,20 @@ end { <# .Synopsis -Create or update an association. +create an association. .Description -Create or update an association. +create an association. .Example $provider = Get-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type New-AzCustomProviderAssociation -Scope $resourceId -Name MyAssoc -TargetResourceId $provider.Id .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation .Link https://learn.microsoft.com/powershell/module/az.customproviders/new-azcustomproviderassociation #> function New-AzCustomProviderAssociation { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation])] [CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] param( [Parameter(Mandatory)] @@ -434,12 +454,24 @@ param( # For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource. ${Scope}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] [System.String] # The REST resource instance of the target resource for this association. ${TargetResourceId}, + [Parameter(ParameterSetName='CreateViaJsonFilePath', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Path of Json file supplied to the Create operation + ${JsonFilePath}, + + [Parameter(ParameterSetName='CreateViaJsonString', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Json string supplied to the Create operation + ${JsonString}, + [Parameter()] [Alias('AzureRMContext', 'AzureCredential')] [ValidateNotNull()] @@ -508,6 +540,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -528,6 +569,8 @@ begin { $mapping = @{ CreateExpanded = 'Az.CustomProviders.private\New-AzCustomProviderAssociation_CreateExpanded'; + CreateViaJsonFilePath = 'Az.CustomProviders.private\New-AzCustomProviderAssociation_CreateViaJsonFilePath'; + CreateViaJsonString = 'Az.CustomProviders.private\New-AzCustomProviderAssociation_CreateViaJsonString'; } $cmdInfo = Get-Command -Name $mapping[$parameterSet] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet) @@ -536,6 +579,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) @@ -581,16 +627,16 @@ end { <# .Synopsis -Creates or updates the custom resource provider. +create the custom resource provider. .Description -Creates or updates the custom resource provider. +create the custom resource provider. .Example New-AzCustomProvider -ResourceGroupName myRG -Name Namespace.Type -Location "West US 2" -ResourceType @{Name="CustomRoute1"; Endpoint="https://www.contoso.com/"} .Example New-AzCustomProvider -ResourceGroupName myRG -Name Namespace2.Type -Location "West US 2" -ResourceType @{Name="CustomRoute1"; Endpoint="https://www.contoso.com/"}, @{Name="Associations"; Endpoint="https://contoso.com/myService"; RoutingType="Proxy,Cache,Extension"} .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest .Notes COMPLEX PARAMETER PROPERTIES @@ -599,21 +645,21 @@ To create the parameters described below, construct a hash table containing the ACTION : A list of actions that the custom resource provider implements. Endpoint : The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}') Name : The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') - [RoutingType ]: The routing types that are supported for action requests. + [RoutingType ]: The routing types that are supported for action requests. RESOURCETYPE : A list of resource types that the custom resource provider implements. Endpoint : The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}') Name : The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') - [RoutingType ]: The routing types that are supported for resource requests. + [RoutingType ]: The routing types that are supported for resource requests. VALIDATION : A list of validations to run on the custom resource provider's requests. Specification : A link to the validation specification. The specification must be hosted on raw.githubusercontent.com. - [ValidationType ]: The type of validation to run against a matching request. + [ValidationType ]: The type of validation to run against a matching request. .Link https://learn.microsoft.com/powershell/module/az.customproviders/new-azcustomprovider #> function New-AzCustomProvider { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest])] [CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] param( [Parameter(Mandatory)] @@ -638,43 +684,52 @@ param( # 00000000-0000-0000-0000-000000000000) ${SubscriptionId}, - [Parameter(Mandatory)] + [Parameter(ParameterSetName='CreateExpanded', Mandatory)] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] [System.String] # Resource location ${Location}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [AllowEmptyCollection()] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[]] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition[]] # A list of actions that the custom resource provider implements. - # To construct, see NOTES section for ACTION properties and create a hash table. ${Action}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [AllowEmptyCollection()] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[]] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition[]] # A list of resource types that the custom resource provider implements. - # To construct, see NOTES section for RESOURCETYPE properties and create a hash table. ${ResourceType}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags]))] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags]))] [System.Collections.Hashtable] # Resource tags ${Tag}, - [Parameter()] + [Parameter(ParameterSetName='CreateExpanded')] [AllowEmptyCollection()] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[]] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations[]] # A list of validations to run on the custom resource provider's requests. - # To construct, see NOTES section for VALIDATION properties and create a hash table. ${Validation}, + [Parameter(ParameterSetName='CreateViaJsonFilePath', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Path of Json file supplied to the Create operation + ${JsonFilePath}, + + [Parameter(ParameterSetName='CreateViaJsonString', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Json string supplied to the Create operation + ${JsonString}, + [Parameter()] [Alias('AzureRMContext', 'AzureCredential')] [ValidateNotNull()] @@ -743,6 +798,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -763,10 +827,10 @@ begin { $mapping = @{ CreateExpanded = 'Az.CustomProviders.private\New-AzCustomProvider_CreateExpanded'; + CreateViaJsonFilePath = 'Az.CustomProviders.private\New-AzCustomProvider_CreateViaJsonFilePath'; + CreateViaJsonString = 'Az.CustomProviders.private\New-AzCustomProvider_CreateViaJsonString'; } - if (('CreateExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) { - $testPlayback = $false - $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + if (('CreateExpanded', 'CreateViaJsonFilePath', 'CreateViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) { if ($testPlayback) { $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') } else { @@ -780,6 +844,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) @@ -873,7 +940,6 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, [Parameter()] @@ -950,6 +1016,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -979,6 +1054,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) @@ -1081,7 +1159,6 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, [Parameter()] @@ -1158,6 +1235,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -1180,9 +1266,7 @@ begin { Delete = 'Az.CustomProviders.private\Remove-AzCustomProvider_Delete'; DeleteViaIdentity = 'Az.CustomProviders.private\Remove-AzCustomProvider_DeleteViaIdentity'; } - if (('Delete') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) { - $testPlayback = $false - $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + if (('Delete') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) { if ($testPlayback) { $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') } else { @@ -1196,6 +1280,220 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } + $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.CustomProviders.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 +update an association. +.Description +update an association. +.Example +$provider = Get-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type +Update-AzCustomProviderAssociation -Scope $resourceId -Name MyAssoc -TargetResourceId $provider.Id + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AssociationName ]: The name of the association. + [Id ]: Resource identity path + [ResourceGroupName ]: The name of the resource group. + [ResourceProviderName ]: The name of the resource provider. + [Scope ]: The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource. + [SubscriptionId ]: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +.Link +https://learn.microsoft.com/powershell/module/az.customproviders/update-azcustomproviderassociation +#> +function Update-AzCustomProviderAssociation { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation])] +[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Alias('AssociationName')] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] + [System.String] + # The name of the association. + ${Name}, + + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] + [System.String] + # The scope of the association. + # The scope can be any valid REST resource instance. + # For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource. + ${Scope}, + + [Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] + # Identity Parameter + ${InputObject}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # The REST resource instance of the target resource for this association. + ${TargetResourceId}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Run the command as a job + ${AsJob}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Run the command asynchronously + ${NoWait}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } + + 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.CustomProviders.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 = @{ + UpdateExpanded = 'Az.CustomProviders.private\Update-AzCustomProviderAssociation_UpdateExpanded'; + UpdateViaIdentityExpanded = 'Az.CustomProviders.private\Update-AzCustomProviderAssociation_UpdateViaIdentityExpanded'; + } + $cmdInfo = Get-Command -Name $mapping[$parameterSet] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){ + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) @@ -1241,10 +1539,10 @@ end { <# .Synopsis -Updates an existing custom resource provider. +update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. .Description -Updates an existing custom resource provider. +update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. .Example Update-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type -Tag @{MyTag="MyValue"} | Format-List @@ -1254,7 +1552,7 @@ Get-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type | Update-AzCus .Inputs Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest .Notes COMPLEX PARAMETER PROPERTIES @@ -1271,10 +1569,12 @@ INPUTOBJECT : Identity Parameter https://learn.microsoft.com/powershell/module/az.customproviders/update-azcustomprovider #> function Update-AzCustomProvider { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest])] [CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] param( [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)] + [Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)] [Alias('ResourceProviderName')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [System.String] @@ -1282,12 +1582,16 @@ param( ${Name}, [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)] + [Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [System.String] # The name of the resource group. ${ResourceGroupName}, [Parameter(ParameterSetName='UpdateExpanded')] + [Parameter(ParameterSetName='UpdateViaJsonFilePath')] + [Parameter(ParameterSetName='UpdateViaJsonString')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] [System.String] @@ -1300,16 +1604,28 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, - [Parameter()] + [Parameter(ParameterSetName='UpdateExpanded')] + [Parameter(ParameterSetName='UpdateViaIdentityExpanded')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags]))] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags]))] [System.Collections.Hashtable] # Resource tags ${Tag}, + [Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Path of Json file supplied to the Update operation + ${JsonFilePath}, + + [Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Json string supplied to the Update operation + ${JsonString}, + [Parameter()] [Alias('AzureRMContext', 'AzureCredential')] [ValidateNotNull()] @@ -1366,6 +1682,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -1387,10 +1712,10 @@ begin { $mapping = @{ UpdateExpanded = 'Az.CustomProviders.private\Update-AzCustomProvider_UpdateExpanded'; UpdateViaIdentityExpanded = 'Az.CustomProviders.private\Update-AzCustomProvider_UpdateViaIdentityExpanded'; + UpdateViaJsonFilePath = 'Az.CustomProviders.private\Update-AzCustomProvider_UpdateViaJsonFilePath'; + UpdateViaJsonString = 'Az.CustomProviders.private\Update-AzCustomProvider_UpdateViaJsonString'; } - if (('UpdateExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) { - $testPlayback = $false - $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + if (('UpdateExpanded', 'UpdateViaJsonFilePath', 'UpdateViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) { if ($testPlayback) { $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') } else { @@ -1404,6 +1729,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/exports/Remove-AzCustomProvider.ps1 b/generated/CustomProviders/CustomProviders.Autorest/exports/Remove-AzCustomProvider.ps1 index 2619e226ff64..81a3d69e1e8c 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/exports/Remove-AzCustomProvider.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/exports/Remove-AzCustomProvider.ps1 @@ -73,7 +73,6 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, [Parameter()] @@ -150,6 +149,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -172,9 +180,7 @@ begin { Delete = 'Az.CustomProviders.private\Remove-AzCustomProvider_Delete'; DeleteViaIdentity = 'Az.CustomProviders.private\Remove-AzCustomProvider_DeleteViaIdentity'; } - if (('Delete') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) { - $testPlayback = $false - $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + if (('Delete') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) { if ($testPlayback) { $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') } else { @@ -188,6 +194,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/exports/Remove-AzCustomProviderAssociation.ps1 b/generated/CustomProviders/CustomProviders.Autorest/exports/Remove-AzCustomProviderAssociation.ps1 index 49b44806924d..9e4022b637d9 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/exports/Remove-AzCustomProviderAssociation.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/exports/Remove-AzCustomProviderAssociation.ps1 @@ -64,7 +64,6 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, [Parameter()] @@ -141,6 +140,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -170,6 +178,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/exports/Update-AzCustomProvider.ps1 b/generated/CustomProviders/CustomProviders.Autorest/exports/Update-AzCustomProvider.ps1 index c3a2fe2be20c..969461f92a80 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/exports/Update-AzCustomProvider.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/exports/Update-AzCustomProvider.ps1 @@ -16,10 +16,10 @@ <# .Synopsis -Updates an existing custom resource provider. +update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. .Description -Updates an existing custom resource provider. +update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. .Example Update-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type -Tag @{MyTag="MyValue"} | Format-List @@ -29,7 +29,7 @@ Get-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type | Update-AzCus .Inputs Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest .Notes COMPLEX PARAMETER PROPERTIES @@ -46,10 +46,12 @@ INPUTOBJECT : Identity Parameter https://learn.microsoft.com/powershell/module/az.customproviders/update-azcustomprovider #> function Update-AzCustomProvider { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest])] [CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] param( [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)] + [Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)] [Alias('ResourceProviderName')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [System.String] @@ -57,12 +59,16 @@ param( ${Name}, [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)] + [Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [System.String] # The name of the resource group. ${ResourceGroupName}, [Parameter(ParameterSetName='UpdateExpanded')] + [Parameter(ParameterSetName='UpdateViaJsonFilePath')] + [Parameter(ParameterSetName='UpdateViaJsonString')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] [System.String] @@ -75,16 +81,28 @@ param( [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] # Identity Parameter - # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ${InputObject}, - [Parameter()] + [Parameter(ParameterSetName='UpdateExpanded')] + [Parameter(ParameterSetName='UpdateViaIdentityExpanded')] [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags]))] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags]))] [System.Collections.Hashtable] # Resource tags ${Tag}, + [Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Path of Json file supplied to the Update operation + ${JsonFilePath}, + + [Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # Json string supplied to the Update operation + ${JsonString}, + [Parameter()] [Alias('AzureRMContext', 'AzureCredential')] [ValidateNotNull()] @@ -141,6 +159,15 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() @@ -162,10 +189,10 @@ begin { $mapping = @{ UpdateExpanded = 'Az.CustomProviders.private\Update-AzCustomProvider_UpdateExpanded'; UpdateViaIdentityExpanded = 'Az.CustomProviders.private\Update-AzCustomProvider_UpdateViaIdentityExpanded'; + UpdateViaJsonFilePath = 'Az.CustomProviders.private\Update-AzCustomProvider_UpdateViaJsonFilePath'; + UpdateViaJsonString = 'Az.CustomProviders.private\Update-AzCustomProvider_UpdateViaJsonString'; } - if (('UpdateExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId')) { - $testPlayback = $false - $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + if (('UpdateExpanded', 'UpdateViaJsonFilePath', 'UpdateViaJsonString') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) { if ($testPlayback) { $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') } else { @@ -179,6 +206,9 @@ begin { [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/exports/Update-AzCustomProviderAssociation.ps1 b/generated/CustomProviders/CustomProviders.Autorest/exports/Update-AzCustomProviderAssociation.ps1 new file mode 100644 index 000000000000..ddb6fbc1b41c --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/exports/Update-AzCustomProviderAssociation.ps1 @@ -0,0 +1,226 @@ + +# ---------------------------------------------------------------------------------- +# 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 +update an association. +.Description +update an association. +.Example +$provider = Get-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type +Update-AzCustomProviderAssociation -Scope $resourceId -Name MyAssoc -TargetResourceId $provider.Id + +.Inputs +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +INPUTOBJECT : Identity Parameter + [AssociationName ]: The name of the association. + [Id ]: Resource identity path + [ResourceGroupName ]: The name of the resource group. + [ResourceProviderName ]: The name of the resource provider. + [Scope ]: The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource. + [SubscriptionId ]: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +.Link +https://learn.microsoft.com/powershell/module/az.customproviders/update-azcustomproviderassociation +#> +function Update-AzCustomProviderAssociation { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation])] +[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Alias('AssociationName')] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] + [System.String] + # The name of the association. + ${Name}, + + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] + [System.String] + # The scope of the association. + # The scope can be any valid REST resource instance. + # For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource. + ${Scope}, + + [Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity] + # Identity Parameter + ${InputObject}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Body')] + [System.String] + # The REST resource instance of the target resource for this association. + ${TargetResourceId}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Run the command as a job + ${AsJob}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Run the command asynchronously + ${NoWait}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } + + $context = Get-AzContext + if (-not $context -and -not $testPlayback) { + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." + exit + } + + 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.CustomProviders.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 = @{ + UpdateExpanded = 'Az.CustomProviders.private\Update-AzCustomProviderAssociation_UpdateExpanded'; + UpdateViaIdentityExpanded = 'Az.CustomProviders.private\Update-AzCustomProviderAssociation_UpdateViaIdentityExpanded'; + } + $cmdInfo = Get-Command -Name $mapping[$parameterSet] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){ + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } + $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.CustomProviders.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/generated/CustomProviders/CustomProviders.Autorest/generate-info.json b/generated/CustomProviders/CustomProviders.Autorest/generate-info.json index 6deccc63555a..5d5734f4e038 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generate-info.json +++ b/generated/CustomProviders/CustomProviders.Autorest/generate-info.json @@ -1,3 +1,3 @@ { - "generate_Id": "cbd1450c-a41e-4af7-9b13-23452be1a95e" + "generate_Id": "6b3b34b2-7cb4-4de3-8d33-279bdbd868f6" } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/Module.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/Module.cs index 8c0001e8e584..384902022486 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/Module.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/Module.cs @@ -28,12 +28,20 @@ public partial class Module 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.CustomProviders.Module _instance; + /// the ISendAsync pipeline instance private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline _pipeline; /// the ISendAsync pipeline instance (when proxy is enabled) private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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(); @@ -56,11 +64,8 @@ public partial class Module /// The delegate to get the telemetry info. public GetTelemetryInfoDelegate GetTelemetryInfo { get; set; } - /// Backing field for property. - private static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module _instance; - /// the singleton of this module class - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module Instance => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module._instance?? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module._instance = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module()); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders"; @@ -125,9 +130,17 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline C /// Initialization steps performed after the module is loaded. public void Init() { - 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(); + 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. diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/CustomProviders.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/CustomProviders.cs index 3254c916ee9f..b5c23eb160e9 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/CustomProviders.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/CustomProviders.cs @@ -14,7 +14,7 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders public partial class CustomProviders { - /// Create or update an association. + /// update an association. /// The scope of the association. The scope can be any valid REST resource instance. For example, use /// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' /// for a virtual machine resource. @@ -25,10 +25,11 @@ public partial class CustomProviders /// elsewhere). /// an instance that will receive events. /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 AssociationsCreateOrUpdate(string scope, string associationName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task AssociationsCreateOrUpdate(string scope, string associationName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -53,15 +54,15 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // set body content - request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + 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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.AssociationsCreateOrUpdate_Call(request,onOk,onDefault,eventListener,sender); + await this.AssociationsCreateOrUpdate_Call (request, onOk,onDefault,eventListener,sender); } } - /// Create or update an association. + /// update an association. /// /// The parameters required to create or update an association. /// a delegate that is called when the remote service returns 200 (OK). @@ -69,10 +70,11 @@ public partial class CustomProviders /// elsewhere). /// an instance that will receive events. /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 AssociationsCreateOrUpdateViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task AssociationsCreateOrUpdateViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -108,15 +110,364 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // set body content - request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + 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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.AssociationsCreateOrUpdate_Call(request,onOk,onDefault,eventListener,sender); + await this.AssociationsCreateOrUpdate_Call (request, onOk,onDefault,eventListener,sender); } } - /// Actual wire call for method. + /// update an association. + /// + /// The parameters required to create or update an association. + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 AssociationsCreateOrUpdateViaIdentityWithResult(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/(?[^/]+)/providers/Microsoft.CustomProviders/associations/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var associationName = _match.Groups["associationName"].Value; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/" + + scope + + "/providers/Microsoft.CustomProviders/associations/" + + associationName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.AssociationsCreateOrUpdateWithResult_Call (request, eventListener,sender); + } + } + + /// update an association. + /// The scope of the association. The scope can be any valid REST resource instance. For example, use + /// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' + /// for a virtual machine resource. + /// The name of the association. + /// Json string supplied to the AssociationsCreateOrUpdate 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.CustomProviders.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 AssociationsCreateOrUpdateViaJsonString(string scope, string associationName, 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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/" + + (scope) + + "/providers/Microsoft.CustomProviders/associations/" + + global::System.Uri.EscapeDataString(associationName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.AssociationsCreateOrUpdate_Call (request, onOk,onDefault,eventListener,sender); + } + } + + /// update an association. + /// The scope of the association. The scope can be any valid REST resource instance. For example, use + /// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' + /// for a virtual machine resource. + /// The name of the association. + /// Json string supplied to the AssociationsCreateOrUpdate operation + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 AssociationsCreateOrUpdateViaJsonStringWithResult(string scope, string associationName, global::System.String jsonString, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/" + + (scope) + + "/providers/Microsoft.CustomProviders/associations/" + + global::System.Uri.EscapeDataString(associationName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.AssociationsCreateOrUpdateWithResult_Call (request, eventListener,sender); + } + } + + /// update an association. + /// The scope of the association. The scope can be any valid REST resource instance. For example, use + /// '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' + /// for a virtual machine resource. + /// The name of the association. + /// The parameters required to create or update an association. + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 AssociationsCreateOrUpdateWithResult(string scope, string associationName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/" + + (scope) + + "/providers/Microsoft.CustomProviders/associations/" + + global::System.Uri.EscapeDataString(associationName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.AssociationsCreateOrUpdateWithResult_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.CustomProviders.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 AssociationsCreateOrUpdateWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + // this operation supports x-ms-long-running-operation + var _originalUri = request.RequestUri.AbsoluteUri; + var sendTask = sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 0); if( eventListener.Token.IsCancellationRequested ) { return null; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + // declared final-state-via: default + var asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = _response.GetFirstHeader(@"Location"); + var operationLocation = _response.GetFirstHeader(@"Operation-Location"); + while (request.Method == System.Net.Http.HttpMethod.Put && _response.StatusCode == global::System.Net.HttpStatusCode.OK || _response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) + { + // delay before making the next polling request + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + + // while we wait, let's grab the headers and get ready to poll. + if (!System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Azure-AsyncOperation"))) { + asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); + } + if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Location"))) { + location = _response.GetFirstHeader(@"Location"); + } + if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Operation-Location"))) { + operationLocation = _response.GetFirstHeader(@"Operation-Location"); + } + var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? global::System.String.IsNullOrEmpty(operationLocation) ? _originalUri : operationLocation : location : asyncOperation; + request = request.CloneAndDispose(new global::System.Uri(_uri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); + + // and let's look at the current response body and see if we have some information we can give back to the listener + var content = await _response.Content.ReadAsStringAsync(); + + // drop the old response + _response?.Dispose(); + + // make the polling call + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + + // if we got back an OK, take a peek inside and see if it's done + if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) + { + var error = false; + try { + if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) + { + var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); + if( state is null ) + { + // the body doesn't contain any information that has the state of the LRO + // we're going to just get out, and let the consumer have the result + break; + } + + switch( state?.ToString()?.ToLower() ) + { + case "failed": + error = true; + break; + case "succeeded": + case "canceled": + // we're done polling. + break; + + default: + // need to keep polling! + _response.StatusCode = global::System.Net.HttpStatusCode.Created; + continue; + } + } + } catch { + // if we run into a problem peeking into the result, + // we really don't want to do anything special. + } + if (error) { + throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); + } + } + + // check for terminal status code + if (_response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) + { + continue; + } + // we are done polling, do a request on final target? + if (!string.IsNullOrWhiteSpace(_originalUri)) + { + // create a new request with the final uri + request = request.CloneAndDispose(new global::System.Uri(_originalUri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); + + // drop the old response + _response?.Dispose(); + + // make the final call + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + break; + } + } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) ); + return await _result; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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.CustomProviders.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 @@ -126,31 +477,28 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task AssociationsCreateOrUpdate_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + internal async global::System.Threading.Tasks.Task AssociationsCreateOrUpdate_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { using( NoSynchronizationContext ) { global::System.Net.Http.HttpResponseMessage _response = null; try { + // this operation supports x-ms-long-running-operation + var _originalUri = request.RequestUri.AbsoluteUri; var sendTask = sender.SendAsync(request, eventListener); await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 0); if( eventListener.Token.IsCancellationRequested ) { return; } _response = await sendTask; await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - // this operation supports x-ms-long-running-operation - var _originalUri = request.RequestUri.AbsoluteUri; // declared final-state-via: default var asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); var location = _response.GetFirstHeader(@"Location"); + var operationLocation = _response.GetFirstHeader(@"Operation-Location"); while (request.Method == System.Net.Http.HttpMethod.Put && _response.StatusCode == global::System.Net.HttpStatusCode.OK || _response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) { - - // get the delay before polling. (default to 30 seconds if not present) - int delay = (int)(_response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, $"Delaying {delay} seconds before polling.", _response); if( eventListener.Token.IsCancellationRequested ) { return; } - - // start the delay timer (we'll await later...) - var waiting = global::System.Threading.Tasks.Task.Delay(delay * 1000, eventListener.Token ); + // delay before making the next polling request + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } // while we wait, let's grab the headers and get ready to poll. if (!System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Azure-AsyncOperation"))) { @@ -159,15 +507,14 @@ public partial class CustomProviders if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Location"))) { location = _response.GetFirstHeader(@"Location"); } - var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? _originalUri : location : asyncOperation; + if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Operation-Location"))) { + operationLocation = _response.GetFirstHeader(@"Operation-Location"); + } + var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? global::System.String.IsNullOrEmpty(operationLocation) ? _originalUri : operationLocation : location : asyncOperation; request = request.CloneAndDispose(new global::System.Uri(_uri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); // and let's look at the current response body and see if we have some information we can give back to the listener var content = await _response.Content.ReadAsStringAsync(); - await waiting; - - // check for cancellation - if( eventListener.Token.IsCancellationRequested ) { return; } // drop the old response _response?.Dispose(); @@ -176,45 +523,45 @@ public partial class CustomProviders _response = await sender.SendAsync(request, eventListener); await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - // if we got back an OK, take a peek inside and see if it's done - if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) - { - var error = false; - try { - if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) - { - var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); - if( state is null ) - { - // the body doesn't contain any information that has the state of the LRO - // we're going to just get out, and let the consumer have the result - break; - } - - switch( state?.ToString()?.ToLower() ) - { - case "failed": - error = true; + // if we got back an OK, take a peek inside and see if it's done + if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) + { + var error = false; + try { + if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) + { + var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); + if( state is null ) + { + // the body doesn't contain any information that has the state of the LRO + // we're going to just get out, and let the consumer have the result break; - case "succeeded": - case "canceled": - // we're done polling. - break; - - default: - // need to keep polling! - _response.StatusCode = global::System.Net.HttpStatusCode.Created; - continue; - } - } - } catch { - // if we run into a problem peeking into the result, - // we really don't want to do anything special. - } - if (error) { - throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); - } - } + } + + switch( state?.ToString()?.ToLower() ) + { + case "failed": + error = true; + break; + case "succeeded": + case "canceled": + // we're done polling. + break; + + default: + // need to keep polling! + _response.StatusCode = global::System.Net.HttpStatusCode.Created; + continue; + } + } + } catch { + // if we run into a problem peeking into the result, + // we really don't want to do anything special. + } + if (error) { + throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); + } + } // check for terminal status code if (_response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) @@ -236,6 +583,7 @@ public partial class CustomProviders break; } } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; } var _contentType = _response.Content.Headers.ContentType?.MediaType; switch ( _response.StatusCode ) @@ -243,13 +591,13 @@ public partial class CustomProviders case global::System.Net.HttpStatusCode.OK: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Association.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } default: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } } @@ -277,7 +625,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task AssociationsCreateOrUpdate_Validate(string scope, string associationName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) + internal async global::System.Threading.Tasks.Task AssociationsCreateOrUpdate_Validate(string scope, string associationName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) { using( NoSynchronizationContext ) { @@ -300,7 +648,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task AssociationsDelete(string scope, string associationName, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task AssociationsDelete(string scope, string associationName, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -325,7 +673,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.AssociationsDelete_Call(request,onOk,onNoContent,onDefault,eventListener,sender); + await this.AssociationsDelete_Call (request, onOk,onNoContent,onDefault,eventListener,sender); } } @@ -340,7 +688,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task AssociationsDeleteViaIdentity(global::System.String viaIdentity, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task AssociationsDeleteViaIdentity(global::System.String viaIdentity, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -376,11 +724,11 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.AssociationsDelete_Call(request,onOk,onNoContent,onDefault,eventListener,sender); + await this.AssociationsDelete_Call (request, onOk,onNoContent,onDefault,eventListener,sender); } } - /// Actual wire call for method. + /// 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 204 (NoContent). @@ -391,32 +739,29 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task AssociationsDelete_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + internal async global::System.Threading.Tasks.Task AssociationsDelete_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { using( NoSynchronizationContext ) { global::System.Net.Http.HttpResponseMessage _response = null; try { + // this operation supports x-ms-long-running-operation + var _originalUri = request.RequestUri.AbsoluteUri; var sendTask = sender.SendAsync(request, eventListener); await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 0); if( eventListener.Token.IsCancellationRequested ) { return; } _response = await sendTask; await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - // this operation supports x-ms-long-running-operation - var _originalUri = request.RequestUri.AbsoluteUri; // declared final-state-via: default var _finalUri = ""; var asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); var location = _response.GetFirstHeader(@"Location"); + var operationLocation = _response.GetFirstHeader(@"Operation-Location"); while (request.Method == System.Net.Http.HttpMethod.Put && _response.StatusCode == global::System.Net.HttpStatusCode.OK || _response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) { - - // get the delay before polling. (default to 30 seconds if not present) - int delay = (int)(_response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, $"Delaying {delay} seconds before polling.", _response); if( eventListener.Token.IsCancellationRequested ) { return; } - - // start the delay timer (we'll await later...) - var waiting = global::System.Threading.Tasks.Task.Delay(delay * 1000, eventListener.Token ); + // delay before making the next polling request + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } // while we wait, let's grab the headers and get ready to poll. if (!System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Azure-AsyncOperation"))) { @@ -425,15 +770,14 @@ public partial class CustomProviders if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Location"))) { location = _response.GetFirstHeader(@"Location"); } - var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? _originalUri : location : asyncOperation; + if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Operation-Location"))) { + operationLocation = _response.GetFirstHeader(@"Operation-Location"); + } + var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? global::System.String.IsNullOrEmpty(operationLocation) ? _originalUri : operationLocation : location : asyncOperation; request = request.CloneAndDispose(new global::System.Uri(_uri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); // and let's look at the current response body and see if we have some information we can give back to the listener var content = await _response.Content.ReadAsStringAsync(); - await waiting; - - // check for cancellation - if( eventListener.Token.IsCancellationRequested ) { return; } // drop the old response _response?.Dispose(); @@ -442,45 +786,45 @@ public partial class CustomProviders _response = await sender.SendAsync(request, eventListener); await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - // if we got back an OK, take a peek inside and see if it's done - if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) - { - var error = false; - try { - if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) - { - var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); - if( state is null ) - { - // the body doesn't contain any information that has the state of the LRO - // we're going to just get out, and let the consumer have the result - break; - } - - switch( state?.ToString()?.ToLower() ) - { - case "failed": - error = true; + // if we got back an OK, take a peek inside and see if it's done + if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) + { + var error = false; + try { + if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) + { + var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); + if( state is null ) + { + // the body doesn't contain any information that has the state of the LRO + // we're going to just get out, and let the consumer have the result break; - case "succeeded": - case "canceled": - // we're done polling. - break; - - default: - // need to keep polling! - _response.StatusCode = global::System.Net.HttpStatusCode.Created; - continue; - } - } - } catch { - // if we run into a problem peeking into the result, - // we really don't want to do anything special. - } - if (error) { - throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); - } - } + } + + switch( state?.ToString()?.ToLower() ) + { + case "failed": + error = true; + break; + case "succeeded": + case "canceled": + // we're done polling. + break; + + default: + // need to keep polling! + _response.StatusCode = global::System.Net.HttpStatusCode.Created; + continue; + } + } + } catch { + // if we run into a problem peeking into the result, + // we really don't want to do anything special. + } + if (error) { + throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); + } + } // check for terminal status code if (_response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) @@ -502,6 +846,7 @@ public partial class CustomProviders break; } } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; } var _contentType = _response.Content.Headers.ContentType?.MediaType; switch ( _response.StatusCode ) @@ -521,7 +866,7 @@ public partial class CustomProviders default: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } } @@ -566,7 +911,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task AssociationsGet(string scope, string associationName, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task AssociationsGet(string scope, string associationName, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -591,7 +936,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.AssociationsGet_Call(request,onOk,onDefault,eventListener,sender); + await this.AssociationsGet_Call (request, onOk,onDefault,eventListener,sender); } } @@ -605,7 +950,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task AssociationsGetViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task AssociationsGetViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -641,11 +986,157 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.AssociationsGet_Call(request,onOk,onDefault,eventListener,sender); + await this.AssociationsGet_Call (request, onOk,onDefault,eventListener,sender); + } + } + + /// Get an association. + /// + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 AssociationsGetViaIdentityWithResult(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/(?[^/]+)/providers/Microsoft.CustomProviders/associations/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + var associationName = _match.Groups["associationName"].Value; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/" + + scope + + "/providers/Microsoft.CustomProviders/associations/" + + associationName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.AssociationsGetWithResult_Call (request, eventListener,sender); + } + } + + /// Get an association. + /// The scope of the association. + /// The name of the association. + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 AssociationsGetWithResult(string scope, string associationName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/" + + (scope) + + "/providers/Microsoft.CustomProviders/associations/" + + global::System.Uri.EscapeDataString(associationName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.AssociationsGetWithResult_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.CustomProviders.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 AssociationsGetWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) ); + return await _result; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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.CustomProviders.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } } } - /// Actual wire call for method. + /// 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 @@ -655,7 +1146,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task AssociationsGet_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + internal async global::System.Threading.Tasks.Task AssociationsGet_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { using( NoSynchronizationContext ) { @@ -666,6 +1157,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } _response = await sendTask; await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; } var _contentType = _response.Content.Headers.ContentType?.MediaType; switch ( _response.StatusCode ) @@ -673,13 +1165,13 @@ public partial class CustomProviders case global::System.Net.HttpStatusCode.OK: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Association.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } default: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } } @@ -723,7 +1215,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task AssociationsListAll(string scope, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task AssociationsListAll(string scope, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -747,7 +1239,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.AssociationsListAll_Call(request,onOk,onDefault,eventListener,sender); + await this.AssociationsListAll_Call (request, onOk,onDefault,eventListener,sender); } } @@ -761,7 +1253,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task AssociationsListAllViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task AssociationsListAllViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -795,11 +1287,153 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.AssociationsListAll_Call(request,onOk,onDefault,eventListener,sender); + await this.AssociationsListAll_Call (request, onOk,onDefault,eventListener,sender); + } + } + + /// Gets all association for the given scope. + /// + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 AssociationsListAllViaIdentityWithResult(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/(?[^/]+)/providers/Microsoft.CustomProviders/associations$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/{scope}/providers/Microsoft.CustomProviders/associations'"); + } + + // replace URI parameters with values from identity + var scope = _match.Groups["scope"].Value; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/" + + scope + + "/providers/Microsoft.CustomProviders/associations" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.AssociationsListAllWithResult_Call (request, eventListener,sender); + } + } + + /// Gets all association for the given scope. + /// The scope of the association. + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 AssociationsListAllWithResult(string scope, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/" + + (scope) + + "/providers/Microsoft.CustomProviders/associations" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.AssociationsListAllWithResult_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.CustomProviders.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 AssociationsListAllWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationsList.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) ); + return await _result; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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.CustomProviders.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } } } - /// Actual wire call for method. + /// 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 @@ -809,7 +1443,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task AssociationsListAll_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + internal async global::System.Threading.Tasks.Task AssociationsListAll_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { using( NoSynchronizationContext ) { @@ -820,6 +1454,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } _response = await sendTask; await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; } var _contentType = _response.Content.Headers.ContentType?.MediaType; switch ( _response.StatusCode ) @@ -827,13 +1462,13 @@ public partial class CustomProviders case global::System.Net.HttpStatusCode.OK: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationsList.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationsList.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } default: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } } @@ -865,7 +1500,7 @@ public partial class CustomProviders } } - /// Creates or updates the custom resource provider. + /// update the custom resource provider. /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) /// The name of the resource group. /// The name of the resource provider. @@ -875,10 +1510,11 @@ public partial class CustomProviders /// elsewhere). /// an instance that will receive events. /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 CustomResourceProviderCreateOrUpdate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderCreateOrUpdate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -905,15 +1541,15 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // set body content - request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + 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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.CustomResourceProviderCreateOrUpdate_Call(request,onOk,onDefault,eventListener,sender); + await this.CustomResourceProviderCreateOrUpdate_Call (request, onOk,onDefault,eventListener,sender); } } - /// Creates or updates the custom resource provider. + /// update the custom resource provider. /// /// The parameters required to create or update a custom resource provider definition. /// a delegate that is called when the remote service returns 200 (OK). @@ -921,10 +1557,11 @@ public partial class CustomProviders /// elsewhere). /// an instance that will receive events. /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 CustomResourceProviderCreateOrUpdateViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderCreateOrUpdateViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -963,51 +1600,244 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // set body content - request.Content = new global::System.Net.Http.StringContent(null != body ? body.ToJson(null).ToString() : @"{}", global::System.Text.Encoding.UTF8); + 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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.CustomResourceProviderCreateOrUpdate_Call(request,onOk,onDefault,eventListener,sender); + await this.CustomResourceProviderCreateOrUpdate_Call (request, onOk,onDefault,eventListener,sender); } } - /// - /// 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). + /// update the custom resource provider. + /// + /// The parameters required to create or update a custom resource provider definition. /// an instance that will receive events. /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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. + /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task CustomResourceProviderCreateOrUpdate_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderCreateOrUpdateViaIdentityWithResult(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters using( NoSynchronizationContext ) { - global::System.Net.Http.HttpResponseMessage _response = null; - try - { - var sendTask = sender.SendAsync(request, eventListener); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } - _response = await sendTask; - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - // this operation supports x-ms-long-running-operation - var _originalUri = request.RequestUri.AbsoluteUri; - // declared final-state-via: default - var asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); - var location = _response.GetFirstHeader(@"Location"); - while (request.Method == System.Net.Http.HttpMethod.Put && _response.StatusCode == global::System.Net.HttpStatusCode.OK || _response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) - { - - // get the delay before polling. (default to 30 seconds if not present) - int delay = (int)(_response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, $"Delaying {delay} seconds before polling.", _response); if( eventListener.Token.IsCancellationRequested ) { return; } - - // start the delay timer (we'll await later...) - var waiting = global::System.Threading.Tasks.Task.Delay(delay * 1000, eventListener.Token ); + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'"); + } + + // replace URI parameters with values from identity + var subscriptionId = _match.Groups["subscriptionId"].Value; + var resourceGroupName = _match.Groups["resourceGroupName"].Value; + var resourceProviderName = _match.Groups["resourceProviderName"].Value; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + subscriptionId + + "/resourceGroups/" + + resourceGroupName + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + resourceProviderName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.CustomResourceProviderCreateOrUpdateWithResult_Call (request, eventListener,sender); + } + } + + /// update the custom resource provider. + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// Json string supplied to the CustomResourceProviderCreateOrUpdate 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.CustomProviders.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 CustomResourceProviderCreateOrUpdateViaJsonString(string subscriptionId, string resourceGroupName, string resourceProviderName, 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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + global::System.Uri.EscapeDataString(subscriptionId) + + "/resourceGroups/" + + global::System.Uri.EscapeDataString(resourceGroupName) + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + global::System.Uri.EscapeDataString(resourceProviderName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.CustomResourceProviderCreateOrUpdate_Call (request, onOk,onDefault,eventListener,sender); + } + } + + /// update the custom resource provider. + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// Json string supplied to the CustomResourceProviderCreateOrUpdate operation + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 CustomResourceProviderCreateOrUpdateViaJsonStringWithResult(string subscriptionId, string resourceGroupName, string resourceProviderName, global::System.String jsonString, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + global::System.Uri.EscapeDataString(subscriptionId) + + "/resourceGroups/" + + global::System.Uri.EscapeDataString(resourceGroupName) + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + global::System.Uri.EscapeDataString(resourceProviderName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.CustomResourceProviderCreateOrUpdateWithResult_Call (request, eventListener,sender); + } + } + + /// update the custom resource provider. + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// The parameters required to create or update a custom resource provider definition. + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 CustomResourceProviderCreateOrUpdateWithResult(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + global::System.Uri.EscapeDataString(subscriptionId) + + "/resourceGroups/" + + global::System.Uri.EscapeDataString(resourceGroupName) + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + global::System.Uri.EscapeDataString(resourceProviderName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.CustomResourceProviderCreateOrUpdateWithResult_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.CustomProviders.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 CustomResourceProviderCreateOrUpdateWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + // this operation supports x-ms-long-running-operation + var _originalUri = request.RequestUri.AbsoluteUri; + var sendTask = sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 0); if( eventListener.Token.IsCancellationRequested ) { return null; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + // declared final-state-via: default + var asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = _response.GetFirstHeader(@"Location"); + var operationLocation = _response.GetFirstHeader(@"Operation-Location"); + while (request.Method == System.Net.Http.HttpMethod.Put && _response.StatusCode == global::System.Net.HttpStatusCode.OK || _response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) + { + // delay before making the next polling request + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } // while we wait, let's grab the headers and get ready to poll. if (!System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Azure-AsyncOperation"))) { @@ -1016,62 +1846,61 @@ public partial class CustomProviders if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Location"))) { location = _response.GetFirstHeader(@"Location"); } - var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? _originalUri : location : asyncOperation; + if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Operation-Location"))) { + operationLocation = _response.GetFirstHeader(@"Operation-Location"); + } + var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? global::System.String.IsNullOrEmpty(operationLocation) ? _originalUri : operationLocation : location : asyncOperation; request = request.CloneAndDispose(new global::System.Uri(_uri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); // and let's look at the current response body and see if we have some information we can give back to the listener var content = await _response.Content.ReadAsStringAsync(); - await waiting; - - // check for cancellation - if( eventListener.Token.IsCancellationRequested ) { return; } // drop the old response _response?.Dispose(); // make the polling call _response = await sender.SendAsync(request, eventListener); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - - // if we got back an OK, take a peek inside and see if it's done - if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) - { - var error = false; - try { - if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) - { - var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); - if( state is null ) - { - // the body doesn't contain any information that has the state of the LRO - // we're going to just get out, and let the consumer have the result - break; - } - - switch( state?.ToString()?.ToLower() ) - { - case "failed": - error = true; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + + // if we got back an OK, take a peek inside and see if it's done + if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) + { + var error = false; + try { + if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) + { + var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); + if( state is null ) + { + // the body doesn't contain any information that has the state of the LRO + // we're going to just get out, and let the consumer have the result break; - case "succeeded": - case "canceled": - // we're done polling. - break; - - default: - // need to keep polling! - _response.StatusCode = global::System.Net.HttpStatusCode.Created; - continue; - } - } - } catch { - // if we run into a problem peeking into the result, - // we really don't want to do anything special. - } - if (error) { - throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); - } - } + } + + switch( state?.ToString()?.ToLower() ) + { + case "failed": + error = true; + break; + case "succeeded": + case "canceled": + // we're done polling. + break; + + default: + // need to keep polling! + _response.StatusCode = global::System.Net.HttpStatusCode.Created; + continue; + } + } + } catch { + // if we run into a problem peeking into the result, + // we really don't want to do anything special. + } + if (error) { + throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); + } + } // check for terminal status code if (_response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) @@ -1089,10 +1918,770 @@ public partial class CustomProviders // make the final call _response = await sender.SendAsync(request, eventListener); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } break; } } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) ); + return await _result; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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.CustomProviders.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.CustomProviders.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 CustomResourceProviderCreateOrUpdate_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + // this operation supports x-ms-long-running-operation + var _originalUri = request.RequestUri.AbsoluteUri; + var sendTask = sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 0); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + // declared final-state-via: default + var asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = _response.GetFirstHeader(@"Location"); + var operationLocation = _response.GetFirstHeader(@"Operation-Location"); + while (request.Method == System.Net.Http.HttpMethod.Put && _response.StatusCode == global::System.Net.HttpStatusCode.OK || _response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) + { + // delay before making the next polling request + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + + // while we wait, let's grab the headers and get ready to poll. + if (!System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Azure-AsyncOperation"))) { + asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); + } + if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Location"))) { + location = _response.GetFirstHeader(@"Location"); + } + if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Operation-Location"))) { + operationLocation = _response.GetFirstHeader(@"Operation-Location"); + } + var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? global::System.String.IsNullOrEmpty(operationLocation) ? _originalUri : operationLocation : location : asyncOperation; + request = request.CloneAndDispose(new global::System.Uri(_uri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); + + // and let's look at the current response body and see if we have some information we can give back to the listener + var content = await _response.Content.ReadAsStringAsync(); + + // drop the old response + _response?.Dispose(); + + // make the polling call + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + + // if we got back an OK, take a peek inside and see if it's done + if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) + { + var error = false; + try { + if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) + { + var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); + if( state is null ) + { + // the body doesn't contain any information that has the state of the LRO + // we're going to just get out, and let the consumer have the result + break; + } + + switch( state?.ToString()?.ToLower() ) + { + case "failed": + error = true; + break; + case "succeeded": + case "canceled": + // we're done polling. + break; + + default: + // need to keep polling! + _response.StatusCode = global::System.Net.HttpStatusCode.Created; + continue; + } + } + } catch { + // if we run into a problem peeking into the result, + // we really don't want to do anything special. + } + if (error) { + throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); + } + } + + // check for terminal status code + if (_response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) + { + continue; + } + // we are done polling, do a request on final target? + if (!string.IsNullOrWhiteSpace(_originalUri)) + { + // create a new request with the final uri + request = request.CloneAndDispose(new global::System.Uri(_originalUri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); + + // drop the old response + _response?.Dispose(); + + // make the final call + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + break; + } + } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// The parameters required to create or update a custom resource provider definition. + /// 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 CustomResourceProviderCreateOrUpdate_Validate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(subscriptionId),subscriptionId); + await eventListener.AssertNotNull(nameof(resourceGroupName),resourceGroupName); + await eventListener.AssertNotNull(nameof(resourceProviderName),resourceProviderName); + await eventListener.AssertMinimumLength(nameof(resourceProviderName),resourceProviderName,3); + await eventListener.AssertMaximumLength(nameof(resourceProviderName),resourceProviderName,64); + await eventListener.AssertNotNull(nameof(body), body); + await eventListener.AssertObjectIsValid(nameof(body), body); + } + } + + /// Deletes the custom resource provider. + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 204 (NoContent). + /// 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.CustomProviders.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 CustomResourceProviderDelete(string subscriptionId, string resourceGroupName, string resourceProviderName, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + global::System.Uri.EscapeDataString(subscriptionId) + + "/resourceGroups/" + + global::System.Uri.EscapeDataString(resourceGroupName) + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + global::System.Uri.EscapeDataString(resourceProviderName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Delete, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.CustomResourceProviderDelete_Call (request, onOk,onNoContent,onDefault,eventListener,sender); + } + } + + /// Deletes the custom resource provider. + /// + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns 204 (NoContent). + /// 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.CustomProviders.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 CustomResourceProviderDeleteViaIdentity(global::System.String viaIdentity, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'"); + } + + // replace URI parameters with values from identity + var subscriptionId = _match.Groups["subscriptionId"].Value; + var resourceGroupName = _match.Groups["resourceGroupName"].Value; + var resourceProviderName = _match.Groups["resourceProviderName"].Value; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + subscriptionId + + "/resourceGroups/" + + resourceGroupName + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + resourceProviderName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Delete, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.CustomResourceProviderDelete_Call (request, onOk,onNoContent,onDefault,eventListener,sender); + } + } + + /// 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 204 (NoContent). + /// 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.CustomProviders.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 CustomResourceProviderDelete_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + using( NoSynchronizationContext ) + { + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + // this operation supports x-ms-long-running-operation + var _originalUri = request.RequestUri.AbsoluteUri; + var sendTask = sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 0); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + // declared final-state-via: default + var _finalUri = ""; + var asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = _response.GetFirstHeader(@"Location"); + var operationLocation = _response.GetFirstHeader(@"Operation-Location"); + while (request.Method == System.Net.Http.HttpMethod.Put && _response.StatusCode == global::System.Net.HttpStatusCode.OK || _response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) + { + // delay before making the next polling request + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + + // while we wait, let's grab the headers and get ready to poll. + if (!System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Azure-AsyncOperation"))) { + asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); + } + if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Location"))) { + location = _response.GetFirstHeader(@"Location"); + } + if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Operation-Location"))) { + operationLocation = _response.GetFirstHeader(@"Operation-Location"); + } + var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? global::System.String.IsNullOrEmpty(operationLocation) ? _originalUri : operationLocation : location : asyncOperation; + request = request.CloneAndDispose(new global::System.Uri(_uri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); + + // and let's look at the current response body and see if we have some information we can give back to the listener + var content = await _response.Content.ReadAsStringAsync(); + + // drop the old response + _response?.Dispose(); + + // make the polling call + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + + // if we got back an OK, take a peek inside and see if it's done + if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) + { + var error = false; + try { + if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) + { + var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); + if( state is null ) + { + // the body doesn't contain any information that has the state of the LRO + // we're going to just get out, and let the consumer have the result + break; + } + + switch( state?.ToString()?.ToLower() ) + { + case "failed": + error = true; + break; + case "succeeded": + case "canceled": + // we're done polling. + break; + + default: + // need to keep polling! + _response.StatusCode = global::System.Net.HttpStatusCode.Created; + continue; + } + } + } catch { + // if we run into a problem peeking into the result, + // we really don't want to do anything special. + } + if (error) { + throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); + } + } + + // check for terminal status code + if (_response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) + { + continue; + } + // we are done polling, do a request on final target? + if (!string.IsNullOrWhiteSpace(_finalUri)) + { + // create a new request with the final uri + request = request.CloneAndDispose(new global::System.Uri(_finalUri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); + + // drop the old response + _response?.Dispose(); + + // make the final call + _response = await sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + break; + } + } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onOk(_response); + break; + } + case global::System.Net.HttpStatusCode.NoContent: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onNoContent(_response); + break; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + break; + } + } + } + finally + { + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// 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 CustomResourceProviderDelete_Validate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) + { + using( NoSynchronizationContext ) + { + await eventListener.AssertNotNull(nameof(subscriptionId),subscriptionId); + await eventListener.AssertNotNull(nameof(resourceGroupName),resourceGroupName); + await eventListener.AssertNotNull(nameof(resourceProviderName),resourceProviderName); + await eventListener.AssertMinimumLength(nameof(resourceProviderName),resourceProviderName,3); + await eventListener.AssertMaximumLength(nameof(resourceProviderName),resourceProviderName,64); + } + } + + /// Gets the custom resource provider manifest. + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// 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.CustomProviders.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 CustomResourceProviderGet(string subscriptionId, string resourceGroupName, string resourceProviderName, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + global::System.Uri.EscapeDataString(subscriptionId) + + "/resourceGroups/" + + global::System.Uri.EscapeDataString(resourceGroupName) + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + global::System.Uri.EscapeDataString(resourceProviderName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.CustomResourceProviderGet_Call (request, onOk,onDefault,eventListener,sender); + } + } + + /// Gets the custom resource provider manifest. + /// + /// 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.CustomProviders.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 CustomResourceProviderGetViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'"); + } + + // replace URI parameters with values from identity + var subscriptionId = _match.Groups["subscriptionId"].Value; + var resourceGroupName = _match.Groups["resourceGroupName"].Value; + var resourceProviderName = _match.Groups["resourceProviderName"].Value; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + subscriptionId + + "/resourceGroups/" + + resourceGroupName + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + resourceProviderName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.CustomResourceProviderGet_Call (request, onOk,onDefault,eventListener,sender); + } + } + + /// Gets the custom resource provider manifest. + /// + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 CustomResourceProviderGetViaIdentityWithResult(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'"); + } + + // replace URI parameters with values from identity + var subscriptionId = _match.Groups["subscriptionId"].Value; + var resourceGroupName = _match.Groups["resourceGroupName"].Value; + var resourceProviderName = _match.Groups["resourceProviderName"].Value; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + subscriptionId + + "/resourceGroups/" + + resourceGroupName + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + resourceProviderName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.CustomResourceProviderGetWithResult_Call (request, eventListener,sender); + } + } + + /// Gets the custom resource provider manifest. + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 CustomResourceProviderGetWithResult(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + global::System.Uri.EscapeDataString(subscriptionId) + + "/resourceGroups/" + + global::System.Uri.EscapeDataString(resourceGroupName) + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + global::System.Uri.EscapeDataString(resourceProviderName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.CustomResourceProviderGetWithResult_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.CustomProviders.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 CustomResourceProviderGetWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) ); + return await _result; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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.CustomProviders.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.CustomProviders.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 CustomResourceProviderGet_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; } var _contentType = _response.Content.Headers.ContentType?.MediaType; switch ( _response.StatusCode ) @@ -1100,13 +2689,13 @@ public partial class CustomProviders case global::System.Net.HttpStatusCode.OK: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } default: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } } @@ -1122,18 +2711,17 @@ public partial class CustomProviders } /// - /// Validation method for method. Call this like the actual call, but - /// you will get validation events back. + /// Validation method for method. Call this like the actual call, but you will get + /// validation events back. /// /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) /// The name of the resource group. /// The name of the resource provider. - /// The parameters required to create or update a custom resource provider definition. /// 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 CustomResourceProviderCreateOrUpdate_Validate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) + internal async global::System.Threading.Tasks.Task CustomResourceProviderGet_Validate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) { using( NoSynchronizationContext ) { @@ -1142,17 +2730,13 @@ public partial class CustomProviders await eventListener.AssertNotNull(nameof(resourceProviderName),resourceProviderName); await eventListener.AssertMinimumLength(nameof(resourceProviderName),resourceProviderName,3); await eventListener.AssertMaximumLength(nameof(resourceProviderName),resourceProviderName,64); - await eventListener.AssertNotNull(nameof(body), body); - await eventListener.AssertObjectIsValid(nameof(body), body); } } - /// Deletes the custom resource provider. + /// Gets all the custom resource providers within a resource group. /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) /// The name of the resource group. - /// The name of the resource provider. /// a delegate that is called when the remote service returns 200 (OK). - /// a delegate that is called when the remote service returns 204 (NoContent). /// a delegate that is called when the remote service returns default (any response code not handled /// elsewhere). /// an instance that will receive events. @@ -1160,7 +2744,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task CustomResourceProviderDelete(string subscriptionId, string resourceGroupName, string resourceProviderName, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroup(string subscriptionId, string resourceGroupName, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -1172,8 +2756,7 @@ public partial class CustomProviders + global::System.Uri.EscapeDataString(subscriptionId) + "/resourceGroups/" + global::System.Uri.EscapeDataString(resourceGroupName) - + "/providers/Microsoft.CustomProviders/resourceProviders/" - + global::System.Uri.EscapeDataString(resourceProviderName) + + "/providers/Microsoft.CustomProviders/resourceProviders" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); @@ -1182,19 +2765,18 @@ public partial class CustomProviders // 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.CustomProviders.Runtime.Method.Delete, _url); + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get, _url); await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.CustomResourceProviderDelete_Call(request,onOk,onNoContent,onDefault,eventListener,sender); + await this.CustomResourceProviderListByResourceGroup_Call (request, onOk,onDefault,eventListener,sender); } } - /// Deletes the custom resource provider. + /// Gets all the custom resource providers within a resource group. /// /// a delegate that is called when the remote service returns 200 (OK). - /// a delegate that is called when the remote service returns 204 (NoContent). /// a delegate that is called when the remote service returns default (any response code not handled /// elsewhere). /// an instance that will receive events. @@ -1202,7 +2784,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task CustomResourceProviderDeleteViaIdentity(global::System.String viaIdentity, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroupViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -1210,24 +2792,22 @@ public partial class CustomProviders { // verify that Identity format is an exact match for uri - var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); if (!_match.Success) { - throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'"); + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders'"); } // replace URI parameters with values from identity var subscriptionId = _match.Groups["subscriptionId"].Value; var resourceGroupName = _match.Groups["resourceGroupName"].Value; - var resourceProviderName = _match.Groups["resourceProviderName"].Value; // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/subscriptions/" + subscriptionId + "/resourceGroups/" + resourceGroupName - + "/providers/Microsoft.CustomProviders/resourceProviders/" - + resourceProviderName + + "/providers/Microsoft.CustomProviders/resourceProviders" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); @@ -1236,207 +2816,74 @@ public partial class CustomProviders // 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.CustomProviders.Runtime.Method.Delete, _url); + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get, _url); await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.CustomResourceProviderDelete_Call(request,onOk,onNoContent,onDefault,eventListener,sender); + await this.CustomResourceProviderListByResourceGroup_Call (request, onOk,onDefault,eventListener,sender); } } - /// 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 204 (NoContent). - /// a delegate that is called when the remote service returns default (any response code not handled - /// elsewhere). + /// Gets all the custom resource providers within a resource group. + /// /// an instance that will receive events. /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync pipeline to use to make the request. /// - /// A that will be complete when handling of the response is completed. + /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task CustomResourceProviderDelete_Call(global::System.Net.Http.HttpRequestMessage request, global::System.Func onOk, global::System.Func onNoContent, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroupViaIdentityWithResult(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters using( NoSynchronizationContext ) { - global::System.Net.Http.HttpResponseMessage _response = null; - try - { - var sendTask = sender.SendAsync(request, eventListener); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } - _response = await sendTask; - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - // this operation supports x-ms-long-running-operation - var _originalUri = request.RequestUri.AbsoluteUri; - // declared final-state-via: default - var _finalUri = ""; - var asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); - var location = _response.GetFirstHeader(@"Location"); - while (request.Method == System.Net.Http.HttpMethod.Put && _response.StatusCode == global::System.Net.HttpStatusCode.OK || _response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) - { - - // get the delay before polling. (default to 30 seconds if not present) - int delay = (int)(_response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling, $"Delaying {delay} seconds before polling.", _response); if( eventListener.Token.IsCancellationRequested ) { return; } - - // start the delay timer (we'll await later...) - var waiting = global::System.Threading.Tasks.Task.Delay(delay * 1000, eventListener.Token ); - - // while we wait, let's grab the headers and get ready to poll. - if (!System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Azure-AsyncOperation"))) { - asyncOperation = _response.GetFirstHeader(@"Azure-AsyncOperation"); - } - if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Location"))) { - location = _response.GetFirstHeader(@"Location"); - } - var _uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? _originalUri : location : asyncOperation; - request = request.CloneAndDispose(new global::System.Uri(_uri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); - - // and let's look at the current response body and see if we have some information we can give back to the listener - var content = await _response.Content.ReadAsStringAsync(); - await waiting; - - // check for cancellation - if( eventListener.Token.IsCancellationRequested ) { return; } - - // drop the old response - _response?.Dispose(); - - // make the polling call - _response = await sender.SendAsync(request, eventListener); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - - // if we got back an OK, take a peek inside and see if it's done - if( _response.StatusCode == global::System.Net.HttpStatusCode.OK) - { - var error = false; - try { - if( Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(await _response.Content.ReadAsStringAsync()) is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json) - { - var state = json.Property("properties")?.PropertyT("provisioningState") ?? json.PropertyT("status"); - if( state is null ) - { - // the body doesn't contain any information that has the state of the LRO - // we're going to just get out, and let the consumer have the result - break; - } - - switch( state?.ToString()?.ToLower() ) - { - case "failed": - error = true; - break; - case "succeeded": - case "canceled": - // we're done polling. - break; - - default: - // need to keep polling! - _response.StatusCode = global::System.Net.HttpStatusCode.Created; - continue; - } - } - } catch { - // if we run into a problem peeking into the result, - // we really don't want to do anything special. - } - if (error) { - throw new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException(_response); - } - } + // verify that Identity format is an exact match for uri - // check for terminal status code - if (_response.StatusCode == global::System.Net.HttpStatusCode.Created || _response.StatusCode == global::System.Net.HttpStatusCode.Accepted ) - { - continue; - } - // we are done polling, do a request on final target? - if (!string.IsNullOrWhiteSpace(_finalUri)) - { - // create a new request with the final uri - request = request.CloneAndDispose(new global::System.Uri(_finalUri), Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Get); + var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders'"); + } - // drop the old response - _response?.Dispose(); + // replace URI parameters with values from identity + var subscriptionId = _match.Groups["subscriptionId"].Value; + var resourceGroupName = _match.Groups["resourceGroupName"].Value; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + subscriptionId + + "/resourceGroups/" + + resourceGroupName + + "/providers/Microsoft.CustomProviders/resourceProviders" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); - // make the final call - _response = await sender.SendAsync(request, eventListener); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Polling, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - break; - } - } - var _contentType = _response.Content.Headers.ContentType?.MediaType; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } - switch ( _response.StatusCode ) - { - case global::System.Net.HttpStatusCode.OK: - { - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response); - break; - } - case global::System.Net.HttpStatusCode.NoContent: - { - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onNoContent(_response); - break; - } - default: - { - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); - break; - } - } - } - finally - { - // finally statements - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Finally, request, _response); - _response?.Dispose(); - request?.Dispose(); - } - } - } + // 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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } - /// - /// Validation method for method. Call this like the actual call, but you will - /// get validation events back. - /// - /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) - /// The name of the resource group. - /// The name of the resource provider. - /// 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 CustomResourceProviderDelete_Validate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) - { - using( NoSynchronizationContext ) - { - await eventListener.AssertNotNull(nameof(subscriptionId),subscriptionId); - await eventListener.AssertNotNull(nameof(resourceGroupName),resourceGroupName); - await eventListener.AssertNotNull(nameof(resourceProviderName),resourceProviderName); - await eventListener.AssertMinimumLength(nameof(resourceProviderName),resourceProviderName,3); - await eventListener.AssertMaximumLength(nameof(resourceProviderName),resourceProviderName,64); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.CustomResourceProviderListByResourceGroupWithResult_Call (request, eventListener,sender); } } - /// Gets the custom resource provider manifest. + /// Gets all the custom resource providers within a resource group. /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) /// The name of the resource group. - /// The name of the resource provider. - /// 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.CustomProviders.Runtime.ISendAsync pipeline to use to make the request. /// - /// A that will be complete when handling of the response is completed. + /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task CustomResourceProviderGet(string subscriptionId, string resourceGroupName, string resourceProviderName, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroupWithResult(string subscriptionId, string resourceGroupName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -1448,79 +2895,89 @@ public partial class CustomProviders + global::System.Uri.EscapeDataString(subscriptionId) + "/resourceGroups/" + global::System.Uri.EscapeDataString(resourceGroupName) - + "/providers/Microsoft.CustomProviders/resourceProviders/" - + global::System.Uri.EscapeDataString(resourceProviderName) + + "/providers/Microsoft.CustomProviders/resourceProviders" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } // make the call - await this.CustomResourceProviderGet_Call(request,onOk,onDefault,eventListener,sender); + return await this.CustomResourceProviderListByResourceGroupWithResult_Call (request, eventListener,sender); } } - /// Gets the custom resource provider manifest. - /// - /// 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). + /// + /// Actual wire call for method. + /// + /// the prepared HttpRequestMessage to send. /// an instance that will receive events. /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync pipeline to use to make the request. /// - /// A that will be complete when handling of the response is completed. + /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task CustomResourceProviderGetViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + internal async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroupWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { - var apiVersion = @"2018-09-01-preview"; - // Constant Parameters using( NoSynchronizationContext ) { - // verify that Identity format is an exact match for uri + global::System.Net.Http.HttpResponseMessage _response = null; + try + { + var sendTask = sender.SendAsync(request, eventListener); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _contentType = _response.Content.Headers.ContentType?.MediaType; - var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); - if (!_match.Success) + switch ( _response.StatusCode ) + { + case global::System.Net.HttpStatusCode.OK: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ListByCustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) ); + return await _result; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.RestException(_response, await _result); + throw ex; + } + else + { + throw new global::System.Exception($"[{code}] : {message}"); + } + } + } + } + finally { - throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'"); + // finally statements + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); } - - // replace URI parameters with values from identity - var subscriptionId = _match.Groups["subscriptionId"].Value; - var resourceGroupName = _match.Groups["resourceGroupName"].Value; - var resourceProviderName = _match.Groups["resourceProviderName"].Value; - // construct URL - var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( - "/subscriptions/" - + subscriptionId - + "/resourceGroups/" - + resourceGroupName - + "/providers/Microsoft.CustomProviders/resourceProviders/" - + resourceProviderName - + "?" - + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) - ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); - - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } - - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } - // make the call - await this.CustomResourceProviderGet_Call(request,onOk,onDefault,eventListener,sender); } } - /// Actual wire call for method. + /// + /// 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 @@ -1530,7 +2987,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task CustomResourceProviderGet_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + internal async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroup_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { using( NoSynchronizationContext ) { @@ -1541,6 +2998,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } _response = await sendTask; await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; } var _contentType = _response.Content.Headers.ContentType?.MediaType; switch ( _response.StatusCode ) @@ -1548,13 +3006,13 @@ public partial class CustomProviders case global::System.Net.HttpStatusCode.OK: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ListByCustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } default: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } } @@ -1570,31 +3028,26 @@ public partial class CustomProviders } /// - /// Validation method for method. Call this like the actual call, but you will get - /// validation events back. + /// Validation method for method. Call this like the actual call, + /// but you will get validation events back. /// /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) /// The name of the resource group. - /// The name of the resource provider. /// 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 CustomResourceProviderGet_Validate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) + internal async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroup_Validate(string subscriptionId, string resourceGroupName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) { using( NoSynchronizationContext ) { await eventListener.AssertNotNull(nameof(subscriptionId),subscriptionId); await eventListener.AssertNotNull(nameof(resourceGroupName),resourceGroupName); - await eventListener.AssertNotNull(nameof(resourceProviderName),resourceProviderName); - await eventListener.AssertMinimumLength(nameof(resourceProviderName),resourceProviderName,3); - await eventListener.AssertMaximumLength(nameof(resourceProviderName),resourceProviderName,64); } } - /// Gets all the custom resource providers within a resource group. + /// Gets all the custom resource providers within a subscription. /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) - /// The name of the resource group. /// 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). @@ -1603,7 +3056,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroup(string subscriptionId, string resourceGroupName, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderListBySubscription(string subscriptionId, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -1613,8 +3066,6 @@ public partial class CustomProviders var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/subscriptions/" + global::System.Uri.EscapeDataString(subscriptionId) - + "/resourceGroups/" - + global::System.Uri.EscapeDataString(resourceGroupName) + "/providers/Microsoft.CustomProviders/resourceProviders" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -1629,11 +3080,11 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.CustomResourceProviderListByResourceGroup_Call(request,onOk,onDefault,eventListener,sender); + await this.CustomResourceProviderListBySubscription_Call (request, onOk,onDefault,eventListener,sender); } } - /// Gets all the custom resource providers within a resource group. + /// Gets all the custom resource providers within a subscription. /// /// 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 @@ -1643,7 +3094,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroupViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderListBySubscriptionViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -1651,21 +3102,18 @@ public partial class CustomProviders { // verify that Identity format is an exact match for uri - var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); if (!_match.Success) { - throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders'"); + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders'"); } // replace URI parameters with values from identity var subscriptionId = _match.Groups["subscriptionId"].Value; - var resourceGroupName = _match.Groups["resourceGroupName"].Value; // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/subscriptions/" + subscriptionId - + "/resourceGroups/" - + resourceGroupName + "/providers/Microsoft.CustomProviders/resourceProviders" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -1680,12 +3128,156 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.CustomResourceProviderListByResourceGroup_Call(request,onOk,onDefault,eventListener,sender); + await this.CustomResourceProviderListBySubscription_Call (request, onOk,onDefault,eventListener,sender); + } + } + + /// Gets all the custom resource providers within a subscription. + /// + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 CustomResourceProviderListBySubscriptionViaIdentityWithResult(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // 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.CustomProviders/resourceProviders$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders'"); + } + + // 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.CustomProviders/resourceProviders" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.CustomResourceProviderListBySubscriptionWithResult_Call (request, eventListener,sender); + } + } + + /// Gets all the custom resource providers within a subscription. + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 CustomResourceProviderListBySubscriptionWithResult(string subscriptionId, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + global::System.Uri.EscapeDataString(subscriptionId) + + "/providers/Microsoft.CustomProviders/resourceProviders" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.CustomResourceProviderListBySubscriptionWithResult_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.CustomProviders.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 CustomResourceProviderListBySubscriptionWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ListByCustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) ); + return await _result; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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.CustomProviders.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } } } /// - /// Actual wire call for method. + /// Actual wire call for method. /// /// the prepared HttpRequestMessage to send. /// a delegate that is called when the remote service returns 200 (OK). @@ -1696,7 +3288,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task CustomResourceProviderListByResourceGroup_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + internal async global::System.Threading.Tasks.Task CustomResourceProviderListBySubscription_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { using( NoSynchronizationContext ) { @@ -1707,6 +3299,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } _response = await sendTask; await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; } var _contentType = _response.Content.Headers.ContentType?.MediaType; switch ( _response.StatusCode ) @@ -1714,13 +3307,13 @@ public partial class CustomProviders case global::System.Net.HttpStatusCode.OK: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ListByCustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ListByCustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } default: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } } @@ -1736,35 +3329,39 @@ public partial class CustomProviders } /// - /// Validation method for method. Call this like the actual call, + /// Validation method for method. Call this like the actual call, /// but you will get validation events back. /// /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) - /// The name of the resource group. /// 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 CustomResourceProviderListByResourceGroup_Validate(string subscriptionId, string resourceGroupName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) + internal async global::System.Threading.Tasks.Task CustomResourceProviderListBySubscription_Validate(string subscriptionId, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) { using( NoSynchronizationContext ) { await eventListener.AssertNotNull(nameof(subscriptionId),subscriptionId); - await eventListener.AssertNotNull(nameof(resourceGroupName),resourceGroupName); } } - /// Gets all the custom resource providers within a subscription. + /// + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. + /// /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// The updatable fields of a custom resource provider. /// 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.CustomProviders.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 CustomResourceProviderListBySubscription(string subscriptionId, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderUpdate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -1774,7 +3371,10 @@ public partial class CustomProviders var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/subscriptions/" + global::System.Uri.EscapeDataString(subscriptionId) - + "/providers/Microsoft.CustomProviders/resourceProviders" + + "/resourceGroups/" + + global::System.Uri.EscapeDataString(resourceGroupName) + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + global::System.Uri.EscapeDataString(resourceProviderName) + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); @@ -1783,26 +3383,34 @@ public partial class CustomProviders // 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.CustomProviders.Runtime.Method.Get, _url); + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Patch, _url); await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.CustomResourceProviderListBySubscription_Call(request,onOk,onDefault,eventListener,sender); + await this.CustomResourceProviderUpdate_Call (request, onOk,onDefault,eventListener,sender); } } - /// Gets all the custom resource providers within a subscription. + /// + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. + /// /// + /// The updatable fields of a custom resource provider. /// 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.CustomProviders.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 CustomResourceProviderListBySubscriptionViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderUpdateViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -1810,19 +3418,24 @@ public partial class CustomProviders { // verify that Identity format is an exact match for uri - var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); if (!_match.Success) { - throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders'"); + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'"); } // replace URI parameters with values from identity var subscriptionId = _match.Groups["subscriptionId"].Value; + var resourceGroupName = _match.Groups["resourceGroupName"].Value; + var resourceProviderName = _match.Groups["resourceProviderName"].Value; // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/subscriptions/" + subscriptionId - + "/providers/Microsoft.CustomProviders/resourceProviders" + + "/resourceGroups/" + + resourceGroupName + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + resourceProviderName + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); @@ -1831,19 +3444,85 @@ public partial class CustomProviders // 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.CustomProviders.Runtime.Method.Get, _url); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Method.Patch, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.CustomResourceProviderUpdate_Call (request, onOk,onDefault,eventListener,sender); + } + } + + /// + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. + /// + /// + /// The updatable fields of a custom resource provider. + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 CustomResourceProviderUpdateViaIdentityWithResult(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'"); + } + + // replace URI parameters with values from identity + var subscriptionId = _match.Groups["subscriptionId"].Value; + var resourceGroupName = _match.Groups["resourceGroupName"].Value; + var resourceProviderName = _match.Groups["resourceProviderName"].Value; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + subscriptionId + + "/resourceGroups/" + + resourceGroupName + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + resourceProviderName + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Patch, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; } // make the call - await this.CustomResourceProviderListBySubscription_Call(request,onOk,onDefault,eventListener,sender); + return await this.CustomResourceProviderUpdateWithResult_Call (request, eventListener,sender); } } /// - /// Actual wire call for method. + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. /// - /// the prepared HttpRequestMessage to send. + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. + /// Json string supplied to the CustomResourceProviderUpdate 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). @@ -1852,78 +3531,55 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task CustomResourceProviderListBySubscription_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderUpdateViaJsonString(string subscriptionId, string resourceGroupName, string resourceProviderName, 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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters using( NoSynchronizationContext ) { - global::System.Net.Http.HttpResponseMessage _response = null; - try - { - var sendTask = sender.SendAsync(request, eventListener); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } - _response = await sendTask; - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - var _contentType = _response.Content.Headers.ContentType?.MediaType; + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + global::System.Uri.EscapeDataString(subscriptionId) + + "/resourceGroups/" + + global::System.Uri.EscapeDataString(resourceGroupName) + + "/providers/Microsoft.CustomProviders/resourceProviders/" + + global::System.Uri.EscapeDataString(resourceProviderName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); - switch ( _response.StatusCode ) - { - case global::System.Net.HttpStatusCode.OK: - { - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ListByCustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); - break; - } - default: - { - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); - break; - } - } - } - finally - { - // finally statements - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Finally, request, _response); - _response?.Dispose(); - request?.Dispose(); - } - } - } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } - /// - /// Validation method for method. Call this like the actual call, - /// but you will get validation events back. - /// - /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) - /// 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 CustomResourceProviderListBySubscription_Validate(string subscriptionId, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) - { - using( NoSynchronizationContext ) - { - await eventListener.AssertNotNull(nameof(subscriptionId),subscriptionId); + // 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.CustomProviders.Runtime.Method.Patch, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.CustomResourceProviderUpdate_Call (request, onOk,onDefault,eventListener,sender); } } /// - /// Updates an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. /// /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) /// The name of the resource group. /// The name of the resource provider. - /// The updatable fields of a custom resource provider. - /// 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). + /// Json string supplied to the CustomResourceProviderUpdate operation /// an instance that will receive events. /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync pipeline to use to make the request. /// - /// A that will be complete when handling of the response is completed. + /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task CustomResourceProviderUpdate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderUpdateViaJsonStringWithResult(string subscriptionId, string resourceGroupName, string resourceProviderName, global::System.String jsonString, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -1941,84 +3597,135 @@ public partial class CustomProviders + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Patch, _url); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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).ToString() : @"{}", global::System.Text.Encoding.UTF8); + 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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; } // make the call - await this.CustomResourceProviderUpdate_Call(request,onOk,onDefault,eventListener,sender); + return await this.CustomResourceProviderUpdateWithResult_Call (request, eventListener,sender); } } /// - /// Updates an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. /// - /// + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// The name of the resource group. + /// The name of the resource provider. /// The updatable fields of a custom resource provider. - /// 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.CustomProviders.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. + /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task CustomResourceProviderUpdateViaIdentity(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate body, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task CustomResourceProviderUpdateWithResult(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode serializationMode = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters using( NoSynchronizationContext ) { - // verify that Identity format is an exact match for uri - - var _match = new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/Microsoft.CustomProviders/resourceProviders/(?[^/]+)$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); - if (!_match.Success) - { - throw new global::System.Exception("Invalid identity for URI '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'"); - } - - // replace URI parameters with values from identity - var subscriptionId = _match.Groups["subscriptionId"].Value; - var resourceGroupName = _match.Groups["resourceGroupName"].Value; - var resourceProviderName = _match.Groups["resourceProviderName"].Value; // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/subscriptions/" - + subscriptionId + + global::System.Uri.EscapeDataString(subscriptionId) + "/resourceGroups/" - + resourceGroupName + + global::System.Uri.EscapeDataString(resourceGroupName) + "/providers/Microsoft.CustomProviders/resourceProviders/" - + resourceProviderName + + global::System.Uri.EscapeDataString(resourceProviderName) + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Patch, _url); - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } - await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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).ToString() : @"{}", global::System.Text.Encoding.UTF8); + 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.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return null; } // make the call - await this.CustomResourceProviderUpdate_Call(request,onOk,onDefault,eventListener,sender); + return await this.CustomResourceProviderUpdateWithResult_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.CustomProviders.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 CustomResourceProviderUpdateWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) ); + return await _result; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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.CustomProviders.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } } } - /// Actual wire call for method. + /// 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 @@ -2028,7 +3735,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task CustomResourceProviderUpdate_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + internal async global::System.Threading.Tasks.Task CustomResourceProviderUpdate_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { using( NoSynchronizationContext ) { @@ -2039,6 +3746,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } _response = await sendTask; await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; } var _contentType = _response.Content.Headers.ContentType?.MediaType; switch ( _response.StatusCode ) @@ -2046,13 +3754,13 @@ public partial class CustomProviders case global::System.Net.HttpStatusCode.OK: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } default: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } } @@ -2079,7 +3787,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task CustomResourceProviderUpdate_Validate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) + internal async global::System.Threading.Tasks.Task CustomResourceProviderUpdate_Validate(string subscriptionId, string resourceGroupName, string resourceProviderName, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate body, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener) { using( NoSynchronizationContext ) { @@ -2102,7 +3810,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task OperationsList(global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task OperationsList(global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -2124,7 +3832,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.OperationsList_Call(request,onOk,onDefault,eventListener,sender); + await this.OperationsList_Call (request, onOk,onDefault,eventListener,sender); } } @@ -2138,7 +3846,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - public async global::System.Threading.Tasks.Task OperationsListViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + public async global::System.Threading.Tasks.Task OperationsListViaIdentity(global::System.String viaIdentity, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { var apiVersion = @"2018-09-01-preview"; // Constant Parameters @@ -2169,11 +3877,147 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } // make the call - await this.OperationsList_Call(request,onOk,onDefault,eventListener,sender); + await this.OperationsList_Call (request, onOk,onDefault,eventListener,sender); + } + } + + /// The list of operations provided by Microsoft CustomProviders. + /// + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 OperationsListViaIdentityWithResult(global::System.String viaIdentity, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // verify that Identity format is an exact match for uri + + var _match = new global::System.Text.RegularExpressions.Regex("^/providers/Microsoft.CustomProviders/operations$", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(viaIdentity); + if (!_match.Success) + { + throw new global::System.Exception("Invalid identity for URI '/providers/Microsoft.CustomProviders/operations'"); + } + + // replace URI parameters with values from identity + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/providers/Microsoft.CustomProviders/operations" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.OperationsListWithResult_Call (request, eventListener,sender); + } + } + + /// The list of operations provided by Microsoft CustomProviders. + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 OperationsListWithResult(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + { + var apiVersion = @"2018-09-01-preview"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/providers/Microsoft.CustomProviders/operations" + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Method.Get, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return null; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return null; } + // make the call + return await this.OperationsListWithResult_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.CustomProviders.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 OperationsListWithResult_Call(global::System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return null; } + _response = await sendTask; + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationList.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) ); + return await _result; + } + default: + { + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return null; } + var _result = _response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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.CustomProviders.Runtime.Events.Finally, request, _response); + _response?.Dispose(); + request?.Dispose(); + } } } - /// Actual wire call for method. + /// 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 @@ -2183,7 +4027,7 @@ public partial class CustomProviders /// /// A that will be complete when handling of the response is completed. /// - internal async global::System.Threading.Tasks.Task OperationsList_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) + internal async global::System.Threading.Tasks.Task OperationsList_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.CustomProviders.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.ISendAsync sender) { using( NoSynchronizationContext ) { @@ -2194,6 +4038,7 @@ public partial class CustomProviders await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeCall, request); if( eventListener.Token.IsCancellationRequested ) { return; } _response = await sendTask; await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.ResponseCreated, _response); if( eventListener.Token.IsCancellationRequested ) { return; } + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress, "intentional placeholder", 100); if( eventListener.Token.IsCancellationRequested ) { return; } var _contentType = _response.Content.Headers.ContentType?.MediaType; switch ( _response.StatusCode ) @@ -2201,13 +4046,13 @@ public partial class CustomProviders case global::System.Net.HttpStatusCode.OK: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationList.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onOk(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationList.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } default: { await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.BeforeResponseDispatch, _response); if( eventListener.Token.IsCancellationRequested ) { return; } - await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); + await onDefault(_response,_response.Content.ReadAsStringAsync().ContinueWith( body => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorResponse.FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(body.Result)) )); break; } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.PowerShell.cs similarity index 63% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.PowerShell.cs index 4a4a253580c7..0e64814bb0ed 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,7 +55,15 @@ public partial class Association partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into a new instance of 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. @@ -70,33 +78,33 @@ internal Association(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("Property")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationPropertiesTypeConverter.ConvertFrom); } if (content.Contains("Id")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Id, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Type")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Type, global::System.Convert.ToString); } if (content.Contains("ProvisioningState")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).ProvisioningState = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState?) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).ProvisioningState, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).ProvisioningState = (string) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).ProvisioningState, global::System.Convert.ToString); } if (content.Contains("TargetResourceId")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).TargetResourceId = (string) content.GetValueForProperty("TargetResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).TargetResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).TargetResourceId = (string) content.GetValueForProperty("TargetResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).TargetResourceId, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -111,53 +119,53 @@ internal Association(global::System.Management.Automation.PSObject content) // actually deserialize if (content.Contains("Property")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationPropertiesTypeConverter.ConvertFrom); } if (content.Contains("Id")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Id, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Type")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).Type, global::System.Convert.ToString); } if (content.Contains("ProvisioningState")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).ProvisioningState = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState?) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).ProvisioningState, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).ProvisioningState = (string) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).ProvisioningState, global::System.Convert.ToString); } if (content.Contains("TargetResourceId")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).TargetResourceId = (string) content.GetValueForProperty("TargetResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal)this).TargetResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).TargetResourceId = (string) content.GetValueForProperty("TargetResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal)this).TargetResourceId, global::System.Convert.ToString); } AfterDeserializePSObject(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Collections.IDictionary content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new Association(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new Association(content); } @@ -167,12 +175,24 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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 definition of this association. [System.ComponentModel.TypeConverter(typeof(AssociationTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.TypeConverter.cs index 32277d430c31..23c0d3e134e8 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.cs similarity index 66% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.cs index 7314c7beb3b9..e4d80b0fca04 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// The resource definition of this association. public partial class Association : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal { /// Backing field for property. @@ -21,19 +21,19 @@ public partial class Association : public string Id { get => this._id; } /// Internal Acessors for Id - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal.Id { get => this._id; set { {_id = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal.Id { get => this._id; set { {_id = value;} } } /// Internal Acessors for Name - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal.Name { get => this._name; set { {_name = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal.Name { get => this._name; set { {_name = value;} } } /// Internal Acessors for Property - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationProperties()); set { {_property = value;} } } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationProperties()); set { {_property = value;} } } /// Internal Acessors for ProvisioningState - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal.ProvisioningState { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)Property).ProvisioningState; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)Property).ProvisioningState = value; } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal.ProvisioningState { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)Property).ProvisioningState; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)Property).ProvisioningState = value; } /// Internal Acessors for Type - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationInternal.Type { get => this._type; set { {_type = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationInternal.Type { get => this._type; set { {_type = value;} } } /// Backing field for property. private string _name; @@ -43,19 +43,23 @@ public partial class Association : public string Name { get => this._name; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties _property; + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties _property; /// The properties of the association. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - internal Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationProperties()); set => this._property = value; } + internal Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationProperties()); set => this._property = value; } /// The provisioning state of the association. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)Property).ProvisioningState; } + public string ProvisioningState { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)Property).ProvisioningState; } + + /// Gets the resource group name + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] + public string ResourceGroupName { get => (new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(this.Id).Success ? new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(this.Id).Groups["resourceGroupName"].Value : null); } /// The REST resource instance of the target resource for this association. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public string TargetResourceId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)Property).TargetResourceId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)Property).TargetResourceId = value ?? null; } + public string TargetResourceId { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)Property).TargetResourceId; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)Property).TargetResourceId = value ?? null; } /// Backing field for property. private string _type; @@ -78,6 +82,9 @@ public partial interface IAssociation : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"The association id.", SerializedName = @"id", PossibleTypes = new [] { typeof(string) })] @@ -86,6 +93,9 @@ public partial interface IAssociation : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"The association name.", SerializedName = @"name", PossibleTypes = new [] { typeof(string) })] @@ -94,14 +104,21 @@ public partial interface IAssociation : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"The provisioning state of the association.", SerializedName = @"provisioningState", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get; } + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Accepted", "Deleting", "Running", "Succeeded", "Failed")] + string ProvisioningState { get; } /// The REST resource instance of the target resource for this association. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The REST resource instance of the target resource for this association.", SerializedName = @"targetResourceId", PossibleTypes = new [] { typeof(string) })] @@ -110,6 +127,9 @@ public partial interface IAssociation : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"The association type.", SerializedName = @"type", PossibleTypes = new [] { typeof(string) })] @@ -125,9 +145,10 @@ internal partial interface IAssociationInternal /// The association name. string Name { get; set; } /// The properties of the association. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties Property { get; set; } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties Property { get; set; } /// The provisioning state of the association. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get; set; } + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Accepted", "Deleting", "Running", "Succeeded", "Failed")] + string ProvisioningState { get; set; } /// The REST resource instance of the target resource for this association. string TargetResourceId { get; set; } /// The association type. diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.json.cs similarity index 93% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.json.cs index 86ee7dbbc127..c52124580d3c 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Association.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Association.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -65,21 +65,21 @@ internal Association(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime. { return; } - {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationProperties.FromJson(__jsonProperties) : Property;} - {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)Id;} - {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} - {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} + {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationProperties.FromJson(__jsonProperties) : _property;} + {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)_id;} + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)_name;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)_type;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new Association(json) : null; } @@ -104,15 +104,15 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode return container; } AddIf( null != this._property ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) this._property.ToJson(null,serializationMode) : null, "properties" ,container.Add ); - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._id)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._id.ToString()) : null, "id" ,container.Add ); } - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); } - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.PowerShell.cs similarity index 73% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.PowerShell.cs index c172ee4e2235..3eed17c3848b 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,7 +55,15 @@ public partial class AssociationProperties partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into a new instance of 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. @@ -70,17 +78,17 @@ internal AssociationProperties(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("TargetResourceId")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)this).TargetResourceId = (string) content.GetValueForProperty("TargetResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)this).TargetResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)this).TargetResourceId = (string) content.GetValueForProperty("TargetResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)this).TargetResourceId, global::System.Convert.ToString); } if (content.Contains("ProvisioningState")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)this).ProvisioningState = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState?) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)this).ProvisioningState, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)this).ProvisioningState = (string) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)this).ProvisioningState, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -95,39 +103,37 @@ internal AssociationProperties(global::System.Management.Automation.PSObject con // actually deserialize if (content.Contains("TargetResourceId")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)this).TargetResourceId = (string) content.GetValueForProperty("TargetResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)this).TargetResourceId, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)this).TargetResourceId = (string) content.GetValueForProperty("TargetResourceId",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)this).TargetResourceId, global::System.Convert.ToString); } if (content.Contains("ProvisioningState")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)this).ProvisioningState = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState?) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal)this).ProvisioningState, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)this).ProvisioningState = (string) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal)this).ProvisioningState, global::System.Convert.ToString); } AfterDeserializePSObject(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Collections.IDictionary content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new AssociationProperties(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new AssociationProperties(content); } @@ -137,12 +143,24 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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 properties of the association. [System.ComponentModel.TypeConverter(typeof(AssociationPropertiesTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.TypeConverter.cs index e770da2ec5a4..3485dfeb6b90 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.cs similarity index 74% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.cs index 763f557b048e..368525c28f49 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.cs @@ -3,25 +3,25 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// The properties of the association. public partial class AssociationProperties : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal { /// Internal Acessors for ProvisioningState - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationPropertiesInternal.ProvisioningState { get => this._provisioningState; set { {_provisioningState = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationPropertiesInternal.ProvisioningState { get => this._provisioningState; set { {_provisioningState = value;} } } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? _provisioningState; + private string _provisioningState; /// The provisioning state of the association. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get => this._provisioningState; } + public string ProvisioningState { get => this._provisioningState; } /// Backing field for property. private string _targetResourceId; @@ -44,14 +44,21 @@ public partial interface IAssociationProperties : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"The provisioning state of the association.", SerializedName = @"provisioningState", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get; } + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Accepted", "Deleting", "Running", "Succeeded", "Failed")] + string ProvisioningState { get; } /// The REST resource instance of the target resource for this association. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The REST resource instance of the target resource for this association.", SerializedName = @"targetResourceId", PossibleTypes = new [] { typeof(string) })] @@ -63,7 +70,8 @@ internal partial interface IAssociationPropertiesInternal { /// The provisioning state of the association. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get; set; } + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Accepted", "Deleting", "Running", "Succeeded", "Failed")] + string ProvisioningState { get; set; } /// The REST resource instance of the target resource for this association. string TargetResourceId { get; set; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.json.cs similarity index 95% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.json.cs index 6d63130ff975..d0bdd3d61d7e 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationProperties.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationProperties.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -65,19 +65,19 @@ internal AssociationProperties(Microsoft.Azure.PowerShell.Cmdlets.CustomProvider { return; } - {_targetResourceId = If( json?.PropertyT("targetResourceId"), out var __jsonTargetResourceId) ? (string)__jsonTargetResourceId : (string)TargetResourceId;} - {_provisioningState = If( json?.PropertyT("provisioningState"), out var __jsonProvisioningState) ? (string)__jsonProvisioningState : (string)ProvisioningState;} + {_targetResourceId = If( json?.PropertyT("targetResourceId"), out var __jsonTargetResourceId) ? (string)__jsonTargetResourceId : (string)_targetResourceId;} + {_provisioningState = If( json?.PropertyT("provisioningState"), out var __jsonProvisioningState) ? (string)__jsonProvisioningState : (string)_provisioningState;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new AssociationProperties(json) : null; } @@ -102,7 +102,7 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode return container; } AddIf( null != (((object)this._targetResourceId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._targetResourceId.ToString()) : null, "targetResourceId" ,container.Add ); - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._provisioningState)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._provisioningState.ToString()) : null, "provisioningState" ,container.Add ); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.PowerShell.cs similarity index 70% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.PowerShell.cs index 0fd248bc1086..c6b5433d797d 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,7 +55,15 @@ public partial class AssociationsList partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into a new instance of 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. @@ -70,17 +78,17 @@ internal AssociationsList(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("Value")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsListInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsListInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsListInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsListInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationTypeConverter.ConvertFrom)); } if (content.Contains("NextLink")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsListInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsListInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsListInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsListInternal)this).NextLink, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -95,39 +103,37 @@ internal AssociationsList(global::System.Management.Automation.PSObject content) // actually deserialize if (content.Contains("Value")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsListInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsListInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.AssociationTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsListInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsListInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.AssociationTypeConverter.ConvertFrom)); } if (content.Contains("NextLink")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsListInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsListInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsListInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsListInternal)this).NextLink, global::System.Convert.ToString); } AfterDeserializePSObject(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Collections.IDictionary content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new AssociationsList(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new AssociationsList(content); } @@ -137,12 +143,24 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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(); + } } /// List of associations. [System.ComponentModel.TypeConverter(typeof(AssociationsListTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.TypeConverter.cs index aa89f037eee9..9f6110cd7c2c 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.cs similarity index 77% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.cs index eb49316cd85d..d3eb19ad7764 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// List of associations. public partial class AssociationsList : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsListInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsListInternal { /// Backing field for property. @@ -21,11 +21,11 @@ public partial class AssociationsList : public string NextLink { get => this._nextLink; set => this._nextLink = value; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation[] _value; + private System.Collections.Generic.List _value; /// The array of associations. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation[] Value { get => this._value; set => this._value = value; } + public System.Collections.Generic.List Value { get => this._value; set => this._value = value; } /// Creates an new instance. public AssociationsList() @@ -41,6 +41,9 @@ public partial interface IAssociationsList : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The URL to use for getting the next set of results.", SerializedName = @"nextLink", PossibleTypes = new [] { typeof(string) })] @@ -49,10 +52,13 @@ public partial interface IAssociationsList : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The array of associations.", SerializedName = @"value", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation[] Value { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation) })] + System.Collections.Generic.List Value { get; set; } } /// List of associations. @@ -62,7 +68,7 @@ internal partial interface IAssociationsListInternal /// The URL to use for getting the next set of results. string NextLink { get; set; } /// The array of associations. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation[] Value { get; set; } + System.Collections.Generic.List Value { get; set; } } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.json.cs similarity index 91% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.json.cs index 181816741ec2..3b1e4641e5ab 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/AssociationsList.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/AssociationsList.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -65,19 +65,19 @@ internal AssociationsList(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Run { return; } - {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Association.FromJson(__u) )) ))() : null : Value;} - {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)NextLink;} + {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Models.IAssociation) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association.FromJson(__u) )) ))() : null : _value;} + {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)_nextLink;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new AssociationsList(json) : null; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.PowerShell.cs index 559a097ca02b..e015aaaf562d 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.PowerShell.cs @@ -53,6 +53,14 @@ public partial class CustomProvidersIdentity 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 . @@ -172,6 +180,18 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomP /// a containing this model serialized to JSON text. public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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(CustomProvidersIdentityTypeConverter))] public partial interface ICustomProvidersIdentity diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.cs index c87a76a556c0..e8653cde7d60 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.cs @@ -72,6 +72,9 @@ public partial interface ICustomProvidersIdentity : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The name of the association.", SerializedName = @"associationName", PossibleTypes = new [] { typeof(string) })] @@ -80,6 +83,9 @@ public partial interface ICustomProvidersIdentity : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Resource identity path", SerializedName = @"id", PossibleTypes = new [] { typeof(string) })] @@ -88,6 +94,9 @@ public partial interface ICustomProvidersIdentity : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The name of the resource group.", SerializedName = @"resourceGroupName", PossibleTypes = new [] { typeof(string) })] @@ -96,6 +105,9 @@ public partial interface ICustomProvidersIdentity : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The name of the resource provider.", SerializedName = @"resourceProviderName", PossibleTypes = new [] { typeof(string) })] @@ -107,6 +119,9 @@ public partial interface ICustomProvidersIdentity : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource.", SerializedName = @"scope", PossibleTypes = new [] { typeof(string) })] @@ -117,6 +132,9 @@ public partial interface ICustomProvidersIdentity : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)", SerializedName = @"subscriptionId", PossibleTypes = new [] { typeof(string) })] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.json.cs index ea069546fe74..43aee3572db7 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomProvidersIdentity.json.cs @@ -64,12 +64,12 @@ internal CustomProvidersIdentity(Microsoft.Azure.PowerShell.Cmdlets.CustomProvid { return; } - {_subscriptionId = If( json?.PropertyT("subscriptionId"), out var __jsonSubscriptionId) ? (string)__jsonSubscriptionId : (string)SubscriptionId;} - {_resourceGroupName = If( json?.PropertyT("resourceGroupName"), out var __jsonResourceGroupName) ? (string)__jsonResourceGroupName : (string)ResourceGroupName;} - {_resourceProviderName = If( json?.PropertyT("resourceProviderName"), out var __jsonResourceProviderName) ? (string)__jsonResourceProviderName : (string)ResourceProviderName;} - {_scope = If( json?.PropertyT("scope"), out var __jsonScope) ? (string)__jsonScope : (string)Scope;} - {_associationName = If( json?.PropertyT("associationName"), out var __jsonAssociationName) ? (string)__jsonAssociationName : (string)AssociationName;} - {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)Id;} + {_subscriptionId = If( json?.PropertyT("subscriptionId"), out var __jsonSubscriptionId) ? (string)__jsonSubscriptionId : (string)_subscriptionId;} + {_resourceGroupName = If( json?.PropertyT("resourceGroupName"), out var __jsonResourceGroupName) ? (string)__jsonResourceGroupName : (string)_resourceGroupName;} + {_resourceProviderName = If( json?.PropertyT("resourceProviderName"), out var __jsonResourceProviderName) ? (string)__jsonResourceProviderName : (string)_resourceProviderName;} + {_scope = If( json?.PropertyT("scope"), out var __jsonScope) ? (string)__jsonScope : (string)_scope;} + {_associationName = If( json?.PropertyT("associationName"), out var __jsonAssociationName) ? (string)__jsonAssociationName : (string)_associationName;} + {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)_id;} AfterFromJson(json); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.PowerShell.cs similarity index 70% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.PowerShell.cs index 65d6cce30b7e..56b5a5c05385 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,7 +55,15 @@ public partial class CustomRpActionRouteDefinition partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into a new instance of 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. @@ -70,21 +78,21 @@ internal CustomRpActionRouteDefinition(global::System.Collections.IDictionary co // actually deserialize if (content.Contains("RoutingType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinitionInternal)this).RoutingType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting?) content.GetValueForProperty("RoutingType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinitionInternal)this).RoutingType, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinitionInternal)this).RoutingType = (string) content.GetValueForProperty("RoutingType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinitionInternal)this).RoutingType, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Endpoint")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -99,43 +107,41 @@ internal CustomRpActionRouteDefinition(global::System.Management.Automation.PSOb // actually deserialize if (content.Contains("RoutingType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinitionInternal)this).RoutingType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting?) content.GetValueForProperty("RoutingType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinitionInternal)this).RoutingType, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinitionInternal)this).RoutingType = (string) content.GetValueForProperty("RoutingType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinitionInternal)this).RoutingType, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Endpoint")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); } AfterDeserializePSObject(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Collections.IDictionary content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new CustomRpActionRouteDefinition(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new CustomRpActionRouteDefinition(content); } @@ -145,12 +151,24 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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 route definition for an action implemented by the custom resource provider. [System.ComponentModel.TypeConverter(typeof(CustomRpActionRouteDefinitionTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.TypeConverter.cs index ab7c71d660f1..297c23045187 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.cs similarity index 72% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.cs index 674f09b0f480..5fb1d8bd3041 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.cs @@ -3,41 +3,41 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// The route definition for an action implemented by the custom resource provider. public partial class CustomRpActionRouteDefinition : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinitionInternal, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinitionInternal, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IValidates { /// - /// Backing field for Inherited model /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition __customRpRouteDefinition = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpRouteDefinition(); + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition __customRpRouteDefinition = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpRouteDefinition(); /// /// The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of /// a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}') /// [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inherited)] - public string Endpoint { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Endpoint; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Endpoint = value ; } + public string Endpoint { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Endpoint; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Endpoint = value ; } /// /// The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') /// [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inherited)] - public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Name = value ; } + public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Name = value ; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting? _routingType; + private string _routingType; /// The routing types that are supported for action requests. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting? RoutingType { get => this._routingType; set => this._routingType = value; } + public string RoutingType { get => this._routingType; set => this._routingType = value; } /// Creates an new instance. public CustomRpActionRouteDefinition() @@ -60,24 +60,29 @@ public CustomRpActionRouteDefinition() /// The route definition for an action implemented by the custom resource provider. public partial interface ICustomRpActionRouteDefinition : Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IJsonSerializable, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition { /// The routing types that are supported for action requests. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The routing types that are supported for action requests.", SerializedName = @"routingType", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting? RoutingType { get; set; } + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Proxy")] + string RoutingType { get; set; } } /// The route definition for an action implemented by the custom resource provider. internal partial interface ICustomRpActionRouteDefinitionInternal : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal { /// The routing types that are supported for action requests. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting? RoutingType { get; set; } + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Proxy")] + string RoutingType { get; set; } } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.json.cs similarity index 94% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.json.cs index e311eaa57333..27854e48f937 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpActionRouteDefinition.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpActionRouteDefinition.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -65,19 +65,19 @@ internal CustomRpActionRouteDefinition(Microsoft.Azure.PowerShell.Cmdlets.Custom { return; } - __customRpRouteDefinition = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpRouteDefinition(json); - {_routingType = If( json?.PropertyT("routingType"), out var __jsonRoutingType) ? (string)__jsonRoutingType : (string)RoutingType;} + __customRpRouteDefinition = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpRouteDefinition(json); + {_routingType = If( json?.PropertyT("routingType"), out var __jsonRoutingType) ? (string)__jsonRoutingType : (string)_routingType;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new CustomRpActionRouteDefinition(json) : null; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.PowerShell.cs similarity index 50% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.PowerShell.cs index 115d9cf85856..4a0f0cedc37b 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,7 +55,15 @@ public partial class CustomRpManifest partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into a new instance of 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. @@ -70,49 +78,49 @@ internal CustomRpManifest(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("Property")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifestPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifestPropertiesTypeConverter.ConvertFrom); } if (content.Contains("Id")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Id, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Type")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Type, global::System.Convert.ToString); } if (content.Contains("Location")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Location = (string) content.GetValueForProperty("Location",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Location, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Location = (string) content.GetValueForProperty("Location",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Location, global::System.Convert.ToString); } if (content.Contains("Tag")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceTagsTypeConverter.ConvertFrom); } if (content.Contains("ProvisioningState")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).ProvisioningState = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState?) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).ProvisioningState, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).ProvisioningState = (string) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).ProvisioningState, global::System.Convert.ToString); } if (content.Contains("Action")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Action = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[]) content.GetValueForProperty("Action",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Action, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpActionRouteDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Action = (System.Collections.Generic.List) content.GetValueForProperty("Action",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Action, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpActionRouteDefinitionTypeConverter.ConvertFrom)); } if (content.Contains("ResourceType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).ResourceType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[]) content.GetValueForProperty("ResourceType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).ResourceType, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpResourceTypeRouteDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).ResourceType = (System.Collections.Generic.List) content.GetValueForProperty("ResourceType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).ResourceType, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpResourceTypeRouteDefinitionTypeConverter.ConvertFrom)); } if (content.Contains("Validation")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Validation = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[]) content.GetValueForProperty("Validation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Validation, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpValidationsTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Validation = (System.Collections.Generic.List) content.GetValueForProperty("Validation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Validation, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpValidationsTypeConverter.ConvertFrom)); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -127,71 +135,69 @@ internal CustomRpManifest(global::System.Management.Automation.PSObject content) // actually deserialize if (content.Contains("Property")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifestPropertiesTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Property = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties) content.GetValueForProperty("Property",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Property, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifestPropertiesTypeConverter.ConvertFrom); } if (content.Contains("Id")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Id, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Type")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Type, global::System.Convert.ToString); } if (content.Contains("Location")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Location = (string) content.GetValueForProperty("Location",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Location, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Location = (string) content.GetValueForProperty("Location",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Location, global::System.Convert.ToString); } if (content.Contains("Tag")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceTagsTypeConverter.ConvertFrom); } if (content.Contains("ProvisioningState")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).ProvisioningState = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState?) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).ProvisioningState, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).ProvisioningState = (string) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).ProvisioningState, global::System.Convert.ToString); } if (content.Contains("Action")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Action = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[]) content.GetValueForProperty("Action",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Action, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpActionRouteDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Action = (System.Collections.Generic.List) content.GetValueForProperty("Action",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Action, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpActionRouteDefinitionTypeConverter.ConvertFrom)); } if (content.Contains("ResourceType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).ResourceType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[]) content.GetValueForProperty("ResourceType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).ResourceType, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpResourceTypeRouteDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).ResourceType = (System.Collections.Generic.List) content.GetValueForProperty("ResourceType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).ResourceType, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpResourceTypeRouteDefinitionTypeConverter.ConvertFrom)); } if (content.Contains("Validation")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Validation = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[]) content.GetValueForProperty("Validation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal)this).Validation, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpValidationsTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Validation = (System.Collections.Generic.List) content.GetValueForProperty("Validation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal)this).Validation, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpValidationsTypeConverter.ConvertFrom)); } AfterDeserializePSObject(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Collections.IDictionary content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new CustomRpManifest(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new CustomRpManifest(content); } @@ -201,12 +207,24 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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(); + } } /// A manifest file that defines the custom resource provider resources. [System.ComponentModel.TypeConverter(typeof(CustomRpManifestTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.TypeConverter.cs index 2680a995cbff..1df0a538dfb3 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.cs similarity index 54% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.cs index 6a6f0f261e85..7369083685e4 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.cs @@ -3,79 +3,82 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// A manifest file that defines the custom resource provider resources. public partial class CustomRpManifest : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IValidates { /// - /// Backing field for Inherited model + /// Backing field for Inherited model /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource __resource = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Resource(); + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource __resource = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Resource(); /// A list of actions that the custom resource provider implements. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[] Action { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)Property).Action; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)Property).Action = value ?? null /* arrayOf */; } + public System.Collections.Generic.List Action { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)Property).Action; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)Property).Action = value ?? null /* arrayOf */; } /// Resource Id [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inherited)] - public string Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Id; } + public string Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Id; } /// Resource location [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inherited)] - public string Location { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Location; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Location = value ; } + public string Location { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Location; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Location = value ?? null; } /// Internal Acessors for Property - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifestProperties()); set { {_property = value;} } } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal.Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifestProperties()); set { {_property = value;} } } /// Internal Acessors for ProvisioningState - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestInternal.ProvisioningState { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)Property).ProvisioningState; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)Property).ProvisioningState = value; } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestInternal.ProvisioningState { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)Property).ProvisioningState; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)Property).ProvisioningState = value; } /// Internal Acessors for Id - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal.Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Id; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Id = value; } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal.Id { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Id; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Id = value; } /// Internal Acessors for Name - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal.Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Name = value; } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal.Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Name = value; } /// Internal Acessors for Type - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal.Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Type = value; } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal.Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Type; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Type = value; } /// Resource name [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inherited)] - public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Name; } + public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Name; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties _property; + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties _property; /// The manifest for the custom resource provider [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - internal Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifestProperties()); set => this._property = value; } + internal Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties Property { get => (this._property = this._property ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifestProperties()); set => this._property = value; } /// The provisioning state of the resource provider. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)Property).ProvisioningState; } + public string ProvisioningState { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)Property).ProvisioningState; } + + /// Gets the resource group name + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] + public string ResourceGroupName { get => (new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(this.Id).Success ? new global::System.Text.RegularExpressions.Regex("^/subscriptions/(?[^/]+)/resourceGroups/(?[^/]+)/providers/", global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(this.Id).Groups["resourceGroupName"].Value : null); } /// A list of resource types that the custom resource provider implements. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[] ResourceType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)Property).ResourceType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)Property).ResourceType = value ?? null /* arrayOf */; } + public System.Collections.Generic.List ResourceType { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)Property).ResourceType; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)Property).ResourceType = value ?? null /* arrayOf */; } /// Resource tags [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inherited)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Tag; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Tag = value ?? null /* model class */; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags Tag { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Tag; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Tag = value ?? null /* model class */; } /// Resource type [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inherited)] - public string Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)__resource).Type; } + public string Type { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)__resource).Type; } /// A list of validations to run on the custom resource provider's requests. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[] Validation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)Property).Validation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)Property).Validation = value ?? null /* arrayOf */; } + public System.Collections.Generic.List Validation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)Property).Validation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)Property).Validation = value ?? null /* arrayOf */; } /// Creates an new instance. public CustomRpManifest() @@ -98,56 +101,70 @@ public CustomRpManifest() /// A manifest file that defines the custom resource provider resources. public partial interface ICustomRpManifest : Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IJsonSerializable, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource { /// A list of actions that the custom resource provider implements. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"A list of actions that the custom resource provider implements.", SerializedName = @"actions", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[] Action { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition) })] + System.Collections.Generic.List Action { get; set; } /// The provisioning state of the resource provider. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"The provisioning state of the resource provider.", SerializedName = @"provisioningState", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get; } + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Accepted", "Deleting", "Running", "Succeeded", "Failed")] + string ProvisioningState { get; } /// A list of resource types that the custom resource provider implements. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"A list of resource types that the custom resource provider implements.", SerializedName = @"resourceTypes", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[] ResourceType { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition) })] + System.Collections.Generic.List ResourceType { get; set; } /// A list of validations to run on the custom resource provider's requests. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"A list of validations to run on the custom resource provider's requests.", SerializedName = @"validations", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[] Validation { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations) })] + System.Collections.Generic.List Validation { get; set; } } /// A manifest file that defines the custom resource provider resources. internal partial interface ICustomRpManifestInternal : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal { /// A list of actions that the custom resource provider implements. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[] Action { get; set; } + System.Collections.Generic.List Action { get; set; } /// The manifest for the custom resource provider - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties Property { get; set; } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties Property { get; set; } /// The provisioning state of the resource provider. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get; set; } + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Accepted", "Deleting", "Running", "Succeeded", "Failed")] + string ProvisioningState { get; set; } /// A list of resource types that the custom resource provider implements. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[] ResourceType { get; set; } + System.Collections.Generic.List ResourceType { get; set; } /// A list of validations to run on the custom resource provider's requests. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[] Validation { get; set; } + System.Collections.Generic.List Validation { get; set; } } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.json.cs similarity index 94% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.json.cs index 277ef488af21..bda1d733cefe 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifest.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifest.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -65,19 +65,19 @@ internal CustomRpManifest(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Run { return; } - __resource = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Resource(json); - {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifestProperties.FromJson(__jsonProperties) : Property;} + __resource = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Resource(json); + {_property = If( json?.PropertyT("properties"), out var __jsonProperties) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifestProperties.FromJson(__jsonProperties) : _property;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new CustomRpManifest(json) : null; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.PowerShell.cs similarity index 57% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.PowerShell.cs index 22766d5fd500..b98237251030 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,7 +55,15 @@ public partial class CustomRpManifestProperties partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into a new instance of 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. @@ -70,25 +78,25 @@ internal CustomRpManifestProperties(global::System.Collections.IDictionary conte // actually deserialize if (content.Contains("Action")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).Action = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[]) content.GetValueForProperty("Action",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).Action, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpActionRouteDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).Action = (System.Collections.Generic.List) content.GetValueForProperty("Action",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).Action, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpActionRouteDefinitionTypeConverter.ConvertFrom)); } if (content.Contains("ResourceType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).ResourceType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[]) content.GetValueForProperty("ResourceType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).ResourceType, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpResourceTypeRouteDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).ResourceType = (System.Collections.Generic.List) content.GetValueForProperty("ResourceType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).ResourceType, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpResourceTypeRouteDefinitionTypeConverter.ConvertFrom)); } if (content.Contains("Validation")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).Validation = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[]) content.GetValueForProperty("Validation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).Validation, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpValidationsTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).Validation = (System.Collections.Generic.List) content.GetValueForProperty("Validation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).Validation, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpValidationsTypeConverter.ConvertFrom)); } if (content.Contains("ProvisioningState")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).ProvisioningState = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState?) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).ProvisioningState, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).ProvisioningState = (string) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).ProvisioningState, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -103,47 +111,45 @@ internal CustomRpManifestProperties(global::System.Management.Automation.PSObjec // actually deserialize if (content.Contains("Action")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).Action = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[]) content.GetValueForProperty("Action",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).Action, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpActionRouteDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).Action = (System.Collections.Generic.List) content.GetValueForProperty("Action",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).Action, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpActionRouteDefinitionTypeConverter.ConvertFrom)); } if (content.Contains("ResourceType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).ResourceType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[]) content.GetValueForProperty("ResourceType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).ResourceType, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpResourceTypeRouteDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).ResourceType = (System.Collections.Generic.List) content.GetValueForProperty("ResourceType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).ResourceType, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpResourceTypeRouteDefinitionTypeConverter.ConvertFrom)); } if (content.Contains("Validation")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).Validation = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[]) content.GetValueForProperty("Validation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).Validation, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpValidationsTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).Validation = (System.Collections.Generic.List) content.GetValueForProperty("Validation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).Validation, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpValidationsTypeConverter.ConvertFrom)); } if (content.Contains("ProvisioningState")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).ProvisioningState = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState?) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal)this).ProvisioningState, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).ProvisioningState = (string) content.GetValueForProperty("ProvisioningState",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal)this).ProvisioningState, global::System.Convert.ToString); } AfterDeserializePSObject(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Collections.IDictionary content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new CustomRpManifestProperties(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new CustomRpManifestProperties(content); } @@ -153,12 +159,24 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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 manifest for the custom resource provider [System.ComponentModel.TypeConverter(typeof(CustomRpManifestPropertiesTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.TypeConverter.cs index 6406d2c23a7c..87053b67820b 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.cs similarity index 58% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.cs index 66363ecbb5c2..d15ff43b783d 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.cs @@ -3,46 +3,46 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// The manifest for the custom resource provider public partial class CustomRpManifestProperties : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal { /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[] _action; + private System.Collections.Generic.List _action; /// A list of actions that the custom resource provider implements. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[] Action { get => this._action; set => this._action = value; } + public System.Collections.Generic.List Action { get => this._action; set => this._action = value; } /// Internal Acessors for ProvisioningState - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestPropertiesInternal.ProvisioningState { get => this._provisioningState; set { {_provisioningState = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestPropertiesInternal.ProvisioningState { get => this._provisioningState; set { {_provisioningState = value;} } } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? _provisioningState; + private string _provisioningState; /// The provisioning state of the resource provider. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get => this._provisioningState; } + public string ProvisioningState { get => this._provisioningState; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[] _resourceType; + private System.Collections.Generic.List _resourceType; /// A list of resource types that the custom resource provider implements. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[] ResourceType { get => this._resourceType; set => this._resourceType = value; } + public System.Collections.Generic.List ResourceType { get => this._resourceType; set => this._resourceType = value; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[] _validation; + private System.Collections.Generic.List _validation; /// A list of validations to run on the custom resource provider's requests. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[] Validation { get => this._validation; set => this._validation = value; } + public System.Collections.Generic.List Validation { get => this._validation; set => this._validation = value; } /// Creates an new instance. public CustomRpManifestProperties() @@ -58,34 +58,47 @@ public partial interface ICustomRpManifestProperties : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"A list of actions that the custom resource provider implements.", SerializedName = @"actions", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[] Action { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition) })] + System.Collections.Generic.List Action { get; set; } /// The provisioning state of the resource provider. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"The provisioning state of the resource provider.", SerializedName = @"provisioningState", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get; } + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Accepted", "Deleting", "Running", "Succeeded", "Failed")] + string ProvisioningState { get; } /// A list of resource types that the custom resource provider implements. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"A list of resource types that the custom resource provider implements.", SerializedName = @"resourceTypes", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[] ResourceType { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition) })] + System.Collections.Generic.List ResourceType { get; set; } /// A list of validations to run on the custom resource provider's requests. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"A list of validations to run on the custom resource provider's requests.", SerializedName = @"validations", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[] Validation { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations) })] + System.Collections.Generic.List Validation { get; set; } } /// The manifest for the custom resource provider @@ -93,13 +106,14 @@ internal partial interface ICustomRpManifestPropertiesInternal { /// A list of actions that the custom resource provider implements. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[] Action { get; set; } + System.Collections.Generic.List Action { get; set; } /// The provisioning state of the resource provider. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState? ProvisioningState { get; set; } + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Accepted", "Deleting", "Running", "Succeeded", "Failed")] + string ProvisioningState { get; set; } /// A list of resource types that the custom resource provider implements. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[] ResourceType { get; set; } + System.Collections.Generic.List ResourceType { get; set; } /// A list of validations to run on the custom resource provider's requests. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[] Validation { get; set; } + System.Collections.Generic.List Validation { get; set; } } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.json.cs similarity index 82% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.json.cs index c7bd4aec9fb5..3e7736121310 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpManifestProperties.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpManifestProperties.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -65,21 +65,21 @@ internal CustomRpManifestProperties(Microsoft.Azure.PowerShell.Cmdlets.CustomPro { return; } - {_action = If( json?.PropertyT("actions"), out var __jsonActions) ? If( __jsonActions as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpActionRouteDefinition.FromJson(__u) )) ))() : null : Action;} - {_resourceType = If( json?.PropertyT("resourceTypes"), out var __jsonResourceTypes) ? If( __jsonResourceTypes as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonArray, out var __q) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__q, (__p)=>(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpResourceTypeRouteDefinition.FromJson(__p) )) ))() : null : ResourceType;} - {_validation = If( json?.PropertyT("validations"), out var __jsonValidations) ? If( __jsonValidations as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonArray, out var __l) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__l, (__k)=>(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpValidations.FromJson(__k) )) ))() : null : Validation;} - {_provisioningState = If( json?.PropertyT("provisioningState"), out var __jsonProvisioningState) ? (string)__jsonProvisioningState : (string)ProvisioningState;} + {_action = If( json?.PropertyT("actions"), out var __jsonActions) ? If( __jsonActions as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Models.ICustomRpActionRouteDefinition) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpActionRouteDefinition.FromJson(__u) )) ))() : null : _action;} + {_resourceType = If( json?.PropertyT("resourceTypes"), out var __jsonResourceTypes) ? If( __jsonResourceTypes as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpResourceTypeRouteDefinition.FromJson(__p) )) ))() : null : _resourceType;} + {_validation = If( json?.PropertyT("validations"), out var __jsonValidations) ? If( __jsonValidations as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Models.ICustomRpValidations) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpValidations.FromJson(__k) )) ))() : null : _validation;} + {_provisioningState = If( json?.PropertyT("provisioningState"), out var __jsonProvisioningState) ? (string)__jsonProvisioningState : (string)_provisioningState;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifestProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifestProperties FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new CustomRpManifestProperties(json) : null; } @@ -130,7 +130,7 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode } container.Add("validations",__m); } - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._provisioningState)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._provisioningState.ToString()) : null, "provisioningState" ,container.Add ); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.PowerShell.cs similarity index 70% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.PowerShell.cs index edd0a04b1faf..71f912eb2c72 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -57,7 +57,15 @@ public partial class CustomRpResourceTypeRouteDefinition partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into a new instance of 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. @@ -72,21 +80,21 @@ internal CustomRpResourceTypeRouteDefinition(global::System.Collections.IDiction // actually deserialize if (content.Contains("RoutingType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinitionInternal)this).RoutingType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting?) content.GetValueForProperty("RoutingType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinitionInternal)this).RoutingType, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinitionInternal)this).RoutingType = (string) content.GetValueForProperty("RoutingType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinitionInternal)this).RoutingType, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Endpoint")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -101,43 +109,43 @@ internal CustomRpResourceTypeRouteDefinition(global::System.Management.Automatio // actually deserialize if (content.Contains("RoutingType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinitionInternal)this).RoutingType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting?) content.GetValueForProperty("RoutingType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinitionInternal)this).RoutingType, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinitionInternal)this).RoutingType = (string) content.GetValueForProperty("RoutingType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinitionInternal)this).RoutingType, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Endpoint")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); } AfterDeserializePSObject(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Collections.IDictionary content that should be used. /// - /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new CustomRpResourceTypeRouteDefinition(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new CustomRpResourceTypeRouteDefinition(content); } @@ -149,12 +157,24 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// an instance of the model class. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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 route definition for a resource implemented by the custom resource provider. [System.ComponentModel.TypeConverter(typeof(CustomRpResourceTypeRouteDefinitionTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.TypeConverter.cs index 03ddeab7e703..1c31c5947a76 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -108,14 +108,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.cs similarity index 71% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.cs index 6585c16d70d6..d6a9a3c765f0 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -11,35 +11,35 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901P /// The route definition for a resource implemented by the custom resource provider. /// public partial class CustomRpResourceTypeRouteDefinition : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinitionInternal, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinitionInternal, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IValidates { /// - /// Backing field for Inherited model /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition __customRpRouteDefinition = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpRouteDefinition(); + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition __customRpRouteDefinition = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpRouteDefinition(); /// /// The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of /// a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}') /// [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inherited)] - public string Endpoint { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Endpoint; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Endpoint = value ; } + public string Endpoint { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Endpoint; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Endpoint = value ; } /// /// The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') /// [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inherited)] - public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Name = value ; } + public string Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)__customRpRouteDefinition).Name = value ; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting? _routingType; + private string _routingType; /// The routing types that are supported for resource requests. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting? RoutingType { get => this._routingType; set => this._routingType = value; } + public string RoutingType { get => this._routingType; set => this._routingType = value; } /// Creates an new instance. public CustomRpResourceTypeRouteDefinition() @@ -62,24 +62,29 @@ public CustomRpResourceTypeRouteDefinition() /// The route definition for a resource implemented by the custom resource provider. public partial interface ICustomRpResourceTypeRouteDefinition : Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IJsonSerializable, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition { /// The routing types that are supported for resource requests. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The routing types that are supported for resource requests.", SerializedName = @"routingType", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting? RoutingType { get; set; } + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Proxy", "Proxy,Cache")] + string RoutingType { get; set; } } /// The route definition for a resource implemented by the custom resource provider. internal partial interface ICustomRpResourceTypeRouteDefinitionInternal : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal { /// The routing types that are supported for resource requests. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting? RoutingType { get; set; } + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Proxy", "Proxy,Cache")] + string RoutingType { get; set; } } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.json.cs similarity index 94% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.json.cs index 66e2bf844717..804a64a9a3eb 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpResourceTypeRouteDefinition.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpResourceTypeRouteDefinition.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -67,19 +67,19 @@ internal CustomRpResourceTypeRouteDefinition(Microsoft.Azure.PowerShell.Cmdlets. { return; } - __customRpRouteDefinition = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpRouteDefinition(json); - {_routingType = If( json?.PropertyT("routingType"), out var __jsonRoutingType) ? (string)__jsonRoutingType : (string)RoutingType;} + __customRpRouteDefinition = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpRouteDefinition(json); + {_routingType = If( json?.PropertyT("routingType"), out var __jsonRoutingType) ? (string)__jsonRoutingType : (string)_routingType;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new CustomRpResourceTypeRouteDefinition(json) : null; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.PowerShell.cs similarity index 74% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.PowerShell.cs index e7c034819f04..c6863a0eed3f 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -57,7 +57,15 @@ public partial class CustomRpRouteDefinition partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into a new instance of 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. @@ -72,17 +80,17 @@ internal CustomRpRouteDefinition(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Endpoint")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -97,39 +105,37 @@ internal CustomRpRouteDefinition(global::System.Management.Automation.PSObject c // actually deserialize if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Endpoint")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint = (string) content.GetValueForProperty("Endpoint",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal)this).Endpoint, global::System.Convert.ToString); } AfterDeserializePSObject(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Collections.IDictionary content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new CustomRpRouteDefinition(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new CustomRpRouteDefinition(content); } @@ -139,12 +145,24 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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(); + } } /// A route definition that defines an action or resource that can be interacted with through the custom resource provider. [System.ComponentModel.TypeConverter(typeof(CustomRpRouteDefinitionTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.TypeConverter.cs index ebae61383644..761f6bcf1738 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.cs similarity index 96% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.cs index 8bec97ac050d..4addd36a3378 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -11,8 +11,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901P /// A route definition that defines an action or resource that can be interacted with through the custom resource provider. /// public partial class CustomRpRouteDefinition : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinitionInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinitionInternal { /// Backing field for property. @@ -51,6 +51,9 @@ public partial interface ICustomRpRouteDefinition : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = true, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}')", SerializedName = @"endpoint", PossibleTypes = new [] { typeof(string) })] @@ -61,6 +64,9 @@ public partial interface ICustomRpRouteDefinition : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = true, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}')", SerializedName = @"name", PossibleTypes = new [] { typeof(string) })] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.json.cs similarity index 95% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.json.cs index 264cd1e53847..1cd6e5a47e32 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpRouteDefinition.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpRouteDefinition.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -67,19 +67,19 @@ internal CustomRpRouteDefinition(Microsoft.Azure.PowerShell.Cmdlets.CustomProvid { return; } - {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} - {_endpoint = If( json?.PropertyT("endpoint"), out var __jsonEndpoint) ? (string)__jsonEndpoint : (string)Endpoint;} + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)_name;} + {_endpoint = If( json?.PropertyT("endpoint"), out var __jsonEndpoint) ? (string)__jsonEndpoint : (string)_endpoint;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpRouteDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpRouteDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new CustomRpRouteDefinition(json) : null; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.PowerShell.cs similarity index 73% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.PowerShell.cs index d98afebdf4e5..92a5bae15e55 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,7 +55,15 @@ public partial class CustomRpValidations partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into a new instance of 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. @@ -70,17 +78,17 @@ internal CustomRpValidations(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("ValidationType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidationsInternal)this).ValidationType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType?) content.GetValueForProperty("ValidationType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidationsInternal)this).ValidationType, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidationsInternal)this).ValidationType = (string) content.GetValueForProperty("ValidationType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidationsInternal)this).ValidationType, global::System.Convert.ToString); } if (content.Contains("Specification")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidationsInternal)this).Specification = (string) content.GetValueForProperty("Specification",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidationsInternal)this).Specification, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidationsInternal)this).Specification = (string) content.GetValueForProperty("Specification",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidationsInternal)this).Specification, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -95,39 +103,37 @@ internal CustomRpValidations(global::System.Management.Automation.PSObject conte // actually deserialize if (content.Contains("ValidationType")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidationsInternal)this).ValidationType = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType?) content.GetValueForProperty("ValidationType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidationsInternal)this).ValidationType, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType.CreateFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidationsInternal)this).ValidationType = (string) content.GetValueForProperty("ValidationType",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidationsInternal)this).ValidationType, global::System.Convert.ToString); } if (content.Contains("Specification")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidationsInternal)this).Specification = (string) content.GetValueForProperty("Specification",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidationsInternal)this).Specification, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidationsInternal)this).Specification = (string) content.GetValueForProperty("Specification",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidationsInternal)this).Specification, global::System.Convert.ToString); } AfterDeserializePSObject(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Collections.IDictionary content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new CustomRpValidations(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new CustomRpValidations(content); } @@ -137,12 +143,24 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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(); + } } /// A validation to apply on custom resource provider requests. [System.ComponentModel.TypeConverter(typeof(CustomRpValidationsTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.TypeConverter.cs index f96acc816778..aafbecf19b53 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.cs similarity index 81% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.cs index af68c4852e34..c0ed96bd41ec 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// A validation to apply on custom resource provider requests. public partial class CustomRpValidations : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidationsInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidationsInternal { /// Backing field for property. @@ -23,11 +23,11 @@ public partial class CustomRpValidations : public string Specification { get => this._specification; set => this._specification = value; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType? _validationType; + private string _validationType; /// The type of validation to run against a matching request. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType? ValidationType { get => this._validationType; set => this._validationType = value; } + public string ValidationType { get => this._validationType; set => this._validationType = value; } /// Creates an new instance. public CustomRpValidations() @@ -45,6 +45,9 @@ public partial interface ICustomRpValidations : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = true, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"A link to the validation specification. The specification must be hosted on raw.githubusercontent.com.", SerializedName = @"specification", PossibleTypes = new [] { typeof(string) })] @@ -53,10 +56,14 @@ public partial interface ICustomRpValidations : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The type of validation to run against a matching request.", SerializedName = @"validationType", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType? ValidationType { get; set; } + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Swagger")] + string ValidationType { get; set; } } /// A validation to apply on custom resource provider requests. @@ -68,7 +75,8 @@ internal partial interface ICustomRpValidationsInternal /// string Specification { get; set; } /// The type of validation to run against a matching request. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType? ValidationType { get; set; } + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PSArgumentCompleterAttribute("Swagger")] + string ValidationType { get; set; } } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.json.cs similarity index 95% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.json.cs index 458ca7bedab9..4e785fc630b0 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/CustomRpValidations.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/CustomRpValidations.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -65,19 +65,19 @@ internal CustomRpValidations(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders. { return; } - {_validationType = If( json?.PropertyT("validationType"), out var __jsonValidationType) ? (string)__jsonValidationType : (string)ValidationType;} - {_specification = If( json?.PropertyT("specification"), out var __jsonSpecification) ? (string)__jsonSpecification : (string)Specification;} + {_validationType = If( json?.PropertyT("validationType"), out var __jsonValidationType) ? (string)__jsonValidationType : (string)_validationType;} + {_specification = If( json?.PropertyT("specification"), out var __jsonSpecification) ? (string)__jsonSpecification : (string)_specification;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new CustomRpValidations(json) : null; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.PowerShell.cs similarity index 68% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.PowerShell.cs index 24cb3d2b11c8..5defea67b44c 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,35 +55,41 @@ public partial class ErrorDefinition partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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 . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ErrorDefinition(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ErrorDefinition(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -98,21 +104,21 @@ internal ErrorDefinition(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("Code")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Code, global::System.Convert.ToString); } if (content.Contains("Message")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Message, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Message, global::System.Convert.ToString); } if (content.Contains("Detail")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[]) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Detail, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Detail = (System.Collections.Generic.List) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Detail, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinitionTypeConverter.ConvertFrom)); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -127,15 +133,15 @@ internal ErrorDefinition(global::System.Management.Automation.PSObject content) // actually deserialize if (content.Contains("Code")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Code, global::System.Convert.ToString); } if (content.Contains("Message")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Message, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Message, global::System.Convert.ToString); } if (content.Contains("Detail")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[]) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)this).Detail, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Detail = (System.Collections.Generic.List) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)this).Detail, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinitionTypeConverter.ConvertFrom)); } AfterDeserializePSObject(content); } @@ -145,12 +151,24 @@ internal ErrorDefinition(global::System.Management.Automation.PSObject content) /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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(); + } } /// Error definition. [System.ComponentModel.TypeConverter(typeof(ErrorDefinitionTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.TypeConverter.cs index 6d349e5bd18c..85e9096152dd 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.cs similarity index 75% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.cs index b35a03c8517d..6d60cef562fb 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// Error definition. public partial class ErrorDefinition : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal { /// Backing field for property. @@ -23,11 +23,11 @@ public partial class ErrorDefinition : public string Code { get => this._code; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[] _detail; + private System.Collections.Generic.List _detail; /// Internal error details. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[] Detail { get => this._detail; } + public System.Collections.Generic.List Detail { get => this._detail; } /// Backing field for property. private string _message; @@ -37,13 +37,13 @@ public partial class ErrorDefinition : public string Message { get => this._message; } /// Internal Acessors for Code - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal.Code { get => this._code; set { {_code = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal.Code { get => this._code; set { {_code = value;} } } /// Internal Acessors for Detail - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[] Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal.Detail { get => this._detail; set { {_detail = value;} } } + System.Collections.Generic.List Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal.Detail { get => this._detail; set { {_detail = value;} } } /// Internal Acessors for Message - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal.Message { get => this._message; set { {_message = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal.Message { get => this._message; set { {_message = value;} } } /// Creates an new instance. public ErrorDefinition() @@ -61,6 +61,9 @@ public partial interface IErrorDefinition : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"Service specific error code which serves as the substatus for the HTTP error code.", SerializedName = @"code", PossibleTypes = new [] { typeof(string) })] @@ -69,14 +72,20 @@ public partial interface IErrorDefinition : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"Internal error details.", SerializedName = @"details", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[] Detail { get; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition) })] + System.Collections.Generic.List Detail { get; } /// Description of the error. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"Description of the error.", SerializedName = @"message", PossibleTypes = new [] { typeof(string) })] @@ -92,7 +101,7 @@ internal partial interface IErrorDefinitionInternal /// string Code { get; set; } /// Internal error details. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[] Detail { get; set; } + System.Collections.Generic.List Detail { get; set; } /// Description of the error. string Message { get; set; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.json.cs similarity index 91% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.json.cs index 246d2ff729f4..a143d8f59d72 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorDefinition.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorDefinition.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -65,20 +65,20 @@ internal ErrorDefinition(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runt { 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;} - {_detail = If( json?.PropertyT("details"), out var __jsonDetails) ? If( __jsonDetails as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinition.FromJson(__u) )) ))() : null : Detail;} + {_code = If( json?.PropertyT("code"), out var __jsonCode) ? (string)__jsonCode : (string)_code;} + {_message = If( json?.PropertyT("message"), out var __jsonMessage) ? (string)__jsonMessage : (string)_message;} + {_detail = If( json?.PropertyT("details"), out var __jsonDetails) ? If( __jsonDetails as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Models.IErrorDefinition) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinition.FromJson(__u) )) ))() : null : _detail;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new ErrorDefinition(json) : null; } @@ -102,15 +102,15 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode { return container; } - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._code)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._code.ToString()) : null, "code" ,container.Add ); } - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._message)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._message.ToString()) : null, "message" ,container.Add ); } - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { if (null != this._detail) { diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.PowerShell.cs similarity index 64% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.PowerShell.cs index 4133af1286e4..5841a579c295 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,35 +55,41 @@ public partial class ErrorResponse partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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 . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ErrorResponse(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ErrorResponse(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -98,25 +104,25 @@ internal ErrorResponse(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("Error")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinitionTypeConverter.ConvertFrom); } if (content.Contains("Code")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Code, global::System.Convert.ToString); } if (content.Contains("Message")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Message, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Message, global::System.Convert.ToString); } if (content.Contains("Detail")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[]) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Detail = (System.Collections.Generic.List) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinitionTypeConverter.ConvertFrom)); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -131,19 +137,19 @@ internal ErrorResponse(global::System.Management.Automation.PSObject content) // actually deserialize if (content.Contains("Error")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinitionTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinitionTypeConverter.ConvertFrom); } if (content.Contains("Code")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Code, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Code, global::System.Convert.ToString); } if (content.Contains("Message")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Message, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Message = (string) content.GetValueForProperty("Message",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Message, global::System.Convert.ToString); } if (content.Contains("Detail")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Detail = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[]) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinitionTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Detail = (System.Collections.Generic.List) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinitionTypeConverter.ConvertFrom)); } AfterDeserializePSObject(content); } @@ -153,12 +159,24 @@ internal ErrorResponse(global::System.Management.Automation.PSObject content) /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.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(); + } } /// Error response. [System.ComponentModel.TypeConverter(typeof(ErrorResponseTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.TypeConverter.cs index 2cc68b9f2cad..3e3e667a8442 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.cs similarity index 62% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.cs index b9057dca289e..10ede8e55b68 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.cs @@ -3,48 +3,48 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// Error response. public partial class ErrorResponse : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal { /// /// Service specific error code which serves as the substatus for the HTTP error code. /// [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public string Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)Error).Code; } + public string Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)Error).Code; } /// Internal error details. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[] Detail { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)Error).Detail; } + public System.Collections.Generic.List Detail { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)Error).Detail; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition _error; + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition _error; /// The error details. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - internal Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinition()); set => this._error = value; } + internal Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinition()); set => this._error = value; } /// Description of the error. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public string Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)Error).Message; } + public string Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)Error).Message; } /// Internal Acessors for Code - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal.Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)Error).Code; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)Error).Code = value; } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal.Code { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)Error).Code; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)Error).Code = value; } /// Internal Acessors for Detail - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[] Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal.Detail { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)Error).Detail; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)Error).Detail = value; } + System.Collections.Generic.List Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal.Detail { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)Error).Detail; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)Error).Detail = value; } /// Internal Acessors for Error - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal.Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinition()); set { {_error = value;} } } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal.Error { get => (this._error = this._error ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinition()); set { {_error = value;} } } /// Internal Acessors for Message - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponseInternal.Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)Error).Message; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinitionInternal)Error).Message = value; } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponseInternal.Message { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)Error).Message; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinitionInternal)Error).Message = value; } /// Creates an new instance. public ErrorResponse() @@ -62,6 +62,9 @@ public partial interface IErrorResponse : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"Service specific error code which serves as the substatus for the HTTP error code.", SerializedName = @"code", PossibleTypes = new [] { typeof(string) })] @@ -70,14 +73,20 @@ public partial interface IErrorResponse : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"Internal error details.", SerializedName = @"details", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[] Detail { get; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition) })] + System.Collections.Generic.List Detail { get; } /// Description of the error. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"Description of the error.", SerializedName = @"message", PossibleTypes = new [] { typeof(string) })] @@ -93,9 +102,9 @@ internal partial interface IErrorResponseInternal /// string Code { get; set; } /// Internal error details. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition[] Detail { get; set; } + System.Collections.Generic.List Detail { get; set; } /// The error details. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorDefinition Error { get; set; } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorDefinition Error { get; set; } /// Description of the error. string Message { get; set; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.json.cs similarity index 95% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.json.cs index 1b57c09db380..00dcf7e6fdeb 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ErrorResponse.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ErrorResponse.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -65,18 +65,18 @@ internal ErrorResponse(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtim { return; } - {_error = If( json?.PropertyT("error"), out var __jsonError) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ErrorDefinition.FromJson(__jsonError) : Error;} + {_error = If( json?.PropertyT("error"), out var __jsonError) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ErrorDefinition.FromJson(__jsonError) : _error;} AfterFromJson(json); } /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new ErrorResponse(json) : null; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.PowerShell.cs similarity index 69% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.PowerShell.cs index a20b6242399a..010e1f7f25ae 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,29 +55,35 @@ public partial class ListByCustomRpManifest partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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 . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ListByCustomRpManifest(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ListByCustomRpManifest(content); } @@ -87,10 +93,10 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -105,17 +111,17 @@ internal ListByCustomRpManifest(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("Value")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifestInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifestInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifestTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifestInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifestInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifestTypeConverter.ConvertFrom)); } if (content.Contains("NextLink")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifestInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifestInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifestInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifestInternal)this).NextLink, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -130,11 +136,11 @@ internal ListByCustomRpManifest(global::System.Management.Automation.PSObject co // actually deserialize if (content.Contains("Value")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifestInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifestInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifestTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifestInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifestInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifestTypeConverter.ConvertFrom)); } if (content.Contains("NextLink")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifestInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifestInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifestInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifestInternal)this).NextLink, global::System.Convert.ToString); } AfterDeserializePSObject(content); } @@ -143,6 +149,18 @@ internal ListByCustomRpManifest(global::System.Management.Automation.PSObject co /// a containing this model serialized to JSON text. public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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(); + } } /// List of custom resource providers. [System.ComponentModel.TypeConverter(typeof(ListByCustomRpManifestTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.TypeConverter.cs index a16b1888c2eb..d11d806084fc 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.cs similarity index 77% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.cs index 5d52d10858b1..786008614fd4 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// List of custom resource providers. public partial class ListByCustomRpManifest : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifestInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifestInternal { /// Backing field for property. @@ -21,11 +21,11 @@ public partial class ListByCustomRpManifest : public string NextLink { get => this._nextLink; set => this._nextLink = value; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest[] _value; + private System.Collections.Generic.List _value; /// The array of custom resource provider manifests. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest[] Value { get => this._value; set => this._value = value; } + public System.Collections.Generic.List Value { get => this._value; set => this._value = value; } /// Creates an new instance. public ListByCustomRpManifest() @@ -41,6 +41,9 @@ public partial interface IListByCustomRpManifest : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The URL to use for getting the next set of results.", SerializedName = @"nextLink", PossibleTypes = new [] { typeof(string) })] @@ -49,10 +52,13 @@ public partial interface IListByCustomRpManifest : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The array of custom resource provider manifests.", SerializedName = @"value", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest[] Value { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest) })] + System.Collections.Generic.List Value { get; set; } } /// List of custom resource providers. @@ -62,7 +68,7 @@ internal partial interface IListByCustomRpManifestInternal /// The URL to use for getting the next set of results. string NextLink { get; set; } /// The array of custom resource provider manifests. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest[] Value { get; set; } + System.Collections.Generic.List Value { get; set; } } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.json.cs similarity index 91% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.json.cs index aa1ef64ff137..b79a671680b9 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ListByCustomRpManifest.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ListByCustomRpManifest.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -54,13 +54,13 @@ public partial class ListByCustomRpManifest partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject container, ref bool returnNow); /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new ListByCustomRpManifest(json) : null; } @@ -77,8 +77,8 @@ internal ListByCustomRpManifest(Microsoft.Azure.PowerShell.Cmdlets.CustomProvide { return; } - {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifest.FromJson(__u) )) ))() : null : Value;} - {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)NextLink;} + {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Models.ICustomRpManifest) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest.FromJson(__u) )) ))() : null : _value;} + {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)_nextLink;} AfterFromJson(json); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.PowerShell.cs similarity index 67% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.PowerShell.cs index 04378e87c97f..91fd80f1f023 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,27 +55,35 @@ public partial class Resource partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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 . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new Resource(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new Resource(content); } @@ -85,10 +93,10 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -103,29 +111,29 @@ internal Resource(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("Id")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Id, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Type")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Type, global::System.Convert.ToString); } if (content.Contains("Location")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Location = (string) content.GetValueForProperty("Location",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Location, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Location = (string) content.GetValueForProperty("Location",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Location, global::System.Convert.ToString); } if (content.Contains("Tag")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceTagsTypeConverter.ConvertFrom); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -140,23 +148,23 @@ internal Resource(global::System.Management.Automation.PSObject content) // actually deserialize if (content.Contains("Id")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Id, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Id = (string) content.GetValueForProperty("Id",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Id, global::System.Convert.ToString); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("Type")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Type, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Type = (string) content.GetValueForProperty("Type",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Type, global::System.Convert.ToString); } if (content.Contains("Location")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Location = (string) content.GetValueForProperty("Location",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Location, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Location = (string) content.GetValueForProperty("Location",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Location, global::System.Convert.ToString); } if (content.Contains("Tag")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceTagsTypeConverter.ConvertFrom); } AfterDeserializePSObject(content); } @@ -165,6 +173,18 @@ internal Resource(global::System.Management.Automation.PSObject content) /// a containing this model serialized to JSON text. public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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 definition. [System.ComponentModel.TypeConverter(typeof(ResourceTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.TypeConverter.cs index 80ab9a0659a9..cb8fb2f02df1 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -105,14 +105,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.cs similarity index 84% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.cs index c4ca6cb6141f..8a12991f574d 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// The resource definition. public partial class Resource : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal { /// Backing field for property. @@ -28,13 +28,13 @@ public partial class Resource : public string Location { get => this._location; set => this._location = value; } /// Internal Acessors for Id - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal.Id { get => this._id; set { {_id = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal.Id { get => this._id; set { {_id = value;} } } /// Internal Acessors for Name - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal.Name { get => this._name; set { {_name = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal.Name { get => this._name; set { {_name = value;} } } /// Internal Acessors for Type - string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceInternal.Type { get => this._type; set { {_type = value;} } } + string Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceInternal.Type { get => this._type; set { {_type = value;} } } /// Backing field for property. private string _name; @@ -44,11 +44,11 @@ public partial class Resource : public string Name { get => this._name; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags _tag; + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags _tag; /// Resource tags [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags Tag { get => (this._tag = this._tag ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTags()); set => this._tag = value; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags Tag { get => (this._tag = this._tag ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceTags()); set => this._tag = value; } /// Backing field for property. private string _type; @@ -71,14 +71,20 @@ public partial interface IResource : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"Resource Id", SerializedName = @"id", PossibleTypes = new [] { typeof(string) })] string Id { get; } /// Resource location [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( - Required = true, + Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = false, Description = @"Resource location", SerializedName = @"location", PossibleTypes = new [] { typeof(string) })] @@ -87,6 +93,9 @@ public partial interface IResource : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"Resource name", SerializedName = @"name", PossibleTypes = new [] { typeof(string) })] @@ -95,14 +104,20 @@ public partial interface IResource : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Resource tags", SerializedName = @"tags", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags Tag { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags) })] + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags Tag { get; set; } /// Resource type [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = true, + Read = true, + Create = false, + Update = false, Description = @"Resource type", SerializedName = @"type", PossibleTypes = new [] { typeof(string) })] @@ -120,7 +135,7 @@ internal partial interface IResourceInternal /// Resource name string Name { get; set; } /// Resource tags - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags Tag { get; set; } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags Tag { get; set; } /// Resource type string Type { get; set; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.json.cs similarity index 89% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.json.cs index 943cb64fe76f..0dd408db7850 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/Resource.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Resource.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -54,13 +54,13 @@ public partial class Resource partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject container, ref bool returnNow); /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResource FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResource FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new Resource(json) : null; } @@ -77,11 +77,11 @@ internal Resource(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Jso { return; } - {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)Id;} - {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} - {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)Type;} - {_location = If( json?.PropertyT("location"), out var __jsonLocation) ? (string)__jsonLocation : (string)Location;} - {_tag = If( json?.PropertyT("tags"), out var __jsonTags) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTags.FromJson(__jsonTags) : Tag;} + {_id = If( json?.PropertyT("id"), out var __jsonId) ? (string)__jsonId : (string)_id;} + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)_name;} + {_type = If( json?.PropertyT("type"), out var __jsonType) ? (string)__jsonType : (string)_type;} + {_location = If( json?.PropertyT("location"), out var __jsonLocation) ? (string)__jsonLocation : (string)_location;} + {_tag = If( json?.PropertyT("tags"), out var __jsonTags) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceTags.FromJson(__jsonTags) : _tag;} AfterFromJson(json); } @@ -104,19 +104,22 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode { return container; } - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._id)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._id.ToString()) : null, "id" ,container.Add ); } - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._name)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._name.ToString()) : null, "name" ,container.Add ); } - if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeReadOnly)) + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)) { AddIf( null != (((object)this._type)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._type.ToString()) : null, "type" ,container.Add ); } - AddIf( null != (((object)this._location)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._location.ToString()) : null, "location" ,container.Add ); + if (serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeRead)||serializationMode.HasFlag(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate)) + { + AddIf( null != (((object)this._location)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonString(this._location.ToString()) : null, "location" ,container.Add ); + } AddIf( null != this._tag ? (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode) this._tag.ToJson(null,serializationMode) : null, "tags" ,container.Add ); AfterToJson(ref container); return container; diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.PowerShell.cs similarity index 62% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.PowerShell.cs index 794402efa625..d93d144dd6f2 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,29 +55,35 @@ public partial class ResourceProviderOperation partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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 . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ResourceProviderOperation(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ResourceProviderOperation(content); } @@ -87,10 +93,10 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -105,33 +111,33 @@ internal ResourceProviderOperation(global::System.Collections.IDictionary conten // actually deserialize if (content.Contains("Display")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).Display = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay) content.GetValueForProperty("Display",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).Display, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationDisplayTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).Display = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay) content.GetValueForProperty("Display",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).Display, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationDisplayTypeConverter.ConvertFrom); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("DisplayProvider")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayProvider = (string) content.GetValueForProperty("DisplayProvider",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayProvider, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayProvider = (string) content.GetValueForProperty("DisplayProvider",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayProvider, global::System.Convert.ToString); } if (content.Contains("DisplayResource")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayResource = (string) content.GetValueForProperty("DisplayResource",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayResource, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayResource = (string) content.GetValueForProperty("DisplayResource",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayResource, global::System.Convert.ToString); } if (content.Contains("DisplayOperation")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayOperation = (string) content.GetValueForProperty("DisplayOperation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayOperation, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayOperation = (string) content.GetValueForProperty("DisplayOperation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayOperation, global::System.Convert.ToString); } if (content.Contains("DisplayDescription")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayDescription, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayDescription, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -146,27 +152,27 @@ internal ResourceProviderOperation(global::System.Management.Automation.PSObject // actually deserialize if (content.Contains("Display")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).Display = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay) content.GetValueForProperty("Display",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).Display, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationDisplayTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).Display = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay) content.GetValueForProperty("Display",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).Display, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationDisplayTypeConverter.ConvertFrom); } if (content.Contains("Name")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).Name, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).Name = (string) content.GetValueForProperty("Name",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).Name, global::System.Convert.ToString); } if (content.Contains("DisplayProvider")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayProvider = (string) content.GetValueForProperty("DisplayProvider",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayProvider, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayProvider = (string) content.GetValueForProperty("DisplayProvider",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayProvider, global::System.Convert.ToString); } if (content.Contains("DisplayResource")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayResource = (string) content.GetValueForProperty("DisplayResource",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayResource, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayResource = (string) content.GetValueForProperty("DisplayResource",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayResource, global::System.Convert.ToString); } if (content.Contains("DisplayOperation")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayOperation = (string) content.GetValueForProperty("DisplayOperation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayOperation, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayOperation = (string) content.GetValueForProperty("DisplayOperation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayOperation, global::System.Convert.ToString); } if (content.Contains("DisplayDescription")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal)this).DisplayDescription, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayDescription = (string) content.GetValueForProperty("DisplayDescription",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal)this).DisplayDescription, global::System.Convert.ToString); } AfterDeserializePSObject(content); } @@ -175,6 +181,18 @@ internal ResourceProviderOperation(global::System.Management.Automation.PSObject /// a containing this model serialized to JSON text. public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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(); + } } /// Supported operations of this resource provider. [System.ComponentModel.TypeConverter(typeof(ResourceProviderOperationTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.TypeConverter.cs index 2051617daafa..26911ed816f7 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.cs similarity index 74% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.cs index 4fa5548744e1..d5afc6773151 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.cs @@ -3,41 +3,41 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// Supported operations of this resource provider. public partial class ResourceProviderOperation : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal { /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay _display; + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay _display; /// Display metadata associated with the operation. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - internal Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay Display { get => (this._display = this._display ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationDisplay()); set => this._display = value; } + internal Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay Display { get => (this._display = this._display ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationDisplay()); set => this._display = value; } /// Description of this operation. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public string DisplayDescription { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)Display).Description; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)Display).Description = value ?? null; } + public string DisplayDescription { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)Display).Description; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)Display).Description = value ?? null; } /// Type of operation: get, read, delete, etc. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public string DisplayOperation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)Display).Operation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)Display).Operation = value ?? null; } + public string DisplayOperation { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)Display).Operation; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)Display).Operation = value ?? null; } /// Resource provider: Microsoft Custom Providers. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public string DisplayProvider { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)Display).Provider; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)Display).Provider = value ?? null; } + public string DisplayProvider { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)Display).Provider; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)Display).Provider = value ?? null; } /// Resource on which the operation is performed. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Inlined)] - public string DisplayResource { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)Display).Resource; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)Display).Resource = value ?? null; } + public string DisplayResource { get => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)Display).Resource; set => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)Display).Resource = value ?? null; } /// Internal Acessors for Display - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationInternal.Display { get => (this._display = this._display ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationDisplay()); set { {_display = value;} } } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationInternal.Display { get => (this._display = this._display ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationDisplay()); set { {_display = value;} } } /// Backing field for property. private string _name; @@ -60,6 +60,9 @@ public partial interface IResourceProviderOperation : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Description of this operation.", SerializedName = @"description", PossibleTypes = new [] { typeof(string) })] @@ -68,6 +71,9 @@ public partial interface IResourceProviderOperation : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Type of operation: get, read, delete, etc.", SerializedName = @"operation", PossibleTypes = new [] { typeof(string) })] @@ -76,6 +82,9 @@ public partial interface IResourceProviderOperation : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Resource provider: Microsoft Custom Providers.", SerializedName = @"provider", PossibleTypes = new [] { typeof(string) })] @@ -84,6 +93,9 @@ public partial interface IResourceProviderOperation : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Resource on which the operation is performed.", SerializedName = @"resource", PossibleTypes = new [] { typeof(string) })] @@ -92,6 +104,9 @@ public partial interface IResourceProviderOperation : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Operation name, in format of {provider}/{resource}/{operation}", SerializedName = @"name", PossibleTypes = new [] { typeof(string) })] @@ -103,7 +118,7 @@ internal partial interface IResourceProviderOperationInternal { /// Display metadata associated with the operation. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay Display { get; set; } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay Display { get; set; } /// Description of this operation. string DisplayDescription { get; set; } /// Type of operation: get, read, delete, etc. diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.json.cs similarity index 94% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.json.cs index f97e68e98ac6..8a407b33ea1c 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperation.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperation.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -54,13 +54,13 @@ public partial class ResourceProviderOperation partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject container, ref bool returnNow); /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new ResourceProviderOperation(json) : null; } @@ -77,8 +77,8 @@ internal ResourceProviderOperation(Microsoft.Azure.PowerShell.Cmdlets.CustomProv { return; } - {_display = If( json?.PropertyT("display"), out var __jsonDisplay) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationDisplay.FromJson(__jsonDisplay) : Display;} - {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)Name;} + {_display = If( json?.PropertyT("display"), out var __jsonDisplay) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationDisplay.FromJson(__jsonDisplay) : _display;} + {_name = If( json?.PropertyT("name"), out var __jsonName) ? (string)__jsonName : (string)_name;} AfterFromJson(json); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.PowerShell.cs similarity index 67% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.PowerShell.cs index 198d75222844..30e5259d96b8 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,29 +55,37 @@ public partial class ResourceProviderOperationDisplay partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ResourceProviderOperationDisplay(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ResourceProviderOperationDisplay(content); } @@ -87,10 +95,10 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -105,25 +113,25 @@ internal ResourceProviderOperationDisplay(global::System.Collections.IDictionary // actually deserialize if (content.Contains("Provider")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Provider = (string) content.GetValueForProperty("Provider",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Provider, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Provider = (string) content.GetValueForProperty("Provider",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Provider, global::System.Convert.ToString); } if (content.Contains("Resource")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Resource = (string) content.GetValueForProperty("Resource",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Resource, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Resource = (string) content.GetValueForProperty("Resource",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Resource, global::System.Convert.ToString); } if (content.Contains("Operation")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Operation = (string) content.GetValueForProperty("Operation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Operation, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Operation = (string) content.GetValueForProperty("Operation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Operation, global::System.Convert.ToString); } if (content.Contains("Description")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Description, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -138,19 +146,19 @@ internal ResourceProviderOperationDisplay(global::System.Management.Automation.P // actually deserialize if (content.Contains("Provider")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Provider = (string) content.GetValueForProperty("Provider",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Provider, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Provider = (string) content.GetValueForProperty("Provider",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Provider, global::System.Convert.ToString); } if (content.Contains("Resource")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Resource = (string) content.GetValueForProperty("Resource",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Resource, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Resource = (string) content.GetValueForProperty("Resource",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Resource, global::System.Convert.ToString); } if (content.Contains("Operation")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Operation = (string) content.GetValueForProperty("Operation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Operation, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Operation = (string) content.GetValueForProperty("Operation",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Operation, global::System.Convert.ToString); } if (content.Contains("Description")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal)this).Description, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Description = (string) content.GetValueForProperty("Description",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal)this).Description, global::System.Convert.ToString); } AfterDeserializePSObject(content); } @@ -159,6 +167,18 @@ internal ResourceProviderOperationDisplay(global::System.Management.Automation.P /// a containing this model serialized to JSON text. public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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(); + } } /// Display metadata associated with the operation. [System.ComponentModel.TypeConverter(typeof(ResourceProviderOperationDisplayTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.TypeConverter.cs index acd26e88b43d..ead37a66633d 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -107,14 +107,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.cs similarity index 93% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.cs index a6340a79b242..9314151618c0 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// Display metadata associated with the operation. public partial class ResourceProviderOperationDisplay : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplayInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplayInternal { /// Backing field for property. @@ -55,6 +55,9 @@ public partial interface IResourceProviderOperationDisplay : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Description of this operation.", SerializedName = @"description", PossibleTypes = new [] { typeof(string) })] @@ -63,6 +66,9 @@ public partial interface IResourceProviderOperationDisplay : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Type of operation: get, read, delete, etc.", SerializedName = @"operation", PossibleTypes = new [] { typeof(string) })] @@ -71,6 +77,9 @@ public partial interface IResourceProviderOperationDisplay : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Resource provider: Microsoft Custom Providers.", SerializedName = @"provider", PossibleTypes = new [] { typeof(string) })] @@ -79,6 +88,9 @@ public partial interface IResourceProviderOperationDisplay : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Resource on which the operation is performed.", SerializedName = @"resource", PossibleTypes = new [] { typeof(string) })] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.json.cs similarity index 95% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.json.cs index c42bf2279b1d..c972f19caf4a 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationDisplay.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationDisplay.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -54,13 +54,13 @@ public partial class ResourceProviderOperationDisplay partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject container, ref bool returnNow); /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationDisplay FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationDisplay FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new ResourceProviderOperationDisplay(json) : null; } @@ -77,10 +77,10 @@ internal ResourceProviderOperationDisplay(Microsoft.Azure.PowerShell.Cmdlets.Cus { return; } - {_provider = If( json?.PropertyT("provider"), out var __jsonProvider) ? (string)__jsonProvider : (string)Provider;} - {_resource = If( json?.PropertyT("resource"), out var __jsonResource) ? (string)__jsonResource : (string)Resource;} - {_operation = If( json?.PropertyT("operation"), out var __jsonOperation) ? (string)__jsonOperation : (string)Operation;} - {_description = If( json?.PropertyT("description"), out var __jsonDescription) ? (string)__jsonDescription : (string)Description;} + {_provider = If( json?.PropertyT("provider"), out var __jsonProvider) ? (string)__jsonProvider : (string)_provider;} + {_resource = If( json?.PropertyT("resource"), out var __jsonResource) ? (string)__jsonResource : (string)_resource;} + {_operation = If( json?.PropertyT("operation"), out var __jsonOperation) ? (string)__jsonOperation : (string)_operation;} + {_description = If( json?.PropertyT("description"), out var __jsonDescription) ? (string)__jsonDescription : (string)_description;} AfterFromJson(json); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.PowerShell.cs similarity index 68% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.PowerShell.cs index 48e2357df180..d5a056613db3 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,29 +55,35 @@ public partial class ResourceProviderOperationList partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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 . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ResourceProviderOperationList(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ResourceProviderOperationList(content); } @@ -87,10 +93,10 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -105,17 +111,17 @@ internal ResourceProviderOperationList(global::System.Collections.IDictionary co // actually deserialize if (content.Contains("Value")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationListInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationListInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationListInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationListInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationTypeConverter.ConvertFrom)); } if (content.Contains("NextLink")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationListInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationListInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationListInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationListInternal)this).NextLink, global::System.Convert.ToString); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -130,11 +136,11 @@ internal ResourceProviderOperationList(global::System.Management.Automation.PSOb // actually deserialize if (content.Contains("Value")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationListInternal)this).Value = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation[]) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationListInternal)this).Value, __y => TypeConverterExtensions.SelectToArray(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperationTypeConverter.ConvertFrom)); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationListInternal)this).Value = (System.Collections.Generic.List) content.GetValueForProperty("Value",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationListInternal)this).Value, __y => TypeConverterExtensions.SelectToList(__y, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperationTypeConverter.ConvertFrom)); } if (content.Contains("NextLink")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationListInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationListInternal)this).NextLink, global::System.Convert.ToString); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationListInternal)this).NextLink = (string) content.GetValueForProperty("NextLink",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationListInternal)this).NextLink, global::System.Convert.ToString); } AfterDeserializePSObject(content); } @@ -143,6 +149,18 @@ internal ResourceProviderOperationList(global::System.Management.Automation.PSOb /// a containing this model serialized to JSON text. public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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(); + } } /// Results of the request to list operations. [System.ComponentModel.TypeConverter(typeof(ResourceProviderOperationListTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.TypeConverter.cs index fb9f52510b27..4f8a04856eea 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.cs similarity index 76% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.cs index 107da38f9ed6..82a240946dbc 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// Results of the request to list operations. public partial class ResourceProviderOperationList : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationListInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationListInternal { /// Backing field for property. @@ -21,11 +21,11 @@ public partial class ResourceProviderOperationList : public string NextLink { get => this._nextLink; set => this._nextLink = value; } /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation[] _value; + private System.Collections.Generic.List _value; /// List of operations supported by this resource provider. [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation[] Value { get => this._value; set => this._value = value; } + public System.Collections.Generic.List Value { get => this._value; set => this._value = value; } /// Creates an new instance. public ResourceProviderOperationList() @@ -41,6 +41,9 @@ public partial interface IResourceProviderOperationList : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"The URL to use for getting the next set of results.", SerializedName = @"nextLink", PossibleTypes = new [] { typeof(string) })] @@ -49,10 +52,13 @@ public partial interface IResourceProviderOperationList : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"List of operations supported by this resource provider.", SerializedName = @"value", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation[] Value { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation) })] + System.Collections.Generic.List Value { get; set; } } /// Results of the request to list operations. @@ -62,7 +68,7 @@ internal partial interface IResourceProviderOperationListInternal /// The URL to use for getting the next set of results. string NextLink { get; set; } /// List of operations supported by this resource provider. - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation[] Value { get; set; } + System.Collections.Generic.List Value { get; set; } } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.json.cs similarity index 90% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.json.cs index 9025fab24b30..4e53f00d2900 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProviderOperationList.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProviderOperationList.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -54,13 +54,13 @@ public partial class ResourceProviderOperationList partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject container, ref bool returnNow); /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new ResourceProviderOperationList(json) : null; } @@ -77,8 +77,8 @@ internal ResourceProviderOperationList(Microsoft.Azure.PowerShell.Cmdlets.Custom { return; } - {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonArray, out var __v) ? new global::System.Func(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProviderOperation.FromJson(__u) )) ))() : null : Value;} - {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)NextLink;} + {_value = If( json?.PropertyT("value"), out var __jsonValue) ? If( __jsonValue as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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.CustomProviders.Models.IResourceProviderOperation) (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProviderOperation.FromJson(__u) )) ))() : null : _value;} + {_nextLink = If( json?.PropertyT("nextLink"), out var __jsonNextLink) ? (string)__jsonNextLink : (string)_nextLink;} AfterFromJson(json); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.PowerShell.cs similarity index 74% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.PowerShell.cs index 3829e57e72f8..2b06515e1486 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,29 +55,35 @@ public partial class ResourceProvidersUpdate partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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 . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ResourceProvidersUpdate(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ResourceProvidersUpdate(content); } @@ -87,10 +93,10 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -105,13 +111,13 @@ internal ResourceProvidersUpdate(global::System.Collections.IDictionary content) // actually deserialize if (content.Contains("Tag")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProvidersUpdateTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProvidersUpdateTagsTypeConverter.ConvertFrom); } AfterDeserializeDictionary(content); } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -126,7 +132,7 @@ internal ResourceProvidersUpdate(global::System.Management.Automation.PSObject c // actually deserialize if (content.Contains("Tag")) { - ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProvidersUpdateTagsTypeConverter.ConvertFrom); + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateInternal)this).Tag = (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags) content.GetValueForProperty("Tag",((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateInternal)this).Tag, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProvidersUpdateTagsTypeConverter.ConvertFrom); } AfterDeserializePSObject(content); } @@ -135,6 +141,18 @@ internal ResourceProvidersUpdate(global::System.Management.Automation.PSObject c /// a containing this model serialized to JSON text. public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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(); + } } /// custom resource provider update information. [System.ComponentModel.TypeConverter(typeof(ResourceProvidersUpdateTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.TypeConverter.cs index 0cad3e487e58..d79b840f23db 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.cs similarity index 76% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.cs index b7fc5e107f5c..0b5ab4f3a261 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.cs @@ -3,22 +3,22 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// custom resource provider update information. public partial class ResourceProvidersUpdate : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateInternal { /// Backing field for property. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags _tag; + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags _tag; /// Resource tags [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Origin(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.PropertyOrigin.Owned)] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags Tag { get => (this._tag = this._tag ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProvidersUpdateTags()); set => this._tag = value; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags Tag { get => (this._tag = this._tag ?? new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProvidersUpdateTags()); set => this._tag = value; } /// Creates an new instance. public ResourceProvidersUpdate() @@ -34,10 +34,13 @@ public partial interface IResourceProvidersUpdate : [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( Required = false, ReadOnly = false, + Read = true, + Create = true, + Update = true, Description = @"Resource tags", SerializedName = @"tags", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags) })] - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags Tag { get; set; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags) })] + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags Tag { get; set; } } /// custom resource provider update information. @@ -45,7 +48,7 @@ internal partial interface IResourceProvidersUpdateInternal { /// Resource tags - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags Tag { get; set; } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags Tag { get; set; } } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.json.cs similarity index 94% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.json.cs index 7618c7118328..a1a6a6a54b79 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdate.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdate.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -54,13 +54,13 @@ public partial class ResourceProvidersUpdate partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject container, ref bool returnNow); /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new ResourceProvidersUpdate(json) : null; } @@ -77,7 +77,7 @@ internal ResourceProvidersUpdate(Microsoft.Azure.PowerShell.Cmdlets.CustomProvid { return; } - {_tag = If( json?.PropertyT("tags"), out var __jsonTags) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProvidersUpdateTags.FromJson(__jsonTags) : Tag;} + {_tag = If( json?.PropertyT("tags"), out var __jsonTags) ? Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProvidersUpdateTags.FromJson(__jsonTags) : _tag;} AfterFromJson(json); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.PowerShell.cs similarity index 80% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.PowerShell.cs index 67282081fd50..f576a616607b 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,29 +55,35 @@ public partial class ResourceProvidersUpdateTags partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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 . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ResourceProvidersUpdateTags(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ResourceProvidersUpdateTags(content); } @@ -87,10 +93,10 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -109,7 +115,7 @@ internal ResourceProvidersUpdateTags(global::System.Collections.IDictionary cont } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -131,6 +137,18 @@ internal ResourceProvidersUpdateTags(global::System.Management.Automation.PSObje /// a containing this model serialized to JSON text. public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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(); + } } /// Resource tags [System.ComponentModel.TypeConverter(typeof(ResourceProvidersUpdateTagsTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.TypeConverter.cs index 42950eacf921..525b2b77fd43 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.cs similarity index 90% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.cs index e84a5c7b9c21..f3264334b808 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// Resource tags public partial class ResourceProvidersUpdateTags : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTagsInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTagsInternal { /// Creates an new instance. diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.dictionary.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.dictionary.cs similarity index 96% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.dictionary.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.dictionary.cs index 754b755ecf14..54a073d36566 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.dictionary.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.dictionary.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -70,6 +70,6 @@ public void CopyFrom(global::System.Management.Automation.PSObject source) /// - public static implicit operator global::System.Collections.Generic.Dictionary(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProvidersUpdateTags source) => source.__additionalProperties; + public static implicit operator global::System.Collections.Generic.Dictionary(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProvidersUpdateTags source) => source.__additionalProperties; } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.json.cs similarity index 95% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.json.cs index d4a3be96a655..ddd48a5f0ade 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceProvidersUpdateTags.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceProvidersUpdateTags.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -54,13 +54,13 @@ public partial class ResourceProvidersUpdateTags partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject container, ref bool returnNow); /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new ResourceProvidersUpdateTags(json) : null; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.PowerShell.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.PowerShell.cs similarity index 81% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.PowerShell.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.PowerShell.cs index dd4a2d6a2164..f6f4e10cf14b 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.PowerShell.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.PowerShell.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -55,29 +55,35 @@ public partial class ResourceTags partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// - /// Deserializes a into an instance of 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 . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags DeserializeFromDictionary(global::System.Collections.IDictionary content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ResourceTags(content); } /// - /// Deserializes a into an instance of into an instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. /// - /// an instance of . + /// an instance of . /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags DeserializeFromPSObject(global::System.Management.Automation.PSObject content) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ResourceTags(content); } @@ -87,10 +93,10 @@ public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180 /// /// a string containing a JSON serialized instance of this model. /// an instance of the model class. - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode.Parse(jsonText)); /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Collections.IDictionary content that should be used. @@ -109,7 +115,7 @@ internal ResourceTags(global::System.Collections.IDictionary content) } /// - /// Deserializes a into a new instance of into a new instance of . /// /// The global::System.Management.Automation.PSObject content that should be used. @@ -131,6 +137,18 @@ internal ResourceTags(global::System.Management.Automation.PSObject content) /// a containing this model serialized to JSON text. public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.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(); + } } /// Resource tags [System.ComponentModel.TypeConverter(typeof(ResourceTagsTypeConverter))] diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.TypeConverter.cs similarity index 97% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.TypeConverter.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.TypeConverter.cs index 0dfd39193213..dd7db985df75 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.TypeConverter.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.TypeConverter.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; @@ -106,14 +106,14 @@ public static bool CanConvertFrom(dynamic sourceValue) /// /// an instance of , or null if there is no suitable conversion. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags ConvertFrom(dynamic sourceValue) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return null; } global::System.Type type = sourceValue.GetType(); - if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags).IsAssignableFrom(type)) + if (typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags).IsAssignableFrom(type)) { return sourceValue; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.cs similarity index 91% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.cs index e8360a8b3010..12b15eaab5f2 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.cs @@ -3,14 +3,14 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; /// Resource tags public partial class ResourceTags : - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTagsInternal + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTagsInternal { /// Creates an new instance. diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.dictionary.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.dictionary.cs similarity index 96% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.dictionary.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.dictionary.cs index d4c83e7d9af0..f19a636c1bb0 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.dictionary.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.dictionary.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -70,6 +70,6 @@ public void CopyFrom(global::System.Management.Automation.PSObject source) /// - public static implicit operator global::System.Collections.Generic.Dictionary(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTags source) => source.__additionalProperties; + public static implicit operator global::System.Collections.Generic.Dictionary(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceTags source) => source.__additionalProperties; } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.json.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.json.cs similarity index 96% rename from generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.json.cs rename to generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.json.cs index 42c7092c3674..f7001ec71e8b 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/Api20180901Preview/ResourceTags.json.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Models/ResourceTags.json.cs @@ -3,7 +3,7 @@ // 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.CustomProviders.Models.Api20180901Preview +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; @@ -54,13 +54,13 @@ public partial class ResourceTags partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject container, ref bool returnNow); /// - /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags. + /// Deserializes a into an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags. /// /// a to deserialize from. /// - /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags. + /// an instance of Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags. /// - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) + public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags FromJson(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Json.JsonObject json ? new ResourceTags(json) : null; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ActionRouting.Completer.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ActionRouting.Completer.cs deleted file mode 100644 index 65c7f38b212d..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ActionRouting.Completer.cs +++ /dev/null @@ -1,35 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The routing types that are supported for action requests. - [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRoutingTypeConverter))] - public partial struct ActionRouting : - System.Management.Automation.IArgumentCompleter - { - - /// - /// Implementations of this function are called by PowerShell to complete arguments. - /// - /// The name of the command that needs argument completion. - /// The name of the parameter that needs argument completion. - /// The (possibly empty) word being completed. - /// The command ast in case it is needed for completion. - /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot - /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. - /// - /// A collection of completion results, most like with ResultType set to ParameterValue. - /// - public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) - { - if (global::System.String.IsNullOrEmpty(wordToComplete) || "Proxy".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) - { - yield return new global::System.Management.Automation.CompletionResult("'Proxy'", "Proxy", global::System.Management.Automation.CompletionResultType.ParameterValue, "Proxy"); - } - } - } -} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ActionRouting.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ActionRouting.TypeConverter.cs deleted file mode 100644 index a6aa4adc61a2..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ActionRouting.TypeConverter.cs +++ /dev/null @@ -1,59 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The routing types that are supported for action requests. - public partial class ActionRoutingTypeConverter : - 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) => true; - - /// - /// 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 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) => ActionRouting.CreateFrom(sourceValue); - - /// 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/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ActionRouting.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ActionRouting.cs deleted file mode 100644 index a71b3b02e212..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ActionRouting.cs +++ /dev/null @@ -1,96 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The routing types that are supported for action requests. - public partial struct ActionRouting : - System.IEquatable - { - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting Proxy = @"Proxy"; - - /// the value for an instance of the Enum. - private string _value { get; set; } - - /// Creates an instance of the Enum class. - /// the value to create an instance for. - private ActionRouting(string underlyingValue) - { - this._value = underlyingValue; - } - - /// Conversion from arbitrary object to ActionRouting - /// the value to convert to an instance of . - internal static object CreateFrom(object value) - { - return new ActionRouting(global::System.Convert.ToString(value)); - } - - /// Compares values of enum type ActionRouting - /// the value to compare against this instance. - /// true if the two instances are equal to the same value - public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting e) - { - return _value.Equals(e._value); - } - - /// Compares values of enum type ActionRouting (override for Object) - /// the value to compare against this instance. - /// true if the two instances are equal to the same value - public override bool Equals(object obj) - { - return obj is ActionRouting && Equals((ActionRouting)obj); - } - - /// Returns hashCode for enum ActionRouting - /// The hashCode of the value - public override int GetHashCode() - { - return this._value.GetHashCode(); - } - - /// Returns string representation for ActionRouting - /// A string for this value. - public override string ToString() - { - return this._value; - } - - /// Implicit operator to convert string to ActionRouting - /// the value to convert to an instance of . - - public static implicit operator ActionRouting(string value) - { - return new ActionRouting(value); - } - - /// Implicit operator to convert ActionRouting to string - /// the value to convert to an instance of . - - public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting e) - { - return e._value; - } - - /// Overriding != operator for enum ActionRouting - /// the value to compare against - /// the value to compare against - /// true if the two instances are not equal to the same value - public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting e1, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting e2) - { - return !e2.Equals(e1); - } - - /// Overriding == operator for enum ActionRouting - /// the value to compare against - /// the value to compare against - /// true if the two instances are equal to the same value - public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting e1, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ActionRouting e2) - { - return e2.Equals(e1); - } - } -} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ProvisioningState.Completer.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ProvisioningState.Completer.cs deleted file mode 100644 index 579899e2db31..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ProvisioningState.Completer.cs +++ /dev/null @@ -1,51 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The provisioning state of the resource provider. - [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningStateTypeConverter))] - public partial struct ProvisioningState : - System.Management.Automation.IArgumentCompleter - { - - /// - /// Implementations of this function are called by PowerShell to complete arguments. - /// - /// The name of the command that needs argument completion. - /// The name of the parameter that needs argument completion. - /// The (possibly empty) word being completed. - /// The command ast in case it is needed for completion. - /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot - /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. - /// - /// A collection of completion results, most like with ResultType set to ParameterValue. - /// - public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) - { - if (global::System.String.IsNullOrEmpty(wordToComplete) || "Accepted".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) - { - yield return new global::System.Management.Automation.CompletionResult("'Accepted'", "Accepted", global::System.Management.Automation.CompletionResultType.ParameterValue, "Accepted"); - } - if (global::System.String.IsNullOrEmpty(wordToComplete) || "Deleting".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) - { - yield return new global::System.Management.Automation.CompletionResult("'Deleting'", "Deleting", global::System.Management.Automation.CompletionResultType.ParameterValue, "Deleting"); - } - if (global::System.String.IsNullOrEmpty(wordToComplete) || "Running".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) - { - yield return new global::System.Management.Automation.CompletionResult("'Running'", "Running", global::System.Management.Automation.CompletionResultType.ParameterValue, "Running"); - } - if (global::System.String.IsNullOrEmpty(wordToComplete) || "Succeeded".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) - { - yield return new global::System.Management.Automation.CompletionResult("'Succeeded'", "Succeeded", global::System.Management.Automation.CompletionResultType.ParameterValue, "Succeeded"); - } - if (global::System.String.IsNullOrEmpty(wordToComplete) || "Failed".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) - { - yield return new global::System.Management.Automation.CompletionResult("'Failed'", "Failed", global::System.Management.Automation.CompletionResultType.ParameterValue, "Failed"); - } - } - } -} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ProvisioningState.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ProvisioningState.TypeConverter.cs deleted file mode 100644 index d918568cc077..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ProvisioningState.TypeConverter.cs +++ /dev/null @@ -1,59 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The provisioning state of the resource provider. - public partial class ProvisioningStateTypeConverter : - 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) => true; - - /// - /// 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 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) => ProvisioningState.CreateFrom(sourceValue); - - /// 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/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ProvisioningState.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ProvisioningState.cs deleted file mode 100644 index b11d98431173..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ProvisioningState.cs +++ /dev/null @@ -1,104 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The provisioning state of the resource provider. - public partial struct ProvisioningState : - System.IEquatable - { - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState Accepted = @"Accepted"; - - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState Deleting = @"Deleting"; - - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState Failed = @"Failed"; - - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState Running = @"Running"; - - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState Succeeded = @"Succeeded"; - - /// the value for an instance of the Enum. - private string _value { get; set; } - - /// Conversion from arbitrary object to ProvisioningState - /// the value to convert to an instance of . - internal static object CreateFrom(object value) - { - return new ProvisioningState(global::System.Convert.ToString(value)); - } - - /// Compares values of enum type ProvisioningState - /// the value to compare against this instance. - /// true if the two instances are equal to the same value - public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState e) - { - return _value.Equals(e._value); - } - - /// Compares values of enum type ProvisioningState (override for Object) - /// the value to compare against this instance. - /// true if the two instances are equal to the same value - public override bool Equals(object obj) - { - return obj is ProvisioningState && Equals((ProvisioningState)obj); - } - - /// Returns hashCode for enum ProvisioningState - /// The hashCode of the value - public override int GetHashCode() - { - return this._value.GetHashCode(); - } - - /// Creates an instance of the Enum class. - /// the value to create an instance for. - private ProvisioningState(string underlyingValue) - { - this._value = underlyingValue; - } - - /// Returns string representation for ProvisioningState - /// A string for this value. - public override string ToString() - { - return this._value; - } - - /// Implicit operator to convert string to ProvisioningState - /// the value to convert to an instance of . - - public static implicit operator ProvisioningState(string value) - { - return new ProvisioningState(value); - } - - /// Implicit operator to convert ProvisioningState to string - /// the value to convert to an instance of . - - public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState e) - { - return e._value; - } - - /// Overriding != operator for enum ProvisioningState - /// the value to compare against - /// the value to compare against - /// true if the two instances are not equal to the same value - public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState e1, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState e2) - { - return !e2.Equals(e1); - } - - /// Overriding == operator for enum ProvisioningState - /// the value to compare against - /// the value to compare against - /// true if the two instances are equal to the same value - public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState e1, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ProvisioningState e2) - { - return e2.Equals(e1); - } - } -} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ResourceTypeRouting.Completer.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ResourceTypeRouting.Completer.cs deleted file mode 100644 index dbff4e9f9de3..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ResourceTypeRouting.Completer.cs +++ /dev/null @@ -1,39 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The routing types that are supported for resource requests. - [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRoutingTypeConverter))] - public partial struct ResourceTypeRouting : - System.Management.Automation.IArgumentCompleter - { - - /// - /// Implementations of this function are called by PowerShell to complete arguments. - /// - /// The name of the command that needs argument completion. - /// The name of the parameter that needs argument completion. - /// The (possibly empty) word being completed. - /// The command ast in case it is needed for completion. - /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot - /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. - /// - /// A collection of completion results, most like with ResultType set to ParameterValue. - /// - public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) - { - if (global::System.String.IsNullOrEmpty(wordToComplete) || "Proxy".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) - { - yield return new global::System.Management.Automation.CompletionResult("'Proxy'", "Proxy", global::System.Management.Automation.CompletionResultType.ParameterValue, "Proxy"); - } - if (global::System.String.IsNullOrEmpty(wordToComplete) || "Proxy,Cache".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) - { - yield return new global::System.Management.Automation.CompletionResult("'Proxy,Cache'", "Proxy,Cache", global::System.Management.Automation.CompletionResultType.ParameterValue, "Proxy,Cache"); - } - } - } -} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ResourceTypeRouting.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ResourceTypeRouting.TypeConverter.cs deleted file mode 100644 index 85b97de91704..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ResourceTypeRouting.TypeConverter.cs +++ /dev/null @@ -1,59 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The routing types that are supported for resource requests. - public partial class ResourceTypeRoutingTypeConverter : - 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) => true; - - /// - /// 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 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) => ResourceTypeRouting.CreateFrom(sourceValue); - - /// 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/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ResourceTypeRouting.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ResourceTypeRouting.cs deleted file mode 100644 index 6e0d05f38ead..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ResourceTypeRouting.cs +++ /dev/null @@ -1,98 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The routing types that are supported for resource requests. - public partial struct ResourceTypeRouting : - System.IEquatable - { - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting Proxy = @"Proxy"; - - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting ProxyCache = @"Proxy,Cache"; - - /// the value for an instance of the Enum. - private string _value { get; set; } - - /// Conversion from arbitrary object to ResourceTypeRouting - /// the value to convert to an instance of . - internal static object CreateFrom(object value) - { - return new ResourceTypeRouting(global::System.Convert.ToString(value)); - } - - /// Compares values of enum type ResourceTypeRouting - /// the value to compare against this instance. - /// true if the two instances are equal to the same value - public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting e) - { - return _value.Equals(e._value); - } - - /// Compares values of enum type ResourceTypeRouting (override for Object) - /// the value to compare against this instance. - /// true if the two instances are equal to the same value - public override bool Equals(object obj) - { - return obj is ResourceTypeRouting && Equals((ResourceTypeRouting)obj); - } - - /// Returns hashCode for enum ResourceTypeRouting - /// The hashCode of the value - public override int GetHashCode() - { - return this._value.GetHashCode(); - } - - /// Creates an instance of the Enum class. - /// the value to create an instance for. - private ResourceTypeRouting(string underlyingValue) - { - this._value = underlyingValue; - } - - /// Returns string representation for ResourceTypeRouting - /// A string for this value. - public override string ToString() - { - return this._value; - } - - /// Implicit operator to convert string to ResourceTypeRouting - /// the value to convert to an instance of . - - public static implicit operator ResourceTypeRouting(string value) - { - return new ResourceTypeRouting(value); - } - - /// Implicit operator to convert ResourceTypeRouting to string - /// the value to convert to an instance of . - - public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting e) - { - return e._value; - } - - /// Overriding != operator for enum ResourceTypeRouting - /// the value to compare against - /// the value to compare against - /// true if the two instances are not equal to the same value - public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting e1, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting e2) - { - return !e2.Equals(e1); - } - - /// Overriding == operator for enum ResourceTypeRouting - /// the value to compare against - /// the value to compare against - /// true if the two instances are equal to the same value - public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting e1, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ResourceTypeRouting e2) - { - return e2.Equals(e1); - } - } -} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ValidationType.Completer.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ValidationType.Completer.cs deleted file mode 100644 index 04a83d2d4a6a..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ValidationType.Completer.cs +++ /dev/null @@ -1,35 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The type of validation to run against a matching request. - [System.ComponentModel.TypeConverter(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationTypeTypeConverter))] - public partial struct ValidationType : - System.Management.Automation.IArgumentCompleter - { - - /// - /// Implementations of this function are called by PowerShell to complete arguments. - /// - /// The name of the command that needs argument completion. - /// The name of the parameter that needs argument completion. - /// The (possibly empty) word being completed. - /// The command ast in case it is needed for completion. - /// This parameter is similar to $PSBoundParameters, except that sometimes PowerShell cannot - /// or will not attempt to evaluate an argument, in which case you may need to use commandAst. - /// - /// A collection of completion results, most like with ResultType set to ParameterValue. - /// - public global::System.Collections.Generic.IEnumerable CompleteArgument(global::System.String commandName, global::System.String parameterName, global::System.String wordToComplete, global::System.Management.Automation.Language.CommandAst commandAst, global::System.Collections.IDictionary fakeBoundParameters) - { - if (global::System.String.IsNullOrEmpty(wordToComplete) || "Swagger".StartsWith(wordToComplete, global::System.StringComparison.InvariantCultureIgnoreCase)) - { - yield return new global::System.Management.Automation.CompletionResult("'Swagger'", "Swagger", global::System.Management.Automation.CompletionResultType.ParameterValue, "Swagger"); - } - } - } -} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ValidationType.TypeConverter.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ValidationType.TypeConverter.cs deleted file mode 100644 index 9de1f166349d..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ValidationType.TypeConverter.cs +++ /dev/null @@ -1,59 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The type of validation to run against a matching request. - public partial class ValidationTypeTypeConverter : - 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) => true; - - /// - /// 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 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) => ValidationType.CreateFrom(sourceValue); - - /// 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/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ValidationType.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ValidationType.cs deleted file mode 100644 index 166d0f1b7a89..000000000000 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/api/Support/ValidationType.cs +++ /dev/null @@ -1,96 +0,0 @@ -// 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.CustomProviders.Support -{ - - /// The type of validation to run against a matching request. - public partial struct ValidationType : - System.IEquatable - { - public static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType Swagger = @"Swagger"; - - /// the value for an instance of the Enum. - private string _value { get; set; } - - /// Conversion from arbitrary object to ValidationType - /// the value to convert to an instance of . - internal static object CreateFrom(object value) - { - return new ValidationType(global::System.Convert.ToString(value)); - } - - /// Compares values of enum type ValidationType - /// the value to compare against this instance. - /// true if the two instances are equal to the same value - public bool Equals(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType e) - { - return _value.Equals(e._value); - } - - /// Compares values of enum type ValidationType (override for Object) - /// the value to compare against this instance. - /// true if the two instances are equal to the same value - public override bool Equals(object obj) - { - return obj is ValidationType && Equals((ValidationType)obj); - } - - /// Returns hashCode for enum ValidationType - /// The hashCode of the value - public override int GetHashCode() - { - return this._value.GetHashCode(); - } - - /// Returns string representation for ValidationType - /// A string for this value. - public override string ToString() - { - return this._value; - } - - /// Creates an instance of the Enum class. - /// the value to create an instance for. - private ValidationType(string underlyingValue) - { - this._value = underlyingValue; - } - - /// Implicit operator to convert string to ValidationType - /// the value to convert to an instance of . - - public static implicit operator ValidationType(string value) - { - return new ValidationType(value); - } - - /// Implicit operator to convert ValidationType to string - /// the value to convert to an instance of . - - public static implicit operator string(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType e) - { - return e._value; - } - - /// Overriding != operator for enum ValidationType - /// the value to compare against - /// the value to compare against - /// true if the two instances are not equal to the same value - public static bool operator !=(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType e1, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType e2) - { - return !e2.Equals(e1); - } - - /// Overriding == operator for enum ValidationType - /// the value to compare against - /// the value to compare against - /// true if the two instances are equal to the same value - public static bool operator ==(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType e1, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support.ValidationType e2) - { - return e2.Equals(e1); - } - } -} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_Get.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_Get.cs index 784591728905..97ce0c4e5330 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_Get.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_Get.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Get an association. @@ -13,12 +15,13 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets /// [OpenAPI] Get=>GET:"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCustomProviderAssociation_Get")] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation))] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation))] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Get an association.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}", ApiVersion = "2018-09-01-preview")] public partial class GetAzCustomProviderAssociation_Get : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,11 +37,26 @@ public partial class GetAzCustomProviderAssociation_Get : global::System.Managem /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -52,6 +70,9 @@ public partial class GetAzCustomProviderAssociation_Get : global::System.Managem [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -93,7 +114,7 @@ public partial class GetAzCustomProviderAssociation_Get : global::System.Managem /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -130,24 +151,24 @@ public partial class GetAzCustomProviderAssociation_Get : global::System.Managem /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -170,6 +191,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -191,7 +217,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public GetAzCustomProviderAssociation_Get() { @@ -242,8 +268,33 @@ public GetAzCustomProviderAssociation_Get() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -296,7 +347,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -314,7 +365,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -352,12 +403,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -374,15 +425,15 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); @@ -392,12 +443,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -409,8 +460,26 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json - // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation - WriteObject((await response)); + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } } } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_GetViaIdentity.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_GetViaIdentity.cs index 26915312b61d..f6335ce8821e 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_GetViaIdentity.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_GetViaIdentity.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Get an association. @@ -13,12 +15,13 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets /// [OpenAPI] Get=>GET:"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCustomProviderAssociation_GetViaIdentity")] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation))] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation))] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Get an association.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}", ApiVersion = "2018-09-01-preview")] public partial class GetAzCustomProviderAssociation_GetViaIdentity : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,11 +37,26 @@ public partial class GetAzCustomProviderAssociation_GetViaIdentity : global::Sys /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -52,6 +70,9 @@ public partial class GetAzCustomProviderAssociation_GetViaIdentity : global::Sys [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -86,7 +107,7 @@ public partial class GetAzCustomProviderAssociation_GetViaIdentity : global::Sys /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -109,24 +130,24 @@ public partial class GetAzCustomProviderAssociation_GetViaIdentity : global::Sys /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -149,6 +170,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -170,7 +196,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public GetAzCustomProviderAssociation_GetViaIdentity() { @@ -221,8 +247,33 @@ public GetAzCustomProviderAssociation_GetViaIdentity() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -275,7 +326,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -309,7 +360,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -347,12 +398,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -369,7 +420,7 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } @@ -387,12 +438,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -404,8 +455,26 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json - // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation - WriteObject((await response)); + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } } } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_List.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_List.cs index 252fe25ee14c..a52b6960928a 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_List.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProviderAssociation_List.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Gets all association for the given scope. @@ -13,12 +15,13 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets /// [OpenAPI] ListAll=>GET:"/{scope}/providers/Microsoft.CustomProviders/associations" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCustomProviderAssociation_List")] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation))] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation))] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Gets all association for the given scope.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/{scope}/providers/Microsoft.CustomProviders/associations", ApiVersion = "2018-09-01-preview")] public partial class GetAzCustomProviderAssociation_List : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,17 +37,32 @@ public partial class GetAzCustomProviderAssociation_List : global::System.Manage /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + /// A flag to tell whether it is the first onOK call. private bool _isFirst = true; /// Link to retrieve next page. private string _nextLink; + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -58,6 +76,9 @@ public partial class GetAzCustomProviderAssociation_List : global::System.Manage [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -84,7 +105,7 @@ public partial class GetAzCustomProviderAssociation_List : global::System.Manage /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -121,24 +142,24 @@ public partial class GetAzCustomProviderAssociation_List : global::System.Manage /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -161,6 +182,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -182,7 +208,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public GetAzCustomProviderAssociation_List() { @@ -233,8 +259,33 @@ public GetAzCustomProviderAssociation_List() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -287,7 +338,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -305,7 +356,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -343,12 +394,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -365,15 +416,15 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); @@ -383,12 +434,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociationsList + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -400,15 +451,38 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociationsList + var result = (await response); // response should be returning an array of some kind. +Pageable // pageable / value / nextLink - var result = await response; - WriteObject(result.Value,true); + if (null != result.Value) + { + if (0 == _responseSize && 1 == result.Value.Count) + { + _firstResponse = result.Value[0]; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + var values = new System.Collections.Generic.List(); + foreach( var value in result.Value ) + { + values.Add(value.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(values, true); + _responseSize = 2; + } + } _nextLink = result.NextLink; if (_isFirst) { _isFirst = false; - while (_nextLink != null) + while (!String.IsNullOrEmpty(_nextLink)) { if (responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ) { diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_Get.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_Get.cs index 90754e0aef0d..78b8235b9232 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_Get.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_Get.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Gets the custom resource provider manifest. @@ -13,12 +15,13 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets /// [OpenAPI] Get=>GET:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCustomProvider_Get")] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest))] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Gets the custom resource provider manifest.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] public partial class GetAzCustomProvider_Get : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,11 +37,26 @@ public partial class GetAzCustomProvider_Get : global::System.Management.Automat /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -52,6 +70,9 @@ public partial class GetAzCustomProvider_Get : global::System.Management.Automat [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -93,7 +114,7 @@ public partial class GetAzCustomProvider_Get : global::System.Management.Automat /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -141,7 +162,8 @@ public partial class GetAzCustomProvider_Get : global::System.Management.Automat [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( Name = @"", Description =@"", - Script = @"(Get-AzContext).Subscription.Id")] + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] public string[] SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } @@ -150,24 +172,24 @@ public partial class GetAzCustomProvider_Get : global::System.Management.Automat /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -190,6 +212,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -211,7 +238,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public GetAzCustomProvider_Get() { @@ -262,8 +289,33 @@ public GetAzCustomProvider_Get() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -316,7 +368,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -337,7 +389,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -375,12 +427,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -397,15 +449,15 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); @@ -415,12 +467,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -432,8 +484,26 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json - // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest - WriteObject((await response)); + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } } } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_GetViaIdentity.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_GetViaIdentity.cs index 01d089f4b906..1fb07c26fd9d 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_GetViaIdentity.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_GetViaIdentity.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Gets the custom resource provider manifest. @@ -13,12 +15,13 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets /// [OpenAPI] Get=>GET:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCustomProvider_GetViaIdentity")] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest))] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Gets the custom resource provider manifest.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] public partial class GetAzCustomProvider_GetViaIdentity : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,11 +37,26 @@ public partial class GetAzCustomProvider_GetViaIdentity : global::System.Managem /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -52,6 +70,9 @@ public partial class GetAzCustomProvider_GetViaIdentity : global::System.Managem [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -86,7 +107,7 @@ public partial class GetAzCustomProvider_GetViaIdentity : global::System.Managem /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -109,24 +130,24 @@ public partial class GetAzCustomProvider_GetViaIdentity : global::System.Managem /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -149,6 +170,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -170,7 +196,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public GetAzCustomProvider_GetViaIdentity() { @@ -221,8 +247,33 @@ public GetAzCustomProvider_GetViaIdentity() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -275,7 +326,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -313,7 +364,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -351,12 +402,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -373,7 +424,7 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } @@ -391,12 +442,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -408,8 +459,26 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json - // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest - WriteObject((await response)); + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } } } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_List.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_List.cs index 0dff17078124..9dd75679b102 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_List.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_List.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Gets all the custom resource providers within a resource group. @@ -13,12 +15,13 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets /// [OpenAPI] ListByResourceGroup=>GET:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCustomProvider_List")] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest))] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Gets all the custom resource providers within a resource group.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders", ApiVersion = "2018-09-01-preview")] public partial class GetAzCustomProvider_List : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,17 +37,32 @@ public partial class GetAzCustomProvider_List : global::System.Management.Automa /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + /// A flag to tell whether it is the first onOK call. private bool _isFirst = true; /// Link to retrieve next page. private string _nextLink; + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -58,6 +76,9 @@ public partial class GetAzCustomProvider_List : global::System.Management.Automa [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -84,7 +105,7 @@ public partial class GetAzCustomProvider_List : global::System.Management.Automa /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -132,7 +153,8 @@ public partial class GetAzCustomProvider_List : global::System.Management.Automa [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( Name = @"", Description =@"", - Script = @"(Get-AzContext).Subscription.Id")] + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] public string[] SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } @@ -141,24 +163,24 @@ public partial class GetAzCustomProvider_List : global::System.Management.Automa /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -181,6 +203,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -202,7 +229,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public GetAzCustomProvider_List() { @@ -253,8 +280,33 @@ public GetAzCustomProvider_List() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -307,7 +359,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -328,7 +380,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -366,12 +418,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -388,15 +440,15 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); @@ -406,12 +458,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -423,15 +475,38 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest + var result = (await response); // response should be returning an array of some kind. +Pageable // pageable / value / nextLink - var result = await response; - WriteObject(result.Value,true); + if (null != result.Value) + { + if (0 == _responseSize && 1 == result.Value.Count) + { + _firstResponse = result.Value[0]; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + var values = new System.Collections.Generic.List(); + foreach( var value in result.Value ) + { + values.Add(value.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(values, true); + _responseSize = 2; + } + } _nextLink = result.NextLink; if (_isFirst) { _isFirst = false; - while (_nextLink != null) + while (!String.IsNullOrEmpty(_nextLink)) { if (responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ) { diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_List1.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_List1.cs index babb5558f619..f1035cfa9bca 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_List1.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzCustomProvider_List1.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Gets all the custom resource providers within a subscription. @@ -13,12 +15,13 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets /// [OpenAPI] ListBySubscription=>GET:"/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzCustomProvider_List1")] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest))] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Gets all the custom resource providers within a subscription.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders", ApiVersion = "2018-09-01-preview")] public partial class GetAzCustomProvider_List1 : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,17 +37,32 @@ public partial class GetAzCustomProvider_List1 : global::System.Management.Autom /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + /// A flag to tell whether it is the first onOK call. private bool _isFirst = true; /// Link to retrieve next page. private string _nextLink; + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -58,6 +76,9 @@ public partial class GetAzCustomProvider_List1 : global::System.Management.Autom [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -84,7 +105,7 @@ public partial class GetAzCustomProvider_List1 : global::System.Management.Autom /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -118,7 +139,8 @@ public partial class GetAzCustomProvider_List1 : global::System.Management.Autom [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( Name = @"", Description =@"", - Script = @"(Get-AzContext).Subscription.Id")] + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] public string[] SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } @@ -127,24 +149,24 @@ public partial class GetAzCustomProvider_List1 : global::System.Management.Autom /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -167,6 +189,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -188,7 +215,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public GetAzCustomProvider_List1() { @@ -239,8 +266,33 @@ public GetAzCustomProvider_List1() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -293,7 +345,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -314,7 +366,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -352,12 +404,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -374,15 +426,15 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); @@ -392,12 +444,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IListByCustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -409,15 +461,38 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IListByCustomRpManifest + var result = (await response); // response should be returning an array of some kind. +Pageable // pageable / value / nextLink - var result = await response; - WriteObject(result.Value,true); + if (null != result.Value) + { + if (0 == _responseSize && 1 == result.Value.Count) + { + _firstResponse = result.Value[0]; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + var values = new System.Collections.Generic.List(); + foreach( var value in result.Value ) + { + values.Add(value.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(values, true); + _responseSize = 2; + } + } _nextLink = result.NextLink; if (_isFirst) { _isFirst = false; - while (_nextLink != null) + while (!String.IsNullOrEmpty(_nextLink)) { if (responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ) { diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzOperation_List.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzOperation_List.cs index 48354269662b..722fe6d5cc04 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzOperation_List.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/GetAzOperation_List.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// The list of operations provided by Microsoft CustomProviders. @@ -14,12 +16,13 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets /// [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.InternalExport] [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.Get, @"AzOperation_List")] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation))] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation))] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"The list of operations provided by Microsoft CustomProviders.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/providers/Microsoft.CustomProviders/operations", ApiVersion = "2018-09-01-preview")] public partial class GetAzOperation_List : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -35,17 +38,32 @@ public partial class GetAzOperation_List : global::System.Management.Automation. /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + /// A flag to tell whether it is the first onOK call. private bool _isFirst = true; /// Link to retrieve next page. private string _nextLink; + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -59,6 +77,9 @@ public partial class GetAzOperation_List : global::System.Management.Automation. [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -85,7 +106,7 @@ public partial class GetAzOperation_List : global::System.Management.Automation. /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -108,24 +129,24 @@ public partial class GetAzOperation_List : global::System.Management.Automation. /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -148,6 +169,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -169,7 +195,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public GetAzOperation_List() { @@ -220,8 +246,33 @@ public GetAzOperation_List() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -274,7 +325,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -292,7 +343,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -330,12 +381,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -352,7 +403,7 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } @@ -370,12 +421,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperationList + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -387,15 +438,38 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperationList + var result = (await response); // response should be returning an array of some kind. +Pageable // pageable / value / nextLink - var result = await response; - WriteObject(result.Value,true); + if (null != result.Value) + { + if (0 == _responseSize && 1 == result.Value.Count) + { + _firstResponse = result.Value[0]; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + var values = new System.Collections.Generic.List(); + foreach( var value in result.Value ) + { + values.Add(value.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(values, true); + _responseSize = 2; + } + } _nextLink = result.NextLink; if (_isFirst) { _isFirst = false; - while (_nextLink != null) + while (!String.IsNullOrEmpty(_nextLink)) { if (responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ) { diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateExpanded.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateExpanded.cs index 79ed5575d568..1bde44ab7c98 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateExpanded.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateExpanded.cs @@ -6,19 +6,22 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; - /// Create or update an association. + /// create an association. /// /// [OpenAPI] CreateOrUpdate=>PUT:"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.New, @"AzCustomProviderAssociation_CreateExpanded", SupportsShouldProcess = true)] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation))] - [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Create or update an association.")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"create an association.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}", ApiVersion = "2018-09-01-preview")] public partial class NewAzCustomProviderAssociation_CreateExpanded : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -30,13 +33,25 @@ public partial class NewAzCustomProviderAssociation_CreateExpanded : global::Sys private string __processRecordId; /// The resource definition of this association. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation _associationBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.Association(); + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation _associationBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association(); /// /// The for this operation. /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// when specified, runs this cmdlet as a PowerShell job [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] @@ -47,6 +62,9 @@ public partial class NewAzCustomProviderAssociation_CreateExpanded : global::Sys [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -60,6 +78,9 @@ public partial class NewAzCustomProviderAssociation_CreateExpanded : global::Sys [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -109,7 +130,7 @@ public partial class NewAzCustomProviderAssociation_CreateExpanded : global::Sys /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -160,24 +181,24 @@ public partial class NewAzCustomProviderAssociation_CreateExpanded : global::Sys /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -223,6 +244,11 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.NewAzCustomPro /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -287,11 +313,36 @@ protected override void EndProcessing() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: { + var data = messageData(); if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) { - var data = messageData(); if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) { var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); @@ -303,10 +354,26 @@ protected override void EndProcessing() return; } } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } break; } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -316,7 +383,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public NewAzCustomProviderAssociation_CreateExpanded() { @@ -382,7 +449,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -395,12 +462,12 @@ protected override void ProcessRecord() try { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - await this.Client.AssociationsCreateOrUpdate(Scope, Name, _associationBody, onOk, onDefault, this, Pipeline); + await this.Client.AssociationsCreateOrUpdate(Scope, Name, _associationBody, onOk, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate); await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name,body=_associationBody}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -438,12 +505,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -460,15 +527,15 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name, body=_associationBody }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name, body=_associationBody }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); @@ -478,12 +545,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -495,8 +562,26 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json - // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IAssociation - WriteObject((await response)); + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } } } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateViaJsonFilePath.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateViaJsonFilePath.cs new file mode 100644 index 000000000000..c53417ae04d2 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateViaJsonFilePath.cs @@ -0,0 +1,590 @@ +// 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.CustomProviders.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; + using System; + + /// create an association. + /// + /// [OpenAPI] CreateOrUpdate=>PUT:"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.New, @"AzCustomProviderAssociation_CreateViaJsonFilePath", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"create an association.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}", ApiVersion = "2018-09-01-preview")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.NotSuggestDefaultParameterSet] + public partial class NewAzCustomProviderAssociation_CreateViaJsonFilePath : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + public global::System.String _jsonString; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + + /// when specified, runs this cmdlet as a PowerShell job + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter AsJob { get; set; } + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; + + /// + /// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet + /// against a different subscription + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// Backing field for property. + private string _jsonFilePath; + + /// Path of Json file supplied to the Create operation + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Path of Json file supplied to the Create operation")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Path of Json file supplied to the Create operation", + SerializedName = @"JsonFilePath", + PossibleTypes = new [] { typeof(string) })] + public string JsonFilePath { get => this._jsonFilePath; set { if (!System.IO.File.Exists(value)) { throw new Exception("Cannot find File " + value); } this._jsonString = System.IO.File.ReadAllText(value); this._jsonFilePath = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// The name of the association. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the association.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the association.", + SerializedName = @"associationName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("AssociationName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// when specified, will make the remote call, and return an AsyncOperationResponse, letting the remote operation continue + /// asynchronously. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command asynchronously")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter NoWait { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _scope; + + /// + /// The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' + /// for a virtual machine resource. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + /// from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + var telemetryId = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryId.Invoke(); + if (telemetryId != "" && telemetryId != "internal") + { + __correlationId = telemetryId; + } + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Creates a duplicate instance of this cmdlet (via JSON serialization). + /// a duplicate instance of NewAzCustomProviderAssociation_CreateViaJsonFilePath + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.NewAzCustomProviderAssociation_CreateViaJsonFilePath Clone() + { + var clone = new NewAzCustomProviderAssociation_CreateViaJsonFilePath(); + clone.__correlationId = this.__correlationId; + clone.__processRecordId = this.__processRecordId; + clone.DefaultProfile = this.DefaultProfile; + clone.InvocationInformation = this.InvocationInformation; + clone.Proxy = this.Proxy; + clone.Pipeline = this.Pipeline; + clone.AsJob = this.AsJob; + clone.Break = this.Break; + clone.ProxyCredential = this.ProxyCredential; + clone.ProxyUseDefaultCredentials = this.ProxyUseDefaultCredentials; + clone.HttpPipelinePrepend = this.HttpPipelinePrepend; + clone.HttpPipelineAppend = this.HttpPipelineAppend; + clone.Scope = this.Scope; + clone.Name = this.Name; + clone.JsonFilePath = this.JsonFilePath; + return clone; + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } + var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); + if (telemetryInfo != null) + { + telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning); + telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties); + telemetryInfo.TryGetValue("InvocationName", out var invocationName); + if (showSecretsWarning == "true") + { + if (string.IsNullOrEmpty(sanitizedProperties)) + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + else + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + } + } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Information: + { + // When an operation supports asjob, Information messages must go thru verbose. + WriteVerbose($"INFORMATION: {(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: + { + var data = messageData(); + if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = response.GetFirstHeader(@"Location"); + var uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? response.RequestMessage.RequestUri.AbsoluteUri : location : asyncOperation; + WriteObject(new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncOperationResponse { Target = uri }); + // do nothing more. + data.Cancel(); + return; + } + } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } + break; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// + /// Initializes a new instance of the cmdlet class. + /// + public NewAzCustomProviderAssociation_CreateViaJsonFilePath() + { + + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'AssociationsCreateOrUpdate' operation")) + { + if (true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")) + { + var instance = this.Clone(); + var job = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncJob(instance, this.MyInvocation.Line, this.MyInvocation.MyCommand.Name, this._cancellationTokenSource.Token, this._cancellationTokenSource.Cancel); + JobRepository.Add(job); + var task = instance.ProcessRecordAsync(); + job.Monitor(task); + WriteObject(job); + } + else + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token); + } + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.AssociationsCreateOrUpdateViaJsonString(Scope, Name, _jsonString, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + new protected void WriteObject(object sendToPipeline) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline); + } + + /// + /// + new protected void WriteObject(object sendToPipeline, bool enumerateCollection) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline, enumerateCollection); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } + } + } + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateViaJsonString.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateViaJsonString.cs new file mode 100644 index 000000000000..8d2886f0ef30 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProviderAssociation_CreateViaJsonString.cs @@ -0,0 +1,588 @@ +// 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.CustomProviders.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; + using System; + + /// create an association. + /// + /// [OpenAPI] CreateOrUpdate=>PUT:"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.New, @"AzCustomProviderAssociation_CreateViaJsonString", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"create an association.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}", ApiVersion = "2018-09-01-preview")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.NotSuggestDefaultParameterSet] + public partial class NewAzCustomProviderAssociation_CreateViaJsonString : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + + /// when specified, runs this cmdlet as a PowerShell job + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter AsJob { get; set; } + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; + + /// + /// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet + /// against a different subscription + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// Backing field for property. + private string _jsonString; + + /// Json string supplied to the Create operation + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Json string supplied to the Create operation")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Json string supplied to the Create operation", + SerializedName = @"JsonString", + PossibleTypes = new [] { typeof(string) })] + public string JsonString { get => this._jsonString; set => this._jsonString = value; } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// The name of the association. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the association.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the association.", + SerializedName = @"associationName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("AssociationName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// when specified, will make the remote call, and return an AsyncOperationResponse, letting the remote operation continue + /// asynchronously. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command asynchronously")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter NoWait { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _scope; + + /// + /// The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' + /// for a virtual machine resource. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + /// from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + var telemetryId = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryId.Invoke(); + if (telemetryId != "" && telemetryId != "internal") + { + __correlationId = telemetryId; + } + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Creates a duplicate instance of this cmdlet (via JSON serialization). + /// a duplicate instance of NewAzCustomProviderAssociation_CreateViaJsonString + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.NewAzCustomProviderAssociation_CreateViaJsonString Clone() + { + var clone = new NewAzCustomProviderAssociation_CreateViaJsonString(); + clone.__correlationId = this.__correlationId; + clone.__processRecordId = this.__processRecordId; + clone.DefaultProfile = this.DefaultProfile; + clone.InvocationInformation = this.InvocationInformation; + clone.Proxy = this.Proxy; + clone.Pipeline = this.Pipeline; + clone.AsJob = this.AsJob; + clone.Break = this.Break; + clone.ProxyCredential = this.ProxyCredential; + clone.ProxyUseDefaultCredentials = this.ProxyUseDefaultCredentials; + clone.HttpPipelinePrepend = this.HttpPipelinePrepend; + clone.HttpPipelineAppend = this.HttpPipelineAppend; + clone.Scope = this.Scope; + clone.Name = this.Name; + clone.JsonString = this.JsonString; + return clone; + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } + var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); + if (telemetryInfo != null) + { + telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning); + telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties); + telemetryInfo.TryGetValue("InvocationName", out var invocationName); + if (showSecretsWarning == "true") + { + if (string.IsNullOrEmpty(sanitizedProperties)) + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + else + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + } + } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Information: + { + // When an operation supports asjob, Information messages must go thru verbose. + WriteVerbose($"INFORMATION: {(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: + { + var data = messageData(); + if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = response.GetFirstHeader(@"Location"); + var uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? response.RequestMessage.RequestUri.AbsoluteUri : location : asyncOperation; + WriteObject(new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncOperationResponse { Target = uri }); + // do nothing more. + data.Cancel(); + return; + } + } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } + break; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// + /// Initializes a new instance of the cmdlet class. + /// + public NewAzCustomProviderAssociation_CreateViaJsonString() + { + + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'AssociationsCreateOrUpdate' operation")) + { + if (true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")) + { + var instance = this.Clone(); + var job = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncJob(instance, this.MyInvocation.Line, this.MyInvocation.MyCommand.Name, this._cancellationTokenSource.Token, this._cancellationTokenSource.Cancel); + JobRepository.Add(job); + var task = instance.ProcessRecordAsync(); + job.Monitor(task); + WriteObject(job); + } + else + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token); + } + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.AssociationsCreateOrUpdateViaJsonString(Scope, Name, _jsonString, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + new protected void WriteObject(object sendToPipeline) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline); + } + + /// + /// + new protected void WriteObject(object sendToPipeline, bool enumerateCollection) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline, enumerateCollection); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } + } + } + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateExpanded.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateExpanded.cs index da3db88f03f4..e64508b27e34 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateExpanded.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateExpanded.cs @@ -6,19 +6,22 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; - /// Creates or updates the custom resource provider. + /// create the custom resource provider. /// /// [OpenAPI] CreateOrUpdate=>PUT:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.New, @"AzCustomProvider_CreateExpanded", SupportsShouldProcess = true)] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest))] - [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Creates or updates the custom resource provider.")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"create the custom resource provider.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] public partial class NewAzCustomProvider_CreateExpanded : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,8 +37,20 @@ public partial class NewAzCustomProvider_CreateExpanded : global::System.Managem /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + /// A manifest file that defines the custom resource provider resources. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest _resourceProviderBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.CustomRpManifest(); + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest _resourceProviderBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.CustomRpManifest(); + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; /// A list of actions that the custom resource provider implements. [global::System.Management.Automation.AllowEmptyCollection] @@ -46,8 +61,8 @@ public partial class NewAzCustomProvider_CreateExpanded : global::System.Managem ReadOnly = false, Description = @"A list of actions that the custom resource provider implements.", SerializedName = @"actions", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition) })] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpActionRouteDefinition[] Action { get => _resourceProviderBody.Action ?? null /* arrayOf */; set => _resourceProviderBody.Action = value; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition) })] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpActionRouteDefinition[] Action { get => _resourceProviderBody.Action?.ToArray() ?? null /* fixedArrayOf */; set => _resourceProviderBody.Action = (value != null ? new System.Collections.Generic.List(value) : null); } /// when specified, runs this cmdlet as a PowerShell job [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] @@ -59,6 +74,9 @@ public partial class NewAzCustomProvider_CreateExpanded : global::System.Managem [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -72,6 +90,9 @@ public partial class NewAzCustomProvider_CreateExpanded : global::System.Managem [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -132,7 +153,7 @@ public partial class NewAzCustomProvider_CreateExpanded : global::System.Managem /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -173,8 +194,8 @@ public partial class NewAzCustomProvider_CreateExpanded : global::System.Managem ReadOnly = false, Description = @"A list of resource types that the custom resource provider implements.", SerializedName = @"resourceTypes", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition) })] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpResourceTypeRouteDefinition[] ResourceType { get => _resourceProviderBody.ResourceType ?? null /* arrayOf */; set => _resourceProviderBody.ResourceType = value; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition) })] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpResourceTypeRouteDefinition[] ResourceType { get => _resourceProviderBody.ResourceType?.ToArray() ?? null /* fixedArrayOf */; set => _resourceProviderBody.ResourceType = (value != null ? new System.Collections.Generic.List(value) : null); } /// Backing field for property. private string _subscriptionId; @@ -192,7 +213,8 @@ public partial class NewAzCustomProvider_CreateExpanded : global::System.Managem [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( Name = @"", Description =@"", - Script = @"(Get-AzContext).Subscription.Id")] + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } @@ -205,8 +227,8 @@ public partial class NewAzCustomProvider_CreateExpanded : global::System.Managem ReadOnly = false, Description = @"Resource tags", SerializedName = @"tags", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags) })] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceTags Tag { get => _resourceProviderBody.Tag ?? null /* object */; set => _resourceProviderBody.Tag = value; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags) })] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceTags Tag { get => _resourceProviderBody.Tag ?? null /* object */; set => _resourceProviderBody.Tag = value; } /// A list of validations to run on the custom resource provider's requests. [global::System.Management.Automation.AllowEmptyCollection] @@ -217,32 +239,32 @@ public partial class NewAzCustomProvider_CreateExpanded : global::System.Managem ReadOnly = false, Description = @"A list of validations to run on the custom resource provider's requests.", SerializedName = @"validations", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations) })] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpValidations[] Validation { get => _resourceProviderBody.Validation ?? null /* arrayOf */; set => _resourceProviderBody.Validation = value; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations) })] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpValidations[] Validation { get => _resourceProviderBody.Validation?.ToArray() ?? null /* fixedArrayOf */; set => _resourceProviderBody.Validation = (value != null ? new System.Collections.Generic.List(value) : null); } /// /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -289,6 +311,11 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.NewAzCustomPro /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -353,11 +380,36 @@ protected override void EndProcessing() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: { + var data = messageData(); if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) { - var data = messageData(); if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) { var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); @@ -369,10 +421,26 @@ protected override void EndProcessing() return; } } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } break; } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -382,7 +450,7 @@ protected override void EndProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public NewAzCustomProvider_CreateExpanded() { @@ -448,7 +516,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -461,12 +529,12 @@ protected override void ProcessRecord() try { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - await this.Client.CustomResourceProviderCreateOrUpdate(SubscriptionId, ResourceGroupName, Name, _resourceProviderBody, onOk, onDefault, this, Pipeline); + await this.Client.CustomResourceProviderCreateOrUpdate(SubscriptionId, ResourceGroupName, Name, _resourceProviderBody, onOk, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate); await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name,body=_resourceProviderBody}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -504,12 +572,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -526,15 +594,15 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name, body=_resourceProviderBody }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name, body=_resourceProviderBody }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); @@ -544,12 +612,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -561,8 +629,26 @@ protected override void StopProcessing() return ; } // onOk - response for 200 / application/json - // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest - WriteObject((await response)); + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } } } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateViaJsonFilePath.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateViaJsonFilePath.cs new file mode 100644 index 000000000000..fd25333aa744 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateViaJsonFilePath.cs @@ -0,0 +1,609 @@ +// 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.CustomProviders.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; + using System; + + /// create the custom resource provider. + /// + /// [OpenAPI] CreateOrUpdate=>PUT:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.New, @"AzCustomProvider_CreateViaJsonFilePath", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"create the custom resource provider.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.NotSuggestDefaultParameterSet] + public partial class NewAzCustomProvider_CreateViaJsonFilePath : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + public global::System.String _jsonString; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + + /// when specified, runs this cmdlet as a PowerShell job + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter AsJob { get; set; } + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; + + /// + /// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet + /// against a different subscription + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// Backing field for property. + private string _jsonFilePath; + + /// Path of Json file supplied to the Create operation + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Path of Json file supplied to the Create operation")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Path of Json file supplied to the Create operation", + SerializedName = @"JsonFilePath", + PossibleTypes = new [] { typeof(string) })] + public string JsonFilePath { get => this._jsonFilePath; set { if (!System.IO.File.Exists(value)) { throw new Exception("Cannot find File " + value); } this._jsonString = System.IO.File.ReadAllText(value); this._jsonFilePath = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// The name of the resource provider. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the resource provider.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the resource provider.", + SerializedName = @"resourceProviderName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("ResourceProviderName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// when specified, will make the remote call, and return an AsyncOperationResponse, letting the remote operation continue + /// asynchronously. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command asynchronously")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter NoWait { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _resourceGroupName; + + /// The name of the resource group. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the resource group.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the resource group.", + SerializedName = @"resourceGroupName", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string ResourceGroupName { get => this._resourceGroupName; set => this._resourceGroupName = value; } + + /// Backing field for property. + private string _subscriptionId; + + /// + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)", + SerializedName = @"subscriptionId", + PossibleTypes = new [] { typeof(string) })] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( + Name = @"", + Description =@"", + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + /// from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + var telemetryId = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryId.Invoke(); + if (telemetryId != "" && telemetryId != "internal") + { + __correlationId = telemetryId; + } + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Creates a duplicate instance of this cmdlet (via JSON serialization). + /// a duplicate instance of NewAzCustomProvider_CreateViaJsonFilePath + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.NewAzCustomProvider_CreateViaJsonFilePath Clone() + { + var clone = new NewAzCustomProvider_CreateViaJsonFilePath(); + clone.__correlationId = this.__correlationId; + clone.__processRecordId = this.__processRecordId; + clone.DefaultProfile = this.DefaultProfile; + clone.InvocationInformation = this.InvocationInformation; + clone.Proxy = this.Proxy; + clone.Pipeline = this.Pipeline; + clone.AsJob = this.AsJob; + clone.Break = this.Break; + clone.ProxyCredential = this.ProxyCredential; + clone.ProxyUseDefaultCredentials = this.ProxyUseDefaultCredentials; + clone.HttpPipelinePrepend = this.HttpPipelinePrepend; + clone.HttpPipelineAppend = this.HttpPipelineAppend; + clone.SubscriptionId = this.SubscriptionId; + clone.ResourceGroupName = this.ResourceGroupName; + clone.Name = this.Name; + clone.JsonFilePath = this.JsonFilePath; + return clone; + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } + var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); + if (telemetryInfo != null) + { + telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning); + telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties); + telemetryInfo.TryGetValue("InvocationName", out var invocationName); + if (showSecretsWarning == "true") + { + if (string.IsNullOrEmpty(sanitizedProperties)) + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + else + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + } + } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Information: + { + // When an operation supports asjob, Information messages must go thru verbose. + WriteVerbose($"INFORMATION: {(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: + { + var data = messageData(); + if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = response.GetFirstHeader(@"Location"); + var uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? response.RequestMessage.RequestUri.AbsoluteUri : location : asyncOperation; + WriteObject(new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncOperationResponse { Target = uri }); + // do nothing more. + data.Cancel(); + return; + } + } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } + break; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// + /// Initializes a new instance of the cmdlet class. + /// + public NewAzCustomProvider_CreateViaJsonFilePath() + { + + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'CustomResourceProviderCreateOrUpdate' operation")) + { + if (true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")) + { + var instance = this.Clone(); + var job = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncJob(instance, this.MyInvocation.Line, this.MyInvocation.MyCommand.Name, this._cancellationTokenSource.Token, this._cancellationTokenSource.Cancel); + JobRepository.Add(job); + var task = instance.ProcessRecordAsync(); + job.Monitor(task); + WriteObject(job); + } + else + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token); + } + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.CustomResourceProviderCreateOrUpdateViaJsonString(SubscriptionId, ResourceGroupName, Name, _jsonString, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + new protected void WriteObject(object sendToPipeline) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline); + } + + /// + /// + new protected void WriteObject(object sendToPipeline, bool enumerateCollection) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline, enumerateCollection); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } + } + } + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateViaJsonString.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateViaJsonString.cs new file mode 100644 index 000000000000..e4c1e10f95c4 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/NewAzCustomProvider_CreateViaJsonString.cs @@ -0,0 +1,607 @@ +// 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.CustomProviders.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; + using System; + + /// create the custom resource provider. + /// + /// [OpenAPI] CreateOrUpdate=>PUT:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.New, @"AzCustomProvider_CreateViaJsonString", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"create the custom resource provider.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.NotSuggestDefaultParameterSet] + public partial class NewAzCustomProvider_CreateViaJsonString : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + + /// when specified, runs this cmdlet as a PowerShell job + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter AsJob { get; set; } + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; + + /// + /// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet + /// against a different subscription + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// Backing field for property. + private string _jsonString; + + /// Json string supplied to the Create operation + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Json string supplied to the Create operation")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Json string supplied to the Create operation", + SerializedName = @"JsonString", + PossibleTypes = new [] { typeof(string) })] + public string JsonString { get => this._jsonString; set => this._jsonString = value; } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// The name of the resource provider. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the resource provider.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the resource provider.", + SerializedName = @"resourceProviderName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("ResourceProviderName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// when specified, will make the remote call, and return an AsyncOperationResponse, letting the remote operation continue + /// asynchronously. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command asynchronously")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter NoWait { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _resourceGroupName; + + /// The name of the resource group. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the resource group.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the resource group.", + SerializedName = @"resourceGroupName", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string ResourceGroupName { get => this._resourceGroupName; set => this._resourceGroupName = value; } + + /// Backing field for property. + private string _subscriptionId; + + /// + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)", + SerializedName = @"subscriptionId", + PossibleTypes = new [] { typeof(string) })] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( + Name = @"", + Description =@"", + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + /// from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + var telemetryId = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryId.Invoke(); + if (telemetryId != "" && telemetryId != "internal") + { + __correlationId = telemetryId; + } + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Creates a duplicate instance of this cmdlet (via JSON serialization). + /// a duplicate instance of NewAzCustomProvider_CreateViaJsonString + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.NewAzCustomProvider_CreateViaJsonString Clone() + { + var clone = new NewAzCustomProvider_CreateViaJsonString(); + clone.__correlationId = this.__correlationId; + clone.__processRecordId = this.__processRecordId; + clone.DefaultProfile = this.DefaultProfile; + clone.InvocationInformation = this.InvocationInformation; + clone.Proxy = this.Proxy; + clone.Pipeline = this.Pipeline; + clone.AsJob = this.AsJob; + clone.Break = this.Break; + clone.ProxyCredential = this.ProxyCredential; + clone.ProxyUseDefaultCredentials = this.ProxyUseDefaultCredentials; + clone.HttpPipelinePrepend = this.HttpPipelinePrepend; + clone.HttpPipelineAppend = this.HttpPipelineAppend; + clone.SubscriptionId = this.SubscriptionId; + clone.ResourceGroupName = this.ResourceGroupName; + clone.Name = this.Name; + clone.JsonString = this.JsonString; + return clone; + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } + var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); + if (telemetryInfo != null) + { + telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning); + telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties); + telemetryInfo.TryGetValue("InvocationName", out var invocationName); + if (showSecretsWarning == "true") + { + if (string.IsNullOrEmpty(sanitizedProperties)) + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + else + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + } + } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Information: + { + // When an operation supports asjob, Information messages must go thru verbose. + WriteVerbose($"INFORMATION: {(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: + { + var data = messageData(); + if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = response.GetFirstHeader(@"Location"); + var uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? response.RequestMessage.RequestUri.AbsoluteUri : location : asyncOperation; + WriteObject(new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncOperationResponse { Target = uri }); + // do nothing more. + data.Cancel(); + return; + } + } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } + break; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// + /// Initializes a new instance of the cmdlet class. + /// + public NewAzCustomProvider_CreateViaJsonString() + { + + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'CustomResourceProviderCreateOrUpdate' operation")) + { + if (true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")) + { + var instance = this.Clone(); + var job = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncJob(instance, this.MyInvocation.Line, this.MyInvocation.MyCommand.Name, this._cancellationTokenSource.Token, this._cancellationTokenSource.Cancel); + JobRepository.Add(job); + var task = instance.ProcessRecordAsync(); + job.Monitor(task); + WriteObject(job); + } + else + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token); + } + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.CustomResourceProviderCreateOrUpdateViaJsonString(SubscriptionId, ResourceGroupName, Name, _jsonString, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + new protected void WriteObject(object sendToPipeline) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline); + } + + /// + /// + new protected void WriteObject(object sendToPipeline, bool enumerateCollection) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline, enumerateCollection); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } + } + } + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProviderAssociation_Delete.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProviderAssociation_Delete.cs index b444be26f323..6766f3560c27 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProviderAssociation_Delete.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProviderAssociation_Delete.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Delete an association. @@ -18,7 +20,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}", ApiVersion = "2018-09-01-preview")] public partial class RemoveAzCustomProviderAssociation_Delete : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,6 +37,18 @@ public partial class RemoveAzCustomProviderAssociation_Delete : global::System.M /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// when specified, runs this cmdlet as a PowerShell job [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] @@ -44,6 +59,9 @@ public partial class RemoveAzCustomProviderAssociation_Delete : global::System.M [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -57,6 +75,9 @@ public partial class RemoveAzCustomProviderAssociation_Delete : global::System.M [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -113,7 +134,7 @@ public partial class RemoveAzCustomProviderAssociation_Delete : global::System.M /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -150,12 +171,12 @@ public partial class RemoveAzCustomProviderAssociation_Delete : global::System.M /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnNoContent will be called before the regular onNoContent has been processed, allowing customization of @@ -220,6 +241,11 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.RemoveAzCustom /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -284,11 +310,36 @@ protected override void EndProcessing() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: { + var data = messageData(); if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) { - var data = messageData(); if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) { var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); @@ -300,10 +351,26 @@ protected override void EndProcessing() return; } } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } break; } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -371,7 +438,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -389,7 +456,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -402,7 +469,7 @@ protected override void ProcessRecord() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public RemoveAzCustomProviderAssociation_Delete() { @@ -435,12 +502,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -457,15 +524,15 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope, Name=Name }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProviderAssociation_DeleteViaIdentity.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProviderAssociation_DeleteViaIdentity.cs index 69267e6e4442..f03cd58b6984 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProviderAssociation_DeleteViaIdentity.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProviderAssociation_DeleteViaIdentity.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Delete an association. @@ -18,7 +20,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}", ApiVersion = "2018-09-01-preview")] public partial class RemoveAzCustomProviderAssociation_DeleteViaIdentity : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,6 +37,18 @@ public partial class RemoveAzCustomProviderAssociation_DeleteViaIdentity : globa /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// when specified, runs this cmdlet as a PowerShell job [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] @@ -44,6 +59,9 @@ public partial class RemoveAzCustomProviderAssociation_DeleteViaIdentity : globa [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -57,6 +75,9 @@ public partial class RemoveAzCustomProviderAssociation_DeleteViaIdentity : globa [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -106,7 +127,7 @@ public partial class RemoveAzCustomProviderAssociation_DeleteViaIdentity : globa /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -129,12 +150,12 @@ public partial class RemoveAzCustomProviderAssociation_DeleteViaIdentity : globa /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnNoContent will be called before the regular onNoContent has been processed, allowing customization of @@ -197,6 +218,11 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.RemoveAzCustom /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -261,11 +287,36 @@ protected override void EndProcessing() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: { + var data = messageData(); if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) { - var data = messageData(); if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) { var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); @@ -277,10 +328,26 @@ protected override void EndProcessing() return; } } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } break; } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -348,7 +415,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -382,7 +449,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -395,7 +462,7 @@ protected override void ProcessRecord() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public RemoveAzCustomProviderAssociation_DeleteViaIdentity() { @@ -428,12 +495,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -450,7 +517,7 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProvider_Delete.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProvider_Delete.cs index c4d09bebeaf1..40270ecaf03c 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProvider_Delete.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProvider_Delete.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Deletes the custom resource provider. @@ -18,7 +20,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] public partial class RemoveAzCustomProvider_Delete : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,6 +37,18 @@ public partial class RemoveAzCustomProvider_Delete : global::System.Management.A /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// when specified, runs this cmdlet as a PowerShell job [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] @@ -44,6 +59,9 @@ public partial class RemoveAzCustomProvider_Delete : global::System.Management.A [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -57,6 +75,9 @@ public partial class RemoveAzCustomProvider_Delete : global::System.Management.A [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -113,7 +134,7 @@ public partial class RemoveAzCustomProvider_Delete : global::System.Management.A /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -161,7 +182,8 @@ public partial class RemoveAzCustomProvider_Delete : global::System.Management.A [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( Name = @"", Description =@"", - Script = @"(Get-AzContext).Subscription.Id")] + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } @@ -170,12 +192,12 @@ public partial class RemoveAzCustomProvider_Delete : global::System.Management.A /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnNoContent will be called before the regular onNoContent has been processed, allowing customization of @@ -241,6 +263,11 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.RemoveAzCustom /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -305,11 +332,36 @@ protected override void EndProcessing() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: { + var data = messageData(); if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) { - var data = messageData(); if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) { var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); @@ -321,10 +373,26 @@ protected override void EndProcessing() return; } } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } break; } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -392,7 +460,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -410,7 +478,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -423,7 +491,7 @@ protected override void ProcessRecord() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public RemoveAzCustomProvider_Delete() { @@ -456,12 +524,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -478,15 +546,15 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProvider_DeleteViaIdentity.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProvider_DeleteViaIdentity.cs index 3c719b593e7b..80375034cd19 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProvider_DeleteViaIdentity.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/RemoveAzCustomProvider_DeleteViaIdentity.cs @@ -6,6 +6,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// Deletes the custom resource provider. @@ -18,7 +20,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] public partial class RemoveAzCustomProvider_DeleteViaIdentity : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -34,6 +37,18 @@ public partial class RemoveAzCustomProvider_DeleteViaIdentity : global::System.M /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + /// when specified, runs this cmdlet as a PowerShell job [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] @@ -44,6 +59,9 @@ public partial class RemoveAzCustomProvider_DeleteViaIdentity : global::System.M [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -57,6 +75,9 @@ public partial class RemoveAzCustomProvider_DeleteViaIdentity : global::System.M [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -106,7 +127,7 @@ public partial class RemoveAzCustomProvider_DeleteViaIdentity : global::System.M /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -129,12 +150,12 @@ public partial class RemoveAzCustomProvider_DeleteViaIdentity : global::System.M /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnNoContent will be called before the regular onNoContent has been processed, allowing customization of @@ -197,6 +218,11 @@ public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.RemoveAzCustom /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -261,11 +287,36 @@ protected override void EndProcessing() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: { + var data = messageData(); if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) { - var data = messageData(); if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) { var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); @@ -277,10 +328,26 @@ protected override void EndProcessing() return; } } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } break; } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -348,7 +415,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -386,7 +453,7 @@ protected override void ProcessRecord() } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -399,7 +466,7 @@ protected override void ProcessRecord() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public RemoveAzCustomProvider_DeleteViaIdentity() { @@ -432,12 +499,12 @@ protected override void StopProcessing() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -454,7 +521,7 @@ protected override void StopProcessing() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProviderAssociation_UpdateExpanded.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProviderAssociation_UpdateExpanded.cs new file mode 100644 index 000000000000..d5e0aa78c0c1 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProviderAssociation_UpdateExpanded.cs @@ -0,0 +1,598 @@ +// 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.CustomProviders.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; + using System; + + /// update an association. + /// + /// [OpenAPI] Get=>GET:"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}" + /// [OpenAPI] CreateOrUpdate=>PUT:"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsData.Update, @"AzCustomProviderAssociation_UpdateExpanded", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"update an association.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] + public partial class UpdateAzCustomProviderAssociation_UpdateExpanded : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// The resource definition of this association. + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation _associationBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association(); + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + + /// when specified, runs this cmdlet as a PowerShell job + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter AsJob { get; set; } + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; + + /// + /// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet + /// against a different subscription + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// The name of the association. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the association.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the association.", + SerializedName = @"associationName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("AssociationName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// when specified, will make the remote call, and return an AsyncOperationResponse, letting the remote operation continue + /// asynchronously. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command asynchronously")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter NoWait { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _scope; + + /// + /// The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' + /// for a virtual machine resource. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The scope of the association. The scope can be any valid REST resource instance. For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource.", + SerializedName = @"scope", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Scope { get => this._scope; set => this._scope = value; } + + /// The REST resource instance of the target resource for this association. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The REST resource instance of the target resource for this association.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The REST resource instance of the target resource for this association.", + SerializedName = @"targetResourceId", + PossibleTypes = new [] { typeof(string) })] + public string TargetResourceId { get => _associationBody.TargetResourceId ?? null; set => _associationBody.TargetResourceId = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + /// from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + var telemetryId = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryId.Invoke(); + if (telemetryId != "" && telemetryId != "internal") + { + __correlationId = telemetryId; + } + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Creates a duplicate instance of this cmdlet (via JSON serialization). + /// a duplicate instance of UpdateAzCustomProviderAssociation_UpdateExpanded + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.UpdateAzCustomProviderAssociation_UpdateExpanded Clone() + { + var clone = new UpdateAzCustomProviderAssociation_UpdateExpanded(); + clone.__correlationId = this.__correlationId; + clone.__processRecordId = this.__processRecordId; + clone.DefaultProfile = this.DefaultProfile; + clone.InvocationInformation = this.InvocationInformation; + clone.Proxy = this.Proxy; + clone.Pipeline = this.Pipeline; + clone.AsJob = this.AsJob; + clone.Break = this.Break; + clone.ProxyCredential = this.ProxyCredential; + clone.ProxyUseDefaultCredentials = this.ProxyUseDefaultCredentials; + clone.HttpPipelinePrepend = this.HttpPipelinePrepend; + clone.HttpPipelineAppend = this.HttpPipelineAppend; + clone._associationBody = this._associationBody; + clone.Scope = this.Scope; + clone.Name = this.Name; + return clone; + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } + var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); + if (telemetryInfo != null) + { + telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning); + telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties); + telemetryInfo.TryGetValue("InvocationName", out var invocationName); + if (showSecretsWarning == "true") + { + if (string.IsNullOrEmpty(sanitizedProperties)) + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + else + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + } + } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Information: + { + // When an operation supports asjob, Information messages must go thru verbose. + WriteVerbose($"INFORMATION: {(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: + { + var data = messageData(); + if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = response.GetFirstHeader(@"Location"); + var uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? response.RequestMessage.RequestUri.AbsoluteUri : location : asyncOperation; + WriteObject(new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncOperationResponse { Target = uri }); + // do nothing more. + data.Cancel(); + return; + } + } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } + break; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'AssociationsCreateOrUpdate' operation")) + { + if (true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")) + { + var instance = this.Clone(); + var job = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncJob(instance, this.MyInvocation.Line, this.MyInvocation.MyCommand.Name, this._cancellationTokenSource.Token, this._cancellationTokenSource.Cancel); + JobRepository.Add(job); + var task = instance.ProcessRecordAsync(); + job.Monitor(task); + WriteObject(job); + } + else + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token); + } + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + _associationBody = await this.Client.AssociationsGetWithResult(Scope, Name, this, Pipeline); + this.Update_associationBody(); + await this.Client.AssociationsCreateOrUpdate(Scope, Name, _associationBody, onOk, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate); + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { Scope=Scope,Name=Name}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// Initializes a new instance of the cmdlet class. + /// + public UpdateAzCustomProviderAssociation_UpdateExpanded() + { + + } + + private void Update_associationBody() + { + if ((bool)(true == this.MyInvocation?.BoundParameters.ContainsKey("TargetResourceId"))) + { + this.TargetResourceId = (string)(this.MyInvocation?.BoundParameters["TargetResourceId"]); + } + } + + /// + new protected void WriteObject(object sendToPipeline) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline); + } + + /// + /// + new protected void WriteObject(object sendToPipeline, bool enumerateCollection) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline, enumerateCollection); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } + } + } + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProviderAssociation_UpdateViaIdentityExpanded.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProviderAssociation_UpdateViaIdentityExpanded.cs new file mode 100644 index 000000000000..691932695227 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProviderAssociation_UpdateViaIdentityExpanded.cs @@ -0,0 +1,592 @@ +// 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.CustomProviders.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; + using System; + + /// update an association. + /// + /// [OpenAPI] Get=>GET:"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}" + /// [OpenAPI] CreateOrUpdate=>PUT:"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsData.Update, @"AzCustomProviderAssociation_UpdateViaIdentityExpanded", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"update an association.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] + public partial class UpdateAzCustomProviderAssociation_UpdateViaIdentityExpanded : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// The resource definition of this association. + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation _associationBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Association(); + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + + /// when specified, runs this cmdlet as a PowerShell job + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter AsJob { get; set; } + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; + + /// + /// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet + /// against a different subscription + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Backing field for property. + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity _inputObject; + + /// Identity Parameter + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Identity Parameter", ValueFromPipeline = true)] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity InputObject { get => this._inputObject; set => this._inputObject = value; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// + /// when specified, will make the remote call, and return an AsyncOperationResponse, letting the remote operation continue + /// asynchronously. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command asynchronously")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter NoWait { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// The REST resource instance of the target resource for this association. + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The REST resource instance of the target resource for this association.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Body)] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = false, + ReadOnly = false, + Description = @"The REST resource instance of the target resource for this association.", + SerializedName = @"targetResourceId", + PossibleTypes = new [] { typeof(string) })] + public string TargetResourceId { get => _associationBody.TargetResourceId ?? null; set => _associationBody.TargetResourceId = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + /// from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + var telemetryId = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryId.Invoke(); + if (telemetryId != "" && telemetryId != "internal") + { + __correlationId = telemetryId; + } + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Creates a duplicate instance of this cmdlet (via JSON serialization). + /// + /// a duplicate instance of UpdateAzCustomProviderAssociation_UpdateViaIdentityExpanded + /// + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets.UpdateAzCustomProviderAssociation_UpdateViaIdentityExpanded Clone() + { + var clone = new UpdateAzCustomProviderAssociation_UpdateViaIdentityExpanded(); + clone.__correlationId = this.__correlationId; + clone.__processRecordId = this.__processRecordId; + clone.DefaultProfile = this.DefaultProfile; + clone.InvocationInformation = this.InvocationInformation; + clone.Proxy = this.Proxy; + clone.Pipeline = this.Pipeline; + clone.AsJob = this.AsJob; + clone.Break = this.Break; + clone.ProxyCredential = this.ProxyCredential; + clone.ProxyUseDefaultCredentials = this.ProxyUseDefaultCredentials; + clone.HttpPipelinePrepend = this.HttpPipelinePrepend; + clone.HttpPipelineAppend = this.HttpPipelineAppend; + clone._associationBody = this._associationBody; + return clone; + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } + var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); + if (telemetryInfo != null) + { + telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning); + telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties); + telemetryInfo.TryGetValue("InvocationName", out var invocationName); + if (showSecretsWarning == "true") + { + if (string.IsNullOrEmpty(sanitizedProperties)) + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + else + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + } + } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Information: + { + // When an operation supports asjob, Information messages must go thru verbose. + WriteVerbose($"INFORMATION: {(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.DelayBeforePolling: + { + var data = messageData(); + if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation"); + var location = response.GetFirstHeader(@"Location"); + var uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? response.RequestMessage.RequestUri.AbsoluteUri : location : asyncOperation; + WriteObject(new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncOperationResponse { Target = uri }); + // do nothing more. + data.Cancel(); + return; + } + } + else + { + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30); + WriteDebug($"Delaying {delay} seconds before polling."); + for (var now = 0; now < delay; ++now) + { + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status") + { + PercentComplete = now * 100 / delay + }); + await global::System.Threading.Tasks.Task.Delay(1000, token); + } + } + } + break; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'AssociationsCreateOrUpdate' operation")) + { + if (true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")) + { + var instance = this.Clone(); + var job = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncJob(instance, this.MyInvocation.Line, this.MyInvocation.MyCommand.Name, this._cancellationTokenSource.Token, this._cancellationTokenSource.Cancel); + JobRepository.Add(job); + var task = instance.ProcessRecordAsync(); + job.Monitor(task); + WriteObject(job); + } + else + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token); + } + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + if (InputObject?.Id != null) + { + _associationBody = await this.Client.AssociationsGetViaIdentityWithResult(InputObject.Id, this, Pipeline); + this.Update_associationBody(); + await this.Client.AssociationsCreateOrUpdateViaIdentity(InputObject.Id, _associationBody, onOk, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate); + } + else + { + // try to call with PATH parameters from Input Object + if (null == InputObject.Scope) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.Scope"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + if (null == InputObject.AssociationName) + { + ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.AssociationName"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); + } + _associationBody = await this.Client.AssociationsGetWithResult(InputObject.Scope ?? null, InputObject.AssociationName ?? null, this, Pipeline); + this.Update_associationBody(); + await this.Client.AssociationsCreateOrUpdate(InputObject.Scope ?? null, InputObject.AssociationName ?? null, _associationBody, onOk, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeCreate|Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate); + } + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// Initializes a new instance of the cmdlet class. + /// + public UpdateAzCustomProviderAssociation_UpdateViaIdentityExpanded() + { + + } + + private void Update_associationBody() + { + if ((bool)(true == this.MyInvocation?.BoundParameters.ContainsKey("TargetResourceId"))) + { + this.TargetResourceId = (string)(this.MyInvocation?.BoundParameters["TargetResourceId"]); + } + } + + /// + new protected void WriteObject(object sendToPipeline) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline); + } + + /// + /// + new protected void WriteObject(object sendToPipeline, bool enumerateCollection) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline, enumerateCollection); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IAssociation + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } + } + } + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateExpanded.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateExpanded.cs index b40870a78644..42fa80892425 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateExpanded.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateExpanded.cs @@ -6,21 +6,24 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// - /// Updates an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. /// /// /// [OpenAPI] Update=>PATCH:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsData.Update, @"AzCustomProvider_UpdateExpanded", SupportsShouldProcess = true)] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest))] - [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Updates an existing custom resource provider. The only value that can be updated via PATCH currently is the tags.")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] public partial class UpdateAzCustomProvider_UpdateExpanded : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -36,14 +39,29 @@ public partial class UpdateAzCustomProvider_UpdateExpanded : global::System.Mana /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + /// custom resource provider update information. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate _patchableResourceBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProvidersUpdate(); + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate _patchableResourceBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProvidersUpdate(); + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -57,6 +75,9 @@ public partial class UpdateAzCustomProvider_UpdateExpanded : global::System.Mana [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -98,7 +119,7 @@ public partial class UpdateAzCustomProvider_UpdateExpanded : global::System.Mana /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -146,7 +167,8 @@ public partial class UpdateAzCustomProvider_UpdateExpanded : global::System.Mana [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( Name = @"", Description =@"", - Script = @"(Get-AzContext).Subscription.Id")] + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } @@ -159,32 +181,32 @@ public partial class UpdateAzCustomProvider_UpdateExpanded : global::System.Mana ReadOnly = false, Description = @"Resource tags", SerializedName = @"tags", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags) })] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags Tag { get => _patchableResourceBody.Tag ?? null /* object */; set => _patchableResourceBody.Tag = value; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags) })] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags Tag { get => _patchableResourceBody.Tag ?? null /* object */; set => _patchableResourceBody.Tag = value; } /// /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -207,6 +229,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -271,8 +298,33 @@ protected override void EndProcessing() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -328,7 +380,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -341,12 +393,12 @@ protected override void ProcessRecord() try { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - await this.Client.CustomResourceProviderUpdate(SubscriptionId, ResourceGroupName, Name, _patchableResourceBody, onOk, onDefault, this, Pipeline); + await this.Client.CustomResourceProviderUpdate(SubscriptionId, ResourceGroupName, Name, _patchableResourceBody, onOk, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate); await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name,body=_patchableResourceBody}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -366,7 +418,7 @@ protected override void StopProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public UpdateAzCustomProvider_UpdateExpanded() { @@ -392,12 +444,12 @@ public UpdateAzCustomProvider_UpdateExpanded() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -414,15 +466,15 @@ public UpdateAzCustomProvider_UpdateExpanded() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name, body=_patchableResourceBody }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name, body=_patchableResourceBody }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); @@ -432,12 +484,12 @@ public UpdateAzCustomProvider_UpdateExpanded() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -449,8 +501,26 @@ public UpdateAzCustomProvider_UpdateExpanded() return ; } // onOk - response for 200 / application/json - // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest - WriteObject((await response)); + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } } } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaIdentityExpanded.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaIdentityExpanded.cs index 258b5b80f677..4a64fd485e28 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaIdentityExpanded.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaIdentityExpanded.cs @@ -6,21 +6,24 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Cmdlets { using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; using System; /// - /// Updates an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. /// /// /// [OpenAPI] Update=>PATCH:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}" /// [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsData.Update, @"AzCustomProvider_UpdateViaIdentityExpanded", SupportsShouldProcess = true)] - [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest))] - [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"Updates an existing custom resource provider. The only value that can be updated via PATCH currently is the tags.")] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags.")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] public partial class UpdateAzCustomProvider_UpdateViaIdentityExpanded : global::System.Management.Automation.PSCmdlet, - Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext { /// A unique id generatd for the this cmdlet when it is instantiated. private string __correlationId = System.Guid.NewGuid().ToString(); @@ -36,14 +39,29 @@ public partial class UpdateAzCustomProvider_UpdateViaIdentityExpanded : global:: /// private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + /// custom resource provider update information. - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdate _patchableResourceBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceProvidersUpdate(); + private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdate _patchableResourceBody = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ResourceProvidersUpdate(); + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; /// Wait for .NET debugger to attach [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] public global::System.Management.Automation.SwitchParameter Break { get; set; } + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + /// The reference to the client API class. public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; @@ -57,6 +75,9 @@ public partial class UpdateAzCustomProvider_UpdateViaIdentityExpanded : global:: [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + /// SendAsync Pipeline Steps to be appended to the front of the pipeline [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] [global::System.Management.Automation.ValidateNotNull] @@ -91,7 +112,7 @@ public partial class UpdateAzCustomProvider_UpdateViaIdentityExpanded : global:: /// /// The instance of the that the remote call will use. /// - private Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } /// The URI for the proxy server to use [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] @@ -118,32 +139,32 @@ public partial class UpdateAzCustomProvider_UpdateViaIdentityExpanded : global:: ReadOnly = false, Description = @"Resource tags", SerializedName = @"tags", - PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags) })] - public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProvidersUpdateTags Tag { get => _patchableResourceBody.Tag ?? null /* object */; set => _patchableResourceBody.Tag = value; } + PossibleTypes = new [] { typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags) })] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProvidersUpdateTags Tag { get => _patchableResourceBody.Tag ?? null /* object */; set => _patchableResourceBody.Tag = value; } /// /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what /// happens on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// Determines if the rest of the onDefault method should be processed, or if the method should /// return immediately (set to true to skip further processing ) - partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens /// on that response. Implement this method in a partial class to enable this behavior /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// Determines if the rest of the onOk method should be processed, or if the method should return /// immediately (set to true to skip further processing ) - partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); /// /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) @@ -166,6 +187,11 @@ protected override void BeginProcessing() /// Performs clean-up after the command execution protected override void EndProcessing() { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); if (telemetryInfo != null) { @@ -230,8 +256,33 @@ protected override void EndProcessing() WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); return ; } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } } - await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); if (token.IsCancellationRequested) { return ; @@ -287,7 +338,7 @@ protected override void ProcessRecord() using( NoSynchronizationContext ) { await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } - Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); if (null != HttpPipelinePrepend) { Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); @@ -302,7 +353,7 @@ protected override void ProcessRecord() await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } if (InputObject?.Id != null) { - await this.Client.CustomResourceProviderUpdateViaIdentity(InputObject.Id, _patchableResourceBody, onOk, onDefault, this, Pipeline); + await this.Client.CustomResourceProviderUpdateViaIdentity(InputObject.Id, _patchableResourceBody, onOk, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate); } else { @@ -319,13 +370,13 @@ protected override void ProcessRecord() { ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.ResourceProviderName"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) ); } - await this.Client.CustomResourceProviderUpdate(InputObject.SubscriptionId ?? null, InputObject.ResourceGroupName ?? null, InputObject.ResourceProviderName ?? null, _patchableResourceBody, onOk, onDefault, this, Pipeline); + await this.Client.CustomResourceProviderUpdate(InputObject.SubscriptionId ?? null, InputObject.ResourceGroupName ?? null, InputObject.ResourceProviderName ?? null, _patchableResourceBody, onOk, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SerializationMode.IncludeUpdate); } await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } } catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) { - WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { body=_patchableResourceBody}) + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } }); @@ -345,7 +396,7 @@ protected override void StopProcessing() } /// - /// Intializes a new instance of the cmdlet class. + /// Initializes a new instance of the cmdlet class. /// public UpdateAzCustomProvider_UpdateViaIdentityExpanded() { @@ -371,12 +422,12 @@ public UpdateAzCustomProvider_UpdateViaIdentityExpanded() /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). /// /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IErrorResponse + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -393,15 +444,15 @@ public UpdateAzCustomProvider_UpdateViaIdentityExpanded() if ((null == code || null == message)) { // Unrecognized Response. Create an error record based on what we have. - var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); - WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { body=_patchableResourceBody }) + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } }); } else { - WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { body=_patchableResourceBody }) + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) { ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } }); @@ -411,12 +462,12 @@ public UpdateAzCustomProvider_UpdateViaIdentityExpanded() /// a delegate that is called when the remote service returns 200 (OK). /// the raw response message as an global::System.Net.Http.HttpResponseMessage. - /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest /// from the remote call /// /// A that will be complete when handling of the method is completed. /// - private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) { using( NoSynchronizationContext ) { @@ -428,8 +479,26 @@ public UpdateAzCustomProvider_UpdateViaIdentityExpanded() return ; } // onOk - response for 200 / application/json - // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest - WriteObject((await response)); + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } } } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaJsonFilePath.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaJsonFilePath.cs new file mode 100644 index 000000000000..57b85c17d9a8 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaJsonFilePath.cs @@ -0,0 +1,528 @@ +// 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.CustomProviders.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; + using System; + + /// + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. + /// + /// + /// [OpenAPI] Update=>PATCH:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsData.Update, @"AzCustomProvider_UpdateViaJsonFilePath", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.NotSuggestDefaultParameterSet] + public partial class UpdateAzCustomProvider_UpdateViaJsonFilePath : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + public global::System.String _jsonString; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; + + /// + /// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet + /// against a different subscription + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// Backing field for property. + private string _jsonFilePath; + + /// Path of Json file supplied to the Update operation + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Path of Json file supplied to the Update operation")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Path of Json file supplied to the Update operation", + SerializedName = @"JsonFilePath", + PossibleTypes = new [] { typeof(string) })] + public string JsonFilePath { get => this._jsonFilePath; set { if (!System.IO.File.Exists(value)) { throw new Exception("Cannot find File " + value); } this._jsonString = System.IO.File.ReadAllText(value); this._jsonFilePath = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// The name of the resource provider. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the resource provider.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the resource provider.", + SerializedName = @"resourceProviderName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("ResourceProviderName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// The instance of the that the remote call will use. + /// + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _resourceGroupName; + + /// The name of the resource group. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the resource group.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the resource group.", + SerializedName = @"resourceGroupName", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string ResourceGroupName { get => this._resourceGroupName; set => this._resourceGroupName = value; } + + /// Backing field for property. + private string _subscriptionId; + + /// + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)", + SerializedName = @"subscriptionId", + PossibleTypes = new [] { typeof(string) })] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( + Name = @"", + Description =@"", + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + /// from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + var telemetryId = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryId.Invoke(); + if (telemetryId != "" && telemetryId != "internal") + { + __correlationId = telemetryId; + } + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } + var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); + if (telemetryInfo != null) + { + telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning); + telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties); + telemetryInfo.TryGetValue("InvocationName", out var invocationName); + if (showSecretsWarning == "true") + { + if (string.IsNullOrEmpty(sanitizedProperties)) + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + else + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + } + } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data.Message, new string[]{}); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'CustomResourceProviderUpdate' operation")) + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token); + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.CustomResourceProviderUpdateViaJsonString(SubscriptionId, ResourceGroupName, Name, _jsonString, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// Initializes a new instance of the cmdlet class. + /// + public UpdateAzCustomProvider_UpdateViaJsonFilePath() + { + + } + + /// + new protected void WriteObject(object sendToPipeline) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline); + } + + /// + /// + new protected void WriteObject(object sendToPipeline, bool enumerateCollection) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline, enumerateCollection); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } + } + } + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaJsonString.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaJsonString.cs new file mode 100644 index 000000000000..6b27e28dc89d --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/cmdlets/UpdateAzCustomProvider_UpdateViaJsonString.cs @@ -0,0 +1,526 @@ +// 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.CustomProviders.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell; + using Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets; + using System; + + /// + /// update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. + /// + /// + /// [OpenAPI] Update=>PATCH:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsData.Update, @"AzCustomProvider_UpdateViaJsonString", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest))] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Description(@"update an existing custom resource provider. The only value that can be updated via PATCH currently is the tags.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Generated] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.HttpPath(Path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", ApiVersion = "2018-09-01-preview")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.NotSuggestDefaultParameterSet] + public partial class UpdateAzCustomProvider_UpdateViaJsonString : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener, + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// A dictionary to carry over additional data for pipeline. + private global::System.Collections.Generic.Dictionary _extensibleParameters = new System.Collections.Generic.Dictionary(); + + /// A buffer to record first returned object in response. + private object _firstResponse = null; + + /// + /// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. + /// Two means multiple returned objects in response. + /// + private int _responseSize = 0; + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// Accessor for cancellationTokenSource. + public global::System.Threading.CancellationTokenSource CancellationTokenSource { get => _cancellationTokenSource ; set { _cancellationTokenSource = value; } } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.ClientAPI; + + /// + /// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet + /// against a different subscription + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// Accessor for extensibleParameters. + public global::System.Collections.Generic.IDictionary ExtensibleParameters { get => _extensibleParameters ; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// Backing field for property. + private string _jsonString; + + /// Json string supplied to the Update operation + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Json string supplied to the Update operation")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Json string supplied to the Update operation", + SerializedName = @"JsonString", + PossibleTypes = new [] { typeof(string) })] + public string JsonString { get => this._jsonString; set => this._jsonString = value; } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// The name of the resource provider. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the resource provider.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the resource provider.", + SerializedName = @"resourceProviderName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("ResourceProviderName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// The instance of the that the remote call will use. + /// + public Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _resourceGroupName; + + /// The name of the resource group. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the resource group.")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the resource group.", + SerializedName = @"resourceGroupName", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string ResourceGroupName { get => this._resourceGroupName; set => this._resourceGroupName = value; } + + /// Backing field for property. + private string _subscriptionId; + + /// + /// The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)")] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)", + SerializedName = @"subscriptionId", + PossibleTypes = new [] { typeof(string) })] + [Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.DefaultInfo( + Name = @"", + Description =@"", + Script = @"(Get-AzContext).Subscription.Id", + SetCondition = @"")] + [global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Category(global::Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.ParameterCategory.Path)] + public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + /// from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + var telemetryId = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryId.Invoke(); + if (telemetryId != "" && telemetryId != "internal") + { + __correlationId = telemetryId; + } + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse); + } + var telemetryInfo = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.GetTelemetryInfo?.Invoke(__correlationId); + if (telemetryInfo != null) + { + telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning); + telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties); + telemetryInfo.TryGetValue("InvocationName", out var invocationName); + if (showSecretsWarning == "true") + { + if (string.IsNullOrEmpty(sanitizedProperties)) + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + else + { + WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844"); + } + } + } + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Information: + { + var data = messageData(); + WriteInformation(data.Message, new string[]{}); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.Progress: + { + var data = messageData(); + int progress = (int)data.Value; + string activityMessage, statusDescription; + global::System.Management.Automation.ProgressRecordType recordType; + if (progress < 100) + { + activityMessage = "In progress"; + statusDescription = "Checking operation status"; + recordType = System.Management.Automation.ProgressRecordType.Processing; + } + else + { + activityMessage = "Completed"; + statusDescription = "Completed"; + recordType = System.Management.Automation.ProgressRecordType.Completed; + } + WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription) + { + PercentComplete = progress, + RecordType = recordType + }); + return ; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.Signal(id, token, messageData, (i, t, m) => ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(i, t, () => Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventDataConverter.ConvertFrom(m()) as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.EventData), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'CustomResourceProviderUpdate' operation")) + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token); + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName, this.ExtensibleParameters); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + await this.Client.CustomResourceProviderUpdateViaJsonString(SubscriptionId, ResourceGroupName, Name, _jsonString, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.UndeclaredResponseException urexception) + { + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// Initializes a new instance of the cmdlet class. + /// + public UpdateAzCustomProvider_UpdateViaJsonString() + { + + } + + /// + new protected void WriteObject(object sendToPipeline) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline); + } + + /// + /// + new protected void WriteObject(object sendToPipeline, bool enumerateCollection) + { + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Module.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId); + base.WriteObject(sendToPipeline, enumerateCollection); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IErrorResponse + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.RestException(responseMessage, await response); + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomRpManifest + var result = (await response); + if (null != result) + { + if (0 == _responseSize) + { + _firstResponse = result; + _responseSize = 1; + } + else + { + if (1 ==_responseSize) + { + // Flush buffer + WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject()); + } + WriteObject(result.AddMultipleTypeNameIntoPSObject()); + _responseSize = 2; + } + } + } + } + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Attributes/ExternalDocsAttribute.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Attributes/ExternalDocsAttribute.cs new file mode 100644 index 000000000000..11e14984c363 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Attributes/ExternalDocsAttribute.cs @@ -0,0 +1,30 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders +{ + using System; + using System.Collections.Generic; + using System.Text; + + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)] + public class ExternalDocsAttribute : Attribute + { + + public string Description { get; } + + public string Url { get; } + + public ExternalDocsAttribute(string url) + { + Url = url; + } + + public ExternalDocsAttribute(string url, string description) + { + Url = url; + Description = description; + } + } +} diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Attributes/PSArgumentCompleterAttribute.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Attributes/PSArgumentCompleterAttribute.cs new file mode 100644 index 000000000000..35072a34d7c7 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Attributes/PSArgumentCompleterAttribute.cs @@ -0,0 +1,52 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Management.Automation; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders +{ + public class PSArgumentCompleterAttribute : ArgumentCompleterAttribute + { + internal string[] ResourceTypes; + + public PSArgumentCompleterAttribute(params string[] argumentList) : base(CreateScriptBlock(argumentList)) + { + ResourceTypes = argumentList; + } + + public static ScriptBlock CreateScriptBlock(string[] resourceTypes) + { + List outputResourceTypes = new List(); + foreach (string resourceType in resourceTypes) + { + if (resourceType.Contains(" ")) + { + outputResourceTypes.Add("\'\'" + resourceType + "\'\'"); + } + else + { + outputResourceTypes.Add(resourceType); + } + } + string scriptResourceTypeList = "'" + String.Join("' , '", outputResourceTypes) + "'"; + string script = "param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)\n" + + String.Format("$values = {0}\n", scriptResourceTypeList) + + "$values | Where-Object { $_ -Like \"$wordToComplete*\" -or $_ -Like \"'$wordToComplete*\" } | Sort-Object | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }"; + ScriptBlock scriptBlock = ScriptBlock.Create(script); + return scriptBlock; + } + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportFormatPs1xml.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportFormatPs1xml.cs index 3f33d0d42976..232c0cb3473a 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportFormatPs1xml.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportFormatPs1xml.cs @@ -20,11 +20,13 @@ public class ExportFormatPs1xml : PSCmdlet public string FilePath { get; set; } private const string ModelNamespace = @"Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models"; - private const string SupportNamespace = @"Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support"; + private const string SupportNamespace = @"${$project.supportNamespace.fullName}"; private const string PropertiesExcludedForTableview = @"Id,Type"; private static readonly bool IsAzure = Convert.ToBoolean(@"true"); + private static string SelectedBySuffix = @"#Multiple"; + protected override void ProcessRecord() { try @@ -76,7 +78,7 @@ private static View CreateViewModel(ViewParameters viewParameters) Name = viewParameters.Type.FullName, ViewSelectedBy = new ViewSelectedBy { - TypeName = viewParameters.Type.FullName + TypeName = string.Concat(viewParameters.Type.FullName, SelectedBySuffix) }, TableControl = new TableControl { diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportModelSurface.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportModelSurface.cs index aa3a2f81b336..c2bbcfd8c09b 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportModelSurface.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportModelSurface.cs @@ -24,7 +24,7 @@ public class ExportModelSurface : PSCmdlet public bool UseExpandedFormat { get; set; } private const string ModelNamespace = @"Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models"; - private const string SupportNamespace = @"Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Support"; + private const string SupportNamespace = @"${$project.supportNamespace.fullName}"; protected override void ProcessRecord() { diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportProxyCmdlet.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportProxyCmdlet.cs index 3070c54cd1b0..605b6b7bc413 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportProxyCmdlet.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportProxyCmdlet.cs @@ -70,9 +70,8 @@ protected override void ProcessRecord() var variantGroups = profileGroups.SelectMany(pg => pg.Variants .GroupBy(v => new { v.CmdletName, v.IsInternal }) .Select(vg => new VariantGroup(ModuleName, vg.Key.CmdletName, vg.Select(v => v).ToArray(), - Path.Combine(vg.Key.IsInternal ? InternalFolder : ExportsFolder, pg.ProfileFolder), pg.ProfileName, isInternal: vg.Key.IsInternal))) + Path.Combine(vg.Key.IsInternal ? InternalFolder : ExportsFolder, pg.ProfileFolder), pg.ProfileName, isInternal: vg.Key.IsInternal))) .ToArray(); - var license = new StringBuilder(); license.Append(@" # ---------------------------------------------------------------------------------- @@ -114,6 +113,7 @@ protected override void ProcessRecord() sb.Append("param("); sb.Append($"{(parameterGroups.Any() ? Environment.NewLine : String.Empty)}"); + foreach (var parameterGroup in parameterGroups) { var parameters = parameterGroup.HasAllVariants ? parameterGroup.Parameters.Take(1) : parameterGroup.Parameters; diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportPsd1.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportPsd1.cs index 69c42cd42cfc..b96c216f1924 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportPsd1.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportPsd1.cs @@ -137,7 +137,7 @@ protected override void ProcessRecord() } else { - var cmdletsList = functionInfos.Select(fi => fi.Name).Distinct().Append("*").ToPsList(); + var cmdletsList = functionInfos.Select(fi => fi.Name).Distinct().ToPsList(); sb.AppendLine($@"{Indent}FunctionsToExport = {cmdletsList}"); } @@ -148,8 +148,10 @@ protected override void ProcessRecord() } else { - var aliasesList = functionInfos.SelectMany(fi => fi.ScriptBlock.Attributes).ToAliasNames().Append("*").ToPsList(); - sb.AppendLine($@"{Indent}AliasesToExport = {aliasesList}"); + var aliasesList = functionInfos.SelectMany(fi => fi.ScriptBlock.Attributes).ToAliasNames().ToPsList(); + if (!String.IsNullOrEmpty(aliasesList)) { + sb.AppendLine($@"{Indent}AliasesToExport = {aliasesList}"); + } } // CmdletsToExport diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportTestStub.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportTestStub.cs index 631b0dbf044e..324063d48573 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportTestStub.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Cmdlets/ExportTestStub.cs @@ -12,50 +12,96 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell { - [Cmdlet(VerbsData.Export, "TestStub")] - [DoNotExport] - public class ExportTestStub : PSCmdlet - { - [Parameter(Mandatory = true)] - [ValidateNotNullOrEmpty] - public string ModuleName { get; set; } - - [Parameter(Mandatory = true)] - [ValidateNotNullOrEmpty] - public string ExportsFolder { get; set; } - - [Parameter(Mandatory = true)] - [ValidateNotNullOrEmpty] - public string OutputFolder { get; set; } - - [Parameter] - public SwitchParameter IncludeGenerated { get; set; } - - protected override void ProcessRecord() + [Cmdlet(VerbsData.Export, "TestStub")] + [DoNotExport] + public class ExportTestStub : PSCmdlet { - try - { - if (!Directory.Exists(ExportsFolder)) - { - throw new ArgumentException($"Exports folder '{ExportsFolder}' does not exist"); - } + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ModuleName { get; set; } - var exportDirectories = Directory.GetDirectories(ExportsFolder); - if (!exportDirectories.Any()) - { - exportDirectories = new[] { ExportsFolder }; - } - var utilFile = Path.Combine(OutputFolder, "utils.ps1"); - if (!File.Exists(utilFile)) + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string ExportsFolder { get; set; } + + [Parameter(Mandatory = true)] + [ValidateNotNullOrEmpty] + public string OutputFolder { get; set; } + + [Parameter] + public SwitchParameter IncludeGenerated { get; set; } + + protected override void ProcessRecord() { - var sc = new StringBuilder(); - sc.AppendLine(@"function RandomString([bool]$allChars, [int32]$len) { + try + { + if (!Directory.Exists(ExportsFolder)) + { + throw new ArgumentException($"Exports folder '{ExportsFolder}' does not exist"); + } + + var exportDirectories = Directory.GetDirectories(ExportsFolder); + if (!exportDirectories.Any()) + { + exportDirectories = new[] { ExportsFolder }; + } + /*var loadEnvFile = Path.Combine(OutputFolder, "loadEnv.ps1"); + if (!File.Exists(loadEnvFile)) + { + var sc = new StringBuilder(); + sc.AppendLine(@" +$envFile = 'env.json' +if ($TestMode -eq 'live') { + $envFile = 'localEnv.json' +} + +if (Test-Path -Path (Join-Path $PSScriptRoot $envFile)) { + $envFilePath = Join-Path $PSScriptRoot $envFile +} else { + $envFilePath = Join-Path $PSScriptRoot '..\$envFile' +} +$env = @{} +if (Test-Path -Path $envFilePath) { + $env = Get-Content (Join-Path $PSScriptRoot $envFile) | ConvertFrom-Json +}"); + File.WriteAllText(loadEnvFile, sc.ToString()); + }*/ + var utilFile = Path.Combine(OutputFolder, "utils.ps1"); + if (!File.Exists(utilFile)) + { + var sc = new StringBuilder(); + sc.AppendLine(@"function RandomString([bool]$allChars, [int32]$len) { if ($allChars) { return -join ((33..126) | Get-Random -Count $len | % {[char]$_}) } else { return -join ((48..57) + (97..122) | Get-Random -Count $len | % {[char]$_}) } } +function Start-TestSleep { + [CmdletBinding(DefaultParameterSetName = 'SleepBySeconds')] + param( + [parameter(Mandatory = $true, Position = 0, ParameterSetName = 'SleepBySeconds')] + [ValidateRange(0.0, 2147483.0)] + [double] $Seconds, + + [parameter(Mandatory = $true, ParameterSetName = 'SleepByMilliseconds')] + [ValidateRange('NonNegative')] + [Alias('ms')] + [int] $Milliseconds + ) + + if ($TestMode -ne 'playback') { + switch ($PSCmdlet.ParameterSetName) { + 'SleepBySeconds' { + Start-Sleep -Seconds $Seconds + } + 'SleepByMilliseconds' { + Start-Sleep -Milliseconds $Milliseconds + } + } + } +} + $env = @{} if ($UsePreviousConfigForRecord) { $previousEnv = Get-Content (Join-Path $PSScriptRoot 'env.json') | ConvertFrom-Json @@ -80,37 +126,40 @@ function cleanupEnv() { # Clean resources you create for testing } "); - File.WriteAllText(utilFile, sc.ToString()); - } - foreach (var exportDirectory in exportDirectories) - { - var outputFolder = OutputFolder; - if (exportDirectory != ExportsFolder) - { - outputFolder = Path.Combine(OutputFolder, Path.GetFileName(exportDirectory)); - Directory.CreateDirectory(outputFolder); - } - - var variantGroups = GetScriptCmdlets(exportDirectory) - .SelectMany(fi => fi.ToVariants()) - .Where(v => !v.IsDoNotExport) - .GroupBy(v => v.CmdletName) - .Select(vg => new VariantGroup(ModuleName, vg.Key, vg.Select(v => v).ToArray(), outputFolder, isTest: true)) - .Where(vtg => !File.Exists(vtg.FilePath) && (IncludeGenerated || !vtg.IsGenerated)); - - foreach (var variantGroup in variantGroups) - { - var sb = new StringBuilder(); - sb.AppendLine($"if(($null -eq $TestName) -or ($TestName -contains '{variantGroup.CmdletName}'))"); - sb.AppendLine(@"{ + File.WriteAllText(utilFile, sc.ToString()); + } + + + + foreach (var exportDirectory in exportDirectories) + { + var outputFolder = OutputFolder; + if (exportDirectory != ExportsFolder) + { + outputFolder = Path.Combine(OutputFolder, Path.GetFileName(exportDirectory)); + Directory.CreateDirectory(outputFolder); + } + + var variantGroups = GetScriptCmdlets(exportDirectory) + .SelectMany(fi => fi.ToVariants()) + .Where(v => !v.IsDoNotExport) + .GroupBy(v => v.CmdletName) + .Select(vg => new VariantGroup(ModuleName, vg.Key, vg.Select(v => v).ToArray(), outputFolder, isTest: true)) + .Where(vtg => !File.Exists(vtg.FilePath) && (IncludeGenerated || !vtg.IsGenerated)); + + foreach (var variantGroup in variantGroups) + { + var sb = new StringBuilder(); + sb.AppendLine($"if(($null -eq $TestName) -or ($TestName -contains '{variantGroup.CmdletName}'))"); + sb.AppendLine(@"{ $loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' if (-Not (Test-Path -Path $loadEnvPath)) { $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' } . ($loadEnvPath)" -); - sb.AppendLine($@" $TestRecordingFile = Join-Path $PSScriptRoot '{variantGroup.CmdletName}.Recording.json'"); - sb.AppendLine(@" $currentPath = $PSScriptRoot + ); + sb.AppendLine($@" $TestRecordingFile = Join-Path $PSScriptRoot '{variantGroup.CmdletName}.Recording.json'"); + sb.AppendLine(@" $currentPath = $PSScriptRoot while(-not $mockingPath) { $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File $currentPath = Split-Path -Path $currentPath -Parent @@ -120,29 +169,29 @@ function cleanupEnv() { "); - sb.AppendLine($"Describe '{variantGroup.CmdletName}' {{"); - var variants = variantGroup.Variants - .Where(v => IncludeGenerated || !v.Attributes.OfType().Any()) - .ToList(); + sb.AppendLine($"Describe '{variantGroup.CmdletName}' {{"); + var variants = variantGroup.Variants + .Where(v => IncludeGenerated || !v.Attributes.OfType().Any()) + .ToList(); - foreach (var variant in variants) + foreach (var variant in variants) + { + sb.AppendLine($"{Indent}It '{variant.VariantName}' -skip {{"); + sb.AppendLine($"{Indent}{Indent}{{ throw [System.NotImplementedException] }} | Should -Not -Throw"); + var variantSeparator = variants.IndexOf(variant) == variants.Count - 1 ? String.Empty : Environment.NewLine; + sb.AppendLine($"{Indent}}}{variantSeparator}"); + } + sb.AppendLine("}"); + + File.WriteAllText(variantGroup.FilePath, sb.ToString()); + } + } + } + catch (Exception ee) { - sb.AppendLine($"{Indent}It '{variant.VariantName}' -skip {{"); - sb.AppendLine($"{Indent}{Indent}{{ throw [System.NotImplementedException] }} | Should -Not -Throw"); - var variantSeparator = variants.IndexOf(variant) == variants.Count - 1 ? String.Empty : Environment.NewLine; - sb.AppendLine($"{Indent}}}{variantSeparator}"); + Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); + throw ee; } - sb.AppendLine("}"); - - File.WriteAllText(variantGroup.FilePath, sb.ToString()); - } } - } - catch (Exception ee) - { - Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); - throw ee; - } } - } } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/MarkdownRenderer.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/MarkdownRenderer.cs index d231e1a18b85..8c01c2ed9faa 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/MarkdownRenderer.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/MarkdownRenderer.cs @@ -94,7 +94,7 @@ public static void WriteMarkdowns(IEnumerable variantGroups, PsMod sb.Append($"## RELATED LINKS{Environment.NewLine}{Environment.NewLine}"); foreach (var relatedLink in markdownInfo.RelatedLinks) { - sb.Append($"{relatedLink}{Environment.NewLine}{Environment.NewLine}"); + sb.Append($"[{relatedLink}]({relatedLink}){Environment.NewLine}{Environment.NewLine}"); } File.WriteAllText(Path.Combine(docsFolder, $"{markdownInfo.CmdletName}.md"), sb.ToString()); diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsMarkdownTypes.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsMarkdownTypes.cs index 064eea33f1c5..be5dc21a8d8e 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsMarkdownTypes.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsMarkdownTypes.cs @@ -31,7 +31,7 @@ internal class MarkdownHelpInfo public string[] Inputs { get; } public string[] Outputs { get; } public ComplexInterfaceInfo[] ComplexInterfaceInfos { get; } - public string[] RelatedLinks { get; } + public MarkdownRelatedLinkInfo[] RelatedLinks { get; } public bool SupportsShouldProcess { get; } public bool SupportsPaging { get; } @@ -67,7 +67,11 @@ public MarkdownHelpInfo(VariantGroup variantGroup, string examplesFolder, string ComplexInterfaceInfos = variantGroup.ComplexInterfaceInfos; OnlineVersion = commentInfo.OnlineVersion; - RelatedLinks = commentInfo.RelatedLinks; + + var relatedLinkLists = new List(); + relatedLinkLists.AddRange(commentInfo.RelatedLinks?.Select(link => new MarkdownRelatedLinkInfo(link))); + relatedLinkLists.AddRange(variantGroup.Variants.SelectMany(v => v.Attributes).OfType()?.Distinct()?.Select(link => new MarkdownRelatedLinkInfo(link.Url, link.Description))); + RelatedLinks = relatedLinkLists?.ToArray(); SupportsShouldProcess = variantGroup.SupportsShouldProcess; SupportsPaging = variantGroup.SupportsPaging; @@ -218,14 +222,45 @@ public MarkdownParameterHelpInfo(PsParameterHelpInfo[] parameterHelpInfos, Param } } + internal class MarkdownRelatedLinkInfo + { + public string Url { get; } + public string Description { get; } + + public MarkdownRelatedLinkInfo(string url) + { + Url = url; + } + + public MarkdownRelatedLinkInfo(string url, string description) + { + Url = url; + Description = description; + } + + public override string ToString() + { + if (string.IsNullOrEmpty(Description)) + { + return Url; + } + else + { + return $@"[{Description}]({Url})"; + + } + + } + } + internal static class MarkdownTypesExtensions { public static MarkdownExampleHelpInfo ToExampleHelpInfo(this PsHelpExampleInfo exampleInfo) => new MarkdownExampleHelpInfo(exampleInfo.Title, exampleInfo.Code, exampleInfo.Output, exampleInfo.Remarks); public static MarkdownExampleHelpInfo[] DefaultExampleHelpInfos = { - new MarkdownExampleHelpInfo("Example 1: {{ Add title here }}", $@"{{{{ Add code here }}}}", $@"{{{{ Add output here }}}}", @"{{ Add description here }}"), - new MarkdownExampleHelpInfo("Example 2: {{ Add title here }}", $@"{{{{ Add code here }}}}", $@"{{{{ Add output here }}}}", @"{{ Add description here }}"), + new MarkdownExampleHelpInfo("Example 1: {{ Add title here }}", $@"{{{{ Add code here }}}}", $@"{{{{ Add output here (remove the output block if the example doesn't have an output) }}}}", @"{{ Add description here }}"), + new MarkdownExampleHelpInfo("Example 2: {{ Add title here }}", $@"{{{{ Add code here }}}}", $@"{{{{ Add output here (remove the output block if the example doesn't have an output) }}}}", @"{{ Add description here }}"), }; public static MarkdownParameterHelpInfo[] SupportsShouldProcessParameters = diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsProxyOutputs.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsProxyOutputs.cs index f55a24edfc6a..9961c61130ae 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsProxyOutputs.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsProxyOutputs.cs @@ -121,6 +121,21 @@ public override string ToString() => CompleterInfo != null : String.Empty; } + internal class PSArgumentCompleterOutput : ArgumentCompleterOutput + { + public PSArgumentCompleterInfo PSArgumentCompleterInfo { get; } + + public PSArgumentCompleterOutput(PSArgumentCompleterInfo completerInfo) : base(completerInfo) + { + PSArgumentCompleterInfo = completerInfo; + } + + + public override string ToString() => PSArgumentCompleterInfo != null + ? $"{Indent}[{typeof(PSArgumentCompleterAttribute)}({(PSArgumentCompleterInfo.IsTypeCompleter ? $"[{PSArgumentCompleterInfo.Type.Unwrap().ToPsType()}]" : $"{PSArgumentCompleterInfo.ResourceTypes?.Select(r => $"\"{r}\"")?.JoinIgnoreEmpty(", ")}")})]{Environment.NewLine}" + : String.Empty; + } + internal class DefaultInfoOutput { public bool HasDefaultInfo { get; } @@ -173,6 +188,7 @@ internal class BaseOutput public VariantGroup VariantGroup { get; } protected static readonly bool IsAzure = Convert.ToBoolean(@"true"); + public BaseOutput(VariantGroup variantGroup) { VariantGroup = variantGroup; @@ -200,6 +216,21 @@ public string GetProcessCustomAttributesAtRuntime() {Indent}{Indent}[Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)"; } + private string GetLoginVerification() + { + if (!VariantGroup.IsInternal && IsAzure && !VariantGroup.IsModelCmdlet) + { + return $@" +{Indent}{Indent}$context = Get-AzContext +{Indent}{Indent}if (-not $context -and -not $testPlayback) {{ +{Indent}{Indent}{Indent}Write-Error ""No Azure login detected. Please run 'Connect-AzAccount' to log in."" +{Indent}{Indent}{Indent}exit +{Indent}{Indent}}} +"; + } + return ""; + } + private string GetTelemetry() { if (!VariantGroup.IsInternal && IsAzure) @@ -232,10 +263,16 @@ public override string ToString() => $@"begin {{ {Indent}{Indent}{Indent}$PSBoundParameters['OutBuffer'] = 1 {Indent}{Indent}}} {Indent}{Indent}$parameterSet = $PSCmdlet.ParameterSetName -{GetTelemetry()} +{Indent}{Indent} +{Indent}{Indent}$testPlayback = $false +{Indent}{Indent}$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object {{ if ($_) {{ $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }} }} +{GetLoginVerification()}{GetTelemetry()} {GetParameterSetToCmdletMapping()}{GetDefaultValuesStatements()} {GetProcessCustomAttributesAtRuntime()} {Indent}{Indent}$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) +{Indent}{Indent}if ($wrappedCmd -eq $null) {{ +{Indent}{Indent}{Indent}$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) +{Indent}{Indent}}} {Indent}{Indent}$scriptCmd = {{& $wrappedCmd @PSBoundParameters}} {Indent}{Indent}$steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) {Indent}{Indent}$steppablePipeline.Begin($PSCmdlet) @@ -269,13 +306,16 @@ private string GetDefaultValuesStatements() var variantListString = defaultInfo.ParameterGroup.VariantNames.ToPsList(); var parameterName = defaultInfo.ParameterGroup.ParameterName; sb.AppendLine(); + var setCondition = " "; + if (!String.IsNullOrEmpty(defaultInfo.SetCondition)) + { + setCondition = $" -and {defaultInfo.SetCondition}"; + } //Yabo: this is bad to hard code the subscription id, but autorest load input README.md reversely (entry readme -> required readme), there are no other way to //override default value set in required readme if ("SubscriptionId".Equals(parameterName)) { - sb.AppendLine($"{Indent}{Indent}if (({variantListString}) -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('{parameterName}')) {{"); - sb.AppendLine($"{Indent}{Indent}{Indent}$testPlayback = $false"); - sb.AppendLine($"{Indent}{Indent}{Indent}$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object {{ if ($_) {{ $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }} }}"); + sb.AppendLine($"{Indent}{Indent}if (({variantListString}) -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('{parameterName}'){setCondition}) {{"); sb.AppendLine($"{Indent}{Indent}{Indent}if ($testPlayback) {{"); sb.AppendLine($"{Indent}{Indent}{Indent}{Indent}$PSBoundParameters['{parameterName}'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')"); sb.AppendLine($"{Indent}{Indent}{Indent}}} else {{"); @@ -285,13 +325,15 @@ private string GetDefaultValuesStatements() } else { - sb.AppendLine($"{Indent}{Indent}if (({variantListString}) -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('{parameterName}')) {{"); + sb.AppendLine($"{Indent}{Indent}if (({variantListString}) -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('{parameterName}'){setCondition}) {{"); sb.AppendLine($"{Indent}{Indent}{Indent}$PSBoundParameters['{parameterName}'] = {defaultInfo.Script}"); sb.Append($"{Indent}{Indent}}}"); } + } return sb.ToString(); } + } internal class ProcessOutput : BaseOutput @@ -381,6 +423,8 @@ public override string ToString() var notesText = !String.IsNullOrEmpty(notes) ? $"{Environment.NewLine}.Notes{Environment.NewLine}{ComplexParameterHeader}{notes}" : String.Empty; var relatedLinks = String.Join(Environment.NewLine, CommentInfo.RelatedLinks.Select(l => $".Link{Environment.NewLine}{l}")); var relatedLinksText = !String.IsNullOrEmpty(relatedLinks) ? $"{Environment.NewLine}{relatedLinks}" : String.Empty; + var externalUrls = String.Join(Environment.NewLine, CommentInfo.ExternalUrls.Select(l => $".Link{Environment.NewLine}{l}")); + var externalUrlsText = !String.IsNullOrEmpty(externalUrls) ? $"{Environment.NewLine}{externalUrls}" : String.Empty; var examples = ""; foreach (var example in VariantGroup.HelpInfo.Examples) { @@ -393,7 +437,7 @@ public override string ToString() {CommentInfo.Description.ToDescriptionFormat(false)} {examples}{inputsText}{outputsText}{notesText} .Link -{CommentInfo.OnlineVersion}{relatedLinksText} +{CommentInfo.OnlineVersion}{relatedLinksText}{externalUrlsText} #> "; } @@ -587,7 +631,9 @@ public static string ToSyntaxTypeName(this Type type) public static AllowEmptyArrayOutput ToAllowEmptyArray(this bool hasAllowEmptyArray) => new AllowEmptyArrayOutput(hasAllowEmptyArray); - public static ArgumentCompleterOutput ToArgumentCompleterOutput(this CompleterInfo completerInfo) => new ArgumentCompleterOutput(completerInfo); + public static ArgumentCompleterOutput ToArgumentCompleterOutput(this CompleterInfo completerInfo) => (completerInfo is PSArgumentCompleterInfo psArgumentCompleterInfo) ? psArgumentCompleterInfo.ToArgumentCompleterOutput() : new ArgumentCompleterOutput(completerInfo); + + public static PSArgumentCompleterOutput ToArgumentCompleterOutput(this PSArgumentCompleterInfo completerInfo) => new PSArgumentCompleterOutput(completerInfo); public static DefaultInfoOutput ToDefaultInfoOutput(this ParameterGroup parameterGroup) => new DefaultInfoOutput(parameterGroup); diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsProxyTypes.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsProxyTypes.cs index 557ff473bf87..171fb8a62bc9 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsProxyTypes.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/Models/PsProxyTypes.cs @@ -31,7 +31,7 @@ internal class VariantGroup { public string ModuleName { get; } - public string RootModuleName {get => @"";} + public string RootModuleName { get => @""; } public string CmdletName { get; } public string CmdletVerb { get; } public string CmdletNoun { get; } @@ -49,7 +49,7 @@ internal class VariantGroup public PsHelpInfo HelpInfo { get; } public bool IsGenerated { get; } public bool IsInternal { get; } - + public bool IsModelCmdlet { get; } public string OutputFolder { get; } public string FileName { get; } public string FilePath { get; } @@ -84,7 +84,7 @@ public VariantGroup(string moduleName, string cmdletName, Variant[] variants, st HelpInfo = Variants.Select(v => v.HelpInfo).FirstOrDefault() ?? new PsHelpInfo(); IsGenerated = Variants.All(v => v.Attributes.OfType().Any()); IsInternal = isInternal; - + IsModelCmdlet = Variants.All(v => v.IsModelCmdlet); OutputFolder = outputFolder; FileName = $"{CmdletName}{(isTest ? ".Tests" : String.Empty)}.ps1"; FilePath = Path.Combine(OutputFolder, FileName); @@ -101,12 +101,23 @@ private string DetermineDefaultParameterSetName() if (String.IsNullOrEmpty(defaultParameterSet)) { var variantParamCountGroups = Variants + .Where(v => !v.IsNotSuggestDefaultParameterSet) .Select(v => ( variant: v.VariantName, paramCount: v.CmdletOnlyParameters.Count(p => p.IsMandatory), isSimple: v.CmdletOnlyParameters.Where(p => p.IsMandatory).All(p => p.ParameterType.IsPsSimple()))) .GroupBy(vpc => vpc.isSimple) .ToArray(); + if (variantParamCountGroups.Length == 0) + { + variantParamCountGroups = Variants + .Select(v => ( + variant: v.VariantName, + paramCount: v.CmdletOnlyParameters.Count(p => p.IsMandatory), + isSimple: v.CmdletOnlyParameters.Where(p => p.IsMandatory).All(p => p.ParameterType.IsPsSimple()))) + .GroupBy(vpc => vpc.isSimple) + .ToArray(); + } var variantParameterCounts = (variantParamCountGroups.Any(g => g.Key) ? variantParamCountGroups.Where(g => g.Key) : variantParamCountGroups).SelectMany(g => g).ToArray(); var smallestParameterCount = variantParameterCounts.Min(vpc => vpc.paramCount); defaultParameterSet = variantParameterCounts.First(vpc => vpc.paramCount == smallestParameterCount).variant; @@ -134,7 +145,9 @@ internal class Variant public Parameter[] Parameters { get; } public Parameter[] CmdletOnlyParameters { get; } public bool IsInternal { get; } + public bool IsModelCmdlet { get; } public bool IsDoNotExport { get; } + public bool IsNotSuggestDefaultParameterSet { get; } public string[] Profiles { get; } public Variant(string cmdletName, string variantName, CommandInfo info, CommandMetadata metadata, bool hasParameterSets = false, PsHelpInfo helpInfo = null) @@ -155,6 +168,8 @@ public Variant(string cmdletName, string variantName, CommandInfo info, CommandM Parameters = this.ToParameters().OrderBy(p => p.OrderCategory).ThenByDescending(p => p.IsMandatory).ToArray(); IsInternal = Attributes.OfType().Any(); IsDoNotExport = Attributes.OfType().Any(); + IsModelCmdlet = Attributes.OfType().Any(); + IsNotSuggestDefaultParameterSet = Attributes.OfType().Any(); CmdletOnlyParameters = Parameters.Where(p => !p.Categories.Any(c => c == ParameterCategory.Azure || c == ParameterCategory.Runtime)).ToArray(); Profiles = Attributes.OfType().SelectMany(pa => pa.Profiles).ToArray(); } @@ -210,6 +225,7 @@ public ParameterGroup(string parameterName, Parameter[] parameters, string[] all HasValidateNotNull = Parameters.SelectMany(p => p.Attributes.OfType()).Any(); HasAllowEmptyArray = Parameters.SelectMany(p => p.Attributes.OfType()).Any(); CompleterInfo = Parameters.Select(p => p.CompleterInfoAttribute).FirstOrDefault()?.ToCompleterInfo() + ?? Parameters.Select(p => p.PSArgumentCompleterAttribute).FirstOrDefault()?.ToPSArgumentCompleterInfo() ?? Parameters.Select(p => p.ArgumentCompleterAttribute).FirstOrDefault()?.ToCompleterInfo(); DefaultInfo = Parameters.Select(p => p.DefaultInfoAttribute).FirstOrDefault()?.ToDefaultInfo(this) ?? Parameters.Select(p => p.DefaultValueAttribute).FirstOrDefault(dv => dv != null)?.ToDefaultInfo(this); @@ -244,7 +260,6 @@ internal class Parameter public ParameterMetadata Metadata { get; } public PsParameterHelpInfo HelpInfo { get; } public Type ParameterType { get; } - public Attribute[] Attributes { get; } public ParameterCategory[] Categories { get; } public ParameterCategory OrderCategory { get; } @@ -254,6 +269,7 @@ internal class Parameter public bool SupportsWildcards { get; } public CompleterInfoAttribute CompleterInfoAttribute { get; } public ArgumentCompleterAttribute ArgumentCompleterAttribute { get; } + public PSArgumentCompleterAttribute PSArgumentCompleterAttribute { get; } public bool ValueFromPipeline { get; } public bool ValueFromPipelineByPropertyName { get; } @@ -286,7 +302,8 @@ public Parameter(string variantName, string parameterName, ParameterMetadata met } SupportsWildcards = Attributes.OfType().Any(); CompleterInfoAttribute = Attributes.OfType().FirstOrDefault(); - ArgumentCompleterAttribute = Attributes.OfType().FirstOrDefault(); + PSArgumentCompleterAttribute = Attributes.OfType().FirstOrDefault(); + ArgumentCompleterAttribute = Attributes.OfType().FirstOrDefault(attr => !attr.GetType().Equals(typeof(PSArgumentCompleterAttribute))); ValueFromPipeline = ParameterAttribute.ValueFromPipeline; ValueFromPipelineByPropertyName = ParameterAttribute.ValueFromPipelineByPropertyName; @@ -295,10 +312,10 @@ public Parameter(string variantName, string parameterName, ParameterMetadata met IsMandatory = ParameterAttribute.Mandatory; var complexParameterName = ParameterName.ToUpperInvariant(); - var complexMessage = $"{Environment.NewLine}To construct, see NOTES section for {complexParameterName} properties and create a hash table."; + var complexMessage = $"{Environment.NewLine}"; var description = ParameterAttribute.HelpMessage.NullIfEmpty() ?? HelpInfo.Description.NullIfEmpty() ?? InfoAttribute?.Description.NullIfEmpty() ?? String.Empty; // Remove the complex type message as it will be reinserted if this is a complex type - description = description.NormalizeNewLines().Replace(complexMessage, String.Empty).Replace(complexMessage.ToPsSingleLine(), String.Empty); + description = description.NormalizeNewLines(); // Make an InfoAttribute for processing only if one isn't provided InfoAttribute = Attributes.OfType().FirstOrDefault() ?? new InfoAttribute { PossibleTypes = new[] { ParameterType.Unwrap() }, Required = IsMandatory }; // Set the description if the InfoAttribute does not have one since they are exported without a description @@ -318,7 +335,7 @@ internal class ComplexInterfaceInfo public bool Required { get; } public bool ReadOnly { get; } public string Description { get; } - + public ComplexInterfaceInfo[] NestedInfos { get; } public bool IsComplexInterface { get; } @@ -335,7 +352,7 @@ public ComplexInterfaceInfo(string name, Type type, InfoAttribute infoAttribute, var unwrappedType = Type.Unwrap(); var hasBeenSeen = seenTypes?.Contains(unwrappedType) ?? false; (seenTypes ?? (seenTypes = new List())).Add(unwrappedType); - NestedInfos = hasBeenSeen ? new ComplexInterfaceInfo[]{} : + NestedInfos = hasBeenSeen ? new ComplexInterfaceInfo[] { } : unwrappedType.GetInterfaces() .Concat(InfoAttribute.PossibleTypes) .SelectMany(pt => pt.GetProperties() @@ -366,6 +383,7 @@ internal class CommentInfo public string OnlineVersion { get; } public string[] RelatedLinks { get; } + public string[] ExternalUrls { get; } private const string HelpLinkPrefix = @"https://learn.microsoft.com/powershell/module/"; @@ -391,6 +409,9 @@ public CommentInfo(VariantGroup variantGroup) var moduleName = variantGroup.RootModuleName == "" ? variantGroup.ModuleName.ToLowerInvariant() : variantGroup.RootModuleName.ToLowerInvariant(); OnlineVersion = helpInfo.OnlineVersion?.Uri.NullIfEmpty() ?? $@"{HelpLinkPrefix}{moduleName}/{variantGroup.CmdletName.ToLowerInvariant()}"; RelatedLinks = helpInfo.RelatedLinks.Select(rl => rl.Text).ToArray(); + + // Get external urls from attribute + ExternalUrls = variantGroup.Variants.SelectMany(v => v.Attributes).OfType()?.Select(e => e.Url)?.Distinct()?.ToArray(); } } @@ -420,11 +441,22 @@ public CompleterInfo(ArgumentCompleterAttribute completerAttribute) } } + internal class PSArgumentCompleterInfo : CompleterInfo + { + public string[] ResourceTypes { get; } + + public PSArgumentCompleterInfo(PSArgumentCompleterAttribute completerAttribute) : base(completerAttribute) + { + ResourceTypes = completerAttribute.ResourceTypes; + } + } + internal class DefaultInfo { public string Name { get; } public string Description { get; } public string Script { get; } + public string SetCondition { get; } public ParameterGroup ParameterGroup { get; } public DefaultInfo(DefaultInfoAttribute infoAttribute, ParameterGroup parameterGroup) @@ -432,6 +464,7 @@ public DefaultInfo(DefaultInfoAttribute infoAttribute, ParameterGroup parameterG Name = infoAttribute.Name; Description = infoAttribute.Description; Script = infoAttribute.Script; + SetCondition = infoAttribute.SetCondition; ParameterGroup = parameterGroup; } @@ -479,7 +512,8 @@ public static Parameter[] ToParameters(this Variant variant) parameterHelp = parameterHelp.Where(ph => (!ph.ParameterSetNames.Any() || ph.ParameterSetNames.Any(psn => psn == variant.VariantName || psn == AllParameterSets)) && ph.Name != "IncludeTotalCount"); } var result = parameters.Select(p => new Parameter(variant.VariantName, p.Key, p.Value, parameterHelp.FirstOrDefault(ph => ph.Name == p.Key))); - if (variant.SupportsPaging) { + if (variant.SupportsPaging) + { // If supportsPaging is set, we will need to add First and Skip parameters since they are treated as common parameters which as not contained on Metadata>parameters variant.Info.Parameters["First"].Attributes.OfType().FirstOrDefault(pa => pa.ParameterSetName == variant.VariantName || pa.ParameterSetName == AllParameterSets).HelpMessage = "Gets only the first 'n' objects."; variant.Info.Parameters["Skip"].Attributes.OfType().FirstOrDefault(pa => pa.ParameterSetName == variant.VariantName || pa.ParameterSetName == AllParameterSets).HelpMessage = "Ignores the first 'n' objects and then gets the remaining objects."; @@ -507,7 +541,7 @@ public static ComplexInterfaceInfo ToComplexInterfaceInfo(this InfoAttribute inf public static CompleterInfo ToCompleterInfo(this CompleterInfoAttribute infoAttribute) => new CompleterInfo(infoAttribute); public static CompleterInfo ToCompleterInfo(this ArgumentCompleterAttribute completerAttribute) => new CompleterInfo(completerAttribute); - + public static PSArgumentCompleterInfo ToPSArgumentCompleterInfo(this PSArgumentCompleterAttribute completerAttribute) => new PSArgumentCompleterInfo(completerAttribute); public static DefaultInfo ToDefaultInfo(this DefaultInfoAttribute infoAttribute, ParameterGroup parameterGroup) => new DefaultInfo(infoAttribute, parameterGroup); public static DefaultInfo ToDefaultInfo(this PSDefaultValueAttribute defaultValueAttribute, ParameterGroup parameterGroup) => new DefaultInfo(defaultValueAttribute, parameterGroup); } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsAttributes.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsAttributes.cs index 1587e021ebfb..7172aa92eafa 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsAttributes.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsAttributes.cs @@ -22,6 +22,11 @@ public class DoNotExportAttribute : Attribute { } + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)] + public class ModelCmdletAttribute : Attribute + { + } + [AttributeUsage(AttributeTargets.Class)] public class InternalExportAttribute : Attribute { @@ -55,6 +60,11 @@ public class HttpPathAttribute : Attribute public string ApiVersion { get; set; } } + [AttributeUsage(AttributeTargets.Class)] + public class NotSuggestDefaultParameterSetAttribute : Attribute + { + } + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] public class CategoryAttribute : Attribute { @@ -109,6 +119,11 @@ public enum PropertyOrigin Inlined } + [AttributeUsage(AttributeTargets.Property)] + public class ConstantAttribute : Attribute + { + } + [AttributeUsage(AttributeTargets.Property)] public class FormatTableAttribute : Attribute { diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsExtensions.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsExtensions.cs index 7e98d42be148..3e277c497fa5 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsExtensions.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsExtensions.cs @@ -13,6 +13,13 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PowerShell { internal static class PsExtensions { + public static PSObject AddMultipleTypeNameIntoPSObject(this object obj, string multipleTag = "#Multiple") + { + var psObj = new PSObject(obj); + psObj.TypeNames.Insert(0, $"{psObj.TypeNames[0]}{multipleTag}"); + return psObj; + } + // https://stackoverflow.com/a/863944/294804 // https://stackoverflow.com/a/4452598/294804 // https://stackoverflow.com/a/28701974/294804 diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsHelpers.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsHelpers.cs index 82bf2eaaf7b3..f548ce2fc0aa 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsHelpers.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/BuildTime/PsHelpers.cs @@ -67,7 +67,7 @@ public static IEnumerable GetScriptHelpInfo(params string[] modulePath public static IEnumerable GetModuleCmdletsAndHelpInfo(PSCmdlet cmdlet, params string[] modulePaths) { - var getCmdletAndHelp = String.Join(" + ", modulePaths.Select(mp => + var getCmdletAndHelp = String.Join(" + ", modulePaths.Select(mp => $@"(Get-Command -Module (Import-Module '{mp}' -PassThru) | Where-Object {{ $_.CommandType -ne 'Alias' }} | ForEach-Object {{ @{{ CommandInfo = $_; HelpInfo = ( invoke-command {{ try {{ Get-Help -Name $_.Name -Full }} catch{{ '' }} }} ) }} }})" )); return (cmdlet?.RunScript(getCmdletAndHelp) ?? RunScript(getCmdletAndHelp)) @@ -88,7 +88,7 @@ public static Guid ReadGuidFromPsd1(string psd1Path) if (File.Exists(psd1Path)) { var currentGuid = File.ReadAllLines(psd1Path) - .FirstOrDefault(l => l.StartsWith(GuidStart))?.Split(new[] { " = " }, StringSplitOptions.RemoveEmptyEntries) + .FirstOrDefault(l => l.TrimStart().StartsWith(GuidStart.TrimStart()))?.Split(new[] { " = " }, StringSplitOptions.RemoveEmptyEntries) .LastOrDefault()?.Replace("'", String.Empty); guid = currentGuid != null ? Guid.Parse(currentGuid) : guid; } diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Context.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Context.cs new file mode 100644 index 000000000000..9a82ea335e5f --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Context.cs @@ -0,0 +1,33 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime +{ + + using System; + using System.Linq; + using System.Collections; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using GetEventData = System.Func; + using static Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Extensions; + + /// + /// The IContext Interface defines the communication mechanism for input customization. + /// + /// + /// In the context, we will have client, pipeline, PSBoundParamters, default EventListener, Cancellation. + /// + public interface IContext + { + System.Management.Automation.InvocationInfo InvocationInformation { get; set; } + System.Threading.CancellationTokenSource CancellationTokenSource { get; set; } + System.Collections.Generic.IDictionary ExtensibleParameters { get; } + HttpPipeline Pipeline { get; set; } + Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.CustomProviders Client { get; } + } +} diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Events.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Events.cs index de2e19d650c9..879c8df8499c 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Events.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Events.cs @@ -22,6 +22,6 @@ public static partial class Events public const string FollowingNextLink = nameof(FollowingNextLink); public const string DelayBeforePolling = nameof(DelayBeforePolling); public const string Polling = nameof(Polling); - + public const string Progress = nameof(Progress); } -} \ No newline at end of file +} diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/ISendAsync.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/ISendAsync.cs index 666724b69b89..5ec449080a7e 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/ISendAsync.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/ISendAsync.cs @@ -11,6 +11,8 @@ namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime using System.Threading.Tasks; using System.Collections; using System.Linq; + using System; + /// /// The interface for sending an HTTP request across the wire. @@ -70,6 +72,7 @@ public interface ISendAsyncTerminalFactory public partial class HttpPipeline : ISendAsync { + private const int DefaultMaxRetry = 3; private ISendAsync pipeline; private ISendAsyncTerminalFactory terminal; private List steps = new List(); @@ -92,6 +95,111 @@ public HttpPipeline(ISendAsyncTerminalFactory terminalStep) /// public HttpPipeline Clone() => new HttpPipeline(terminal) { steps = this.steps.ToList(), pipeline = this.pipeline }; + private bool shouldRetry429(HttpResponseMessage response) + { + if (response.StatusCode == (System.Net.HttpStatusCode)429) + { + var retryAfter = response.Headers.RetryAfter; + if (retryAfter != null && retryAfter.Delta.HasValue) + { + return true; + } + } + return false; + } + /// + /// The step to handle 429 response with retry-after header. + /// + public async Task Retry429(HttpRequestMessage request, IEventListener callback, ISendAsync next) + { + int retryCount = int.MaxValue; + + try + { + try + { + retryCount = int.Parse(System.Environment.GetEnvironmentVariable("PS_HTTP_MAX_RETRIES_FOR_429")); + } + finally + { + retryCount = int.Parse(System.Environment.GetEnvironmentVariable("AZURE_PS_HTTP_MAX_RETRIES_FOR_429")); + } + } + catch (System.Exception) + { + //no action + } + var cloneRequest = await request.CloneWithContent(); + var response = await next.SendAsync(request, callback); + int count = 0; + while (shouldRetry429(response) && count++ < retryCount) + { + request = await cloneRequest.CloneWithContent(); + var retryAfter = response.Headers.RetryAfter; + await Task.Delay(retryAfter.Delta.Value, callback.Token); + await callback.Signal("Debug", $"Start to retry {count} time(s) on status code 429 after waiting {retryAfter.Delta.Value.TotalSeconds} seconds."); + response = await next.SendAsync(request, callback); + } + return response; + } + + private bool shouldRetryError(HttpResponseMessage response) + { + if (response.StatusCode >= System.Net.HttpStatusCode.InternalServerError) + { + if (response.StatusCode != System.Net.HttpStatusCode.NotImplemented && + response.StatusCode != System.Net.HttpStatusCode.HttpVersionNotSupported) + { + return true; + } + } + else if (response.StatusCode == System.Net.HttpStatusCode.RequestTimeout) + { + return true; + } + else if (response.StatusCode == (System.Net.HttpStatusCode)429 && response.Headers.RetryAfter == null) + { + return true; + } + return false; + } + + /// + /// Returns true if status code in HttpRequestExceptionWithStatus exception is greater + /// than or equal to 500 and not NotImplemented (501) or HttpVersionNotSupported (505). + /// Or it's 429 (TOO MANY REQUESTS) without Retry-After header. + /// + public async Task RetryError(HttpRequestMessage request, IEventListener callback, ISendAsync next) + { + int retryCount = DefaultMaxRetry; + + try + { + try + { + retryCount = int.Parse(System.Environment.GetEnvironmentVariable("PS_HTTP_MAX_RETRIES")); + } + finally + { + retryCount = int.Parse(System.Environment.GetEnvironmentVariable("AZURE_PS_HTTP_MAX_RETRIES")); + } + } + catch (System.Exception) + { + //no action + } + var cloneRequest = await request.CloneWithContent(); + var response = await next.SendAsync(request, callback); + int count = 0; + while (shouldRetryError(response) && count++ < retryCount) + { + await callback.Signal("Debug", $"Start to retry {count} time(s) on status code {response.StatusCode}"); + request = await cloneRequest.CloneWithContent(); + response = await next.SendAsync(request, callback); + } + return response; + } + public ISendAsyncTerminalFactory TerminalFactory { get => terminal; @@ -117,6 +225,11 @@ public ISendAsync Pipeline // create the pipeline from scratch. var next = terminal.Create(); + if (Convert.ToBoolean(@"true")) + { + next = (new SendAsyncFactory(Retry429)).Create(next) ?? next; + next = (new SendAsyncFactory(RetryError)).Create(next) ?? next; + } foreach (var factory in steps) { // skip factories that return null. diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/InfoAttribute.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/InfoAttribute.cs index 29409ef80348..4e06986c2dc7 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/InfoAttribute.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/InfoAttribute.cs @@ -11,6 +11,9 @@ public class InfoAttribute : Attribute { public bool Required { get; set; } = false; public bool ReadOnly { get; set; } = false; + public bool Read { get; set; } = true; + public bool Create { get; set; } = true; + public bool Update { get; set; } = true; public Type[] PossibleTypes { get; set; } = new Type[0]; public string Description { get; set; } = ""; public string SerializedName { get; set; } = ""; @@ -30,5 +33,6 @@ public class DefaultInfoAttribute : Attribute public string Script { get; set; } = ""; public string Name { get; set; } = ""; public string Description { get; set; } = ""; + public string SetCondition { get; set; } = ""; } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/InputHandler.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/InputHandler.cs new file mode 100644 index 000000000000..115100c48fff --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/InputHandler.cs @@ -0,0 +1,22 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +using System; +using System.Collections.Generic; + +namespace Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.Cmdlets +{ + public abstract class InputHandler + { + protected InputHandler NextHandler = null; + + public void SetNextHandler(InputHandler nextHandler) + { + this.NextHandler = nextHandler; + } + + public abstract void Process(Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.IContext context); + } +} \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Nodes/Collections/XNodeArray.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Nodes/Collections/XNodeArray.cs index 8b6358041351..b5798cf43332 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Nodes/Collections/XNodeArray.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/Nodes/Collections/XNodeArray.cs @@ -21,6 +21,11 @@ internal XNodeArray(params JsonNode[] values) items = new List(values); } + internal XNodeArray(System.Collections.Generic.List values) + { + items = new List(values); + } + public override JsonNode this[int index] => items[index]; internal override JsonType? ElementType => null; diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/SerializationMode.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/SerializationMode.cs index 2b5aef4cb7f3..dced0a4e6c36 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/SerializationMode.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/SerializationMode.cs @@ -9,8 +9,10 @@ public enum SerializationMode { None = 0, IncludeHeaders = 1 << 0, - IncludeReadOnly = 1 << 1, - - IncludeAll = IncludeHeaders | IncludeReadOnly + IncludeRead = 1 << 1, + IncludeCreate = 1 << 2, + IncludeUpdate = 1 << 3, + IncludeAll = IncludeHeaders | IncludeRead | IncludeCreate | IncludeUpdate, + IncludeCreateOrUpdate = IncludeCreate | IncludeUpdate } } \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/TypeConverterExtensions.cs b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/TypeConverterExtensions.cs index e7c9433565f2..c5e0512d6ce6 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/TypeConverterExtensions.cs +++ b/generated/CustomProviders/CustomProviders.Autorest/generated/runtime/TypeConverterExtensions.cs @@ -62,6 +62,56 @@ internal static T[] SelectToArray(object source, System.Func return result.ToArray(); } + internal static System.Collections.Generic.List SelectToList(object source, System.Func converter) + { + // null begets null + if (source == null) + { + return null; + } + + // single values and strings are just encapsulated in the array. + if (source is string || !(source is System.Collections.IEnumerable)) + { + try + { + return new T[] { (T)converter(source) }.ToList(); + } +#if DEBUG + catch (System.Exception E) + { + System.Console.Error.WriteLine($"{E.GetType().Name}/{E.Message}/{E.StackTrace}"); + } +#else + catch + { + // silent conversion fail + } +#endif + return new T[0].ToList(); // empty result if couldn't convert. + } + + var result = new System.Collections.Generic.List(); + foreach (var each in (System.Collections.IEnumerable)source) + { + try + { + result.Add((T)converter(each)); + } +#if DEBUG + catch (System.Exception E) + { + System.Console.Error.WriteLine($"{E.GetType().Name}/{E.Message}/{E.StackTrace}"); + } +#else + catch + { + // silent conversion fail + } +#endif + } + return result; + } internal static System.Collections.Generic.IEnumerable GetPropertyKeys(this System.Collections.Generic.IDictionary dictionary) { if (null != dictionary) diff --git a/generated/CustomProviders/CustomProviders.Autorest/internal/Get-AzOperation.ps1 b/generated/CustomProviders/CustomProviders.Autorest/internal/Get-AzOperation.ps1 index acbf59607483..9ef106dff617 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/internal/Get-AzOperation.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/internal/Get-AzOperation.ps1 @@ -25,12 +25,12 @@ The list of operations provided by Microsoft CustomProviders. {{ Add code here }} .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation .Link https://learn.microsoft.com/powershell/module/az.customproviders/get-azoperation #> function Get-AzOperation { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation])] [CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] param( [Parameter()] @@ -89,12 +89,18 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } $mapping = @{ List = 'Az.CustomProviders.private\Get-AzOperation_List'; } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/internal/ProxyCmdletDefinitions.ps1 b/generated/CustomProviders/CustomProviders.Autorest/internal/ProxyCmdletDefinitions.ps1 index acbf59607483..9ef106dff617 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/internal/ProxyCmdletDefinitions.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/internal/ProxyCmdletDefinitions.ps1 @@ -25,12 +25,12 @@ The list of operations provided by Microsoft CustomProviders. {{ Add code here }} .Outputs -Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation +Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation .Link https://learn.microsoft.com/powershell/module/az.customproviders/get-azoperation #> function Get-AzOperation { -[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.IResourceProviderOperation])] +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.IResourceProviderOperation])] [CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] param( [Parameter()] @@ -89,12 +89,18 @@ begin { $PSBoundParameters['OutBuffer'] = 1 } $parameterSet = $PSCmdlet.ParameterSetName + + $testPlayback = $false + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } $mapping = @{ List = 'Az.CustomProviders.private\Get-AzOperation_List'; } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) + if ($wrappedCmd -eq $null) { + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) + } $scriptCmd = {& $wrappedCmd @PSBoundParameters} $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) diff --git a/generated/CustomProviders/CustomProviders.Autorest/resources/README.md b/generated/CustomProviders/CustomProviders.Autorest/resources/README.md new file mode 100644 index 000000000000..937f07f8fec2 --- /dev/null +++ b/generated/CustomProviders/CustomProviders.Autorest/resources/README.md @@ -0,0 +1,11 @@ +# Resources +This directory can contain any additional resources for module that are not required at runtime. This directory **does not** get packaged with the module. If you have assets for custom implementation, place them into the `..\custom` folder. + +## Info +- Modifiable: yes +- Generated: no +- Committed: yes +- Packaged: no + +## Purpose +Use this folder to put anything you want to keep around as part of the repository for the module, but is not something that is required for the module. For example, development files, packaged builds, or additional information. This is only intended to be used in repositories where the module's output directory is cleaned, but tangential resources for the module want to remain intact. \ No newline at end of file diff --git a/generated/CustomProviders/CustomProviders.Autorest/test-module.ps1 b/generated/CustomProviders/CustomProviders.Autorest/test-module.ps1 index 3edafe561abc..6d676890012a 100644 --- a/generated/CustomProviders/CustomProviders.Autorest/test-module.ps1 +++ b/generated/CustomProviders/CustomProviders.Autorest/test-module.ps1 @@ -12,17 +12,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code # is regenerated. # ---------------------------------------------------------------------------------- -param([switch]$Isolated, [switch]$Live, [switch]$Record, [switch]$Playback, [switch]$RegenerateSupportModule, [switch]$UsePreviousConfigForRecord, [string[]]$TestName) +param([switch]$NotIsolated, [switch]$Live, [switch]$Record, [switch]$Playback, [switch]$RegenerateSupportModule, [switch]$UsePreviousConfigForRecord, [string[]]$TestName) $ErrorActionPreference = 'Stop' -if(-not $Isolated) +if(-not $NotIsolated) { Write-Host -ForegroundColor Green 'Creating isolated process...' if ($PSBoundParameters.ContainsKey("TestName")) { $PSBoundParameters["TestName"] = $PSBoundParameters["TestName"] -join "," } $pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path - & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated + & "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -NotIsolated return } @@ -34,7 +34,7 @@ if ($PSBoundParameters.ContainsKey("TestName") -and ($TestName.count -eq 1) -and $ProgressPreference = 'SilentlyContinue' $baseName = $PSScriptRoot.BaseName $requireResourceModule = (($baseName -ne "Resources") -and ($Record.IsPresent -or $Live.IsPresent)) -. (Join-Path $PSScriptRoot 'check-dependencies.ps1') -Isolated -Accounts:$false -Pester -Resources:$requireResourceModule -RegenerateSupportModule:$RegenerateSupportModule +. (Join-Path $PSScriptRoot 'check-dependencies.ps1') -NotIsolated -Accounts:$false -Pester -Resources:$requireResourceModule -RegenerateSupportModule:$RegenerateSupportModule . ("$PSScriptRoot\test\utils.ps1") if ($requireResourceModule) @@ -95,4 +95,4 @@ try } } -Write-Host -ForegroundColor Green '-------------Done-------------' \ No newline at end of file +Write-Host -ForegroundColor Green '-------------Done-------------'