diff --git a/eng/packages/http-client-csharp-mgmt/eng/scripts/Generate.ps1 b/eng/packages/http-client-csharp-mgmt/eng/scripts/Generate.ps1 index 69297ce9b26b..dc8c244e6a21 100755 --- a/eng/packages/http-client-csharp-mgmt/eng/scripts/Generate.ps1 +++ b/eng/packages/http-client-csharp-mgmt/eng/scripts/Generate.ps1 @@ -7,9 +7,10 @@ param( ) Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force; +Import-Module "$PSScriptRoot\Spector-Helper.psm1" -DisableNameChecking -Force; $mgmtPackageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..') -Write-Host "Mgmt Package root: $packageRoot" -ForegroundColor Cyan +Write-Host "Mgmt Package root: $mgmtPackageRoot" -ForegroundColor Cyan $mgmtSolutionDir = Join-Path $mgmtPackageRoot 'generator' if (-not $LaunchOnly) { @@ -38,6 +39,43 @@ if (-not $LaunchOnly) { } } +$spectorRoot = Join-Path $mgmtPackageRoot 'generator' 'TestProjects' 'Spector' + +$spectorLaunchProjects = @{} + +foreach ($specFile in Get-Sorted-Specs) { + $subPath = Get-SubPath $specFile + $folders = $subPath.Split([System.IO.Path]::DirectorySeparatorChar) + + if (-not (Compare-Paths $subPath $filter)) { + continue + } + + $generationDir = $spectorRoot + foreach ($folder in $folders) { + $generationDir = Join-Path $generationDir $folder + } + + # create the directory if it doesn't exist + if (-not (Test-Path $generationDir)) { + New-Item -ItemType Directory -Path $generationDir | Out-Null + } + + Write-Host "Generating $subPath" -ForegroundColor Cyan + + $spectorLaunchProjects.Add(($folders -join "-"), ("TestProjects/Spector/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))")) + if ($LaunchOnly) { + continue + } + + Invoke (Get-Mgmt-TspCommand $specFile $generationDir -debug:$Debug) + + # exit if the generation failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } +} + # only write new launch settings if no filter was passed in if ($null -eq $filter) { $mgmtSpec = "TestProjects/Local/Mgmt-TypeSpec" @@ -50,6 +88,13 @@ if ($null -eq $filter) { $mgmtLaunchSettings["profiles"]["Mgmt-TypeSpec"].Add("commandName", "Executable") $mgmtLaunchSettings["profiles"]["Mgmt-TypeSpec"].Add("executablePath", "dotnet") + foreach ($kvp in $spectorLaunchProjects.GetEnumerator()) { + $mgmtLaunchSettings["profiles"].Add($kvp.Key, @{}) + $mgmtLaunchSettings["profiles"][$kvp.Key].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll `$(SolutionDir)/$($kvp.Value) -g AzureStubGenerator") + $mgmtLaunchSettings["profiles"][$kvp.Key].Add("commandName", "Executable") + $mgmtLaunchSettings["profiles"][$kvp.Key].Add("executablePath", "dotnet") + } + $mgmtSortedLaunchSettings = @{} $mgmtSortedLaunchSettings.Add("profiles", [ordered]@{}) $mgmtLaunchSettings["profiles"].Keys | Sort-Object | ForEach-Object { diff --git a/eng/packages/http-client-csharp-mgmt/eng/scripts/Spector-Helper.psm1 b/eng/packages/http-client-csharp-mgmt/eng/scripts/Spector-Helper.psm1 new file mode 100644 index 000000000000..deb579f500db --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/eng/scripts/Spector-Helper.psm1 @@ -0,0 +1,115 @@ +$repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..') + +# These are specs that are not yet building correctly with the management generator +# Add specs here as needed when they fail to build +$failingSpecs = @( + # method-subscription-id: Skipped due to "Some file paths are too long" error in CI + "http/azure/resource-manager/method-subscription-id" +) + +function Capitalize-FirstLetter { + param ( + [string]$inputString + ) + + if ([string]::IsNullOrEmpty($inputString)) { + return $inputString + } + + $firstChar = $inputString[0].ToString().ToUpper() + $restOfString = $inputString.Substring(1) + + return $firstChar + $restOfString +} + +function Get-Namespace { + param ( + [string]$dir + ) + + $words = $dir.Split('-') + $namespace = "" + foreach ($word in $words) { + $namespace += Capitalize-FirstLetter $word + } + return $namespace +} + +function IsValidSpecDir { + param ( + [string]$fullPath + ) + if (-not(Test-Path "$fullPath/main.tsp")){ + return $false; + } + + $subPath = Get-SubPath $fullPath + + if ($failingSpecs.Contains($subPath)) { + Write-Host "Skipping $subPath" -ForegroundColor Yellow + return $false + } + + return $true +} + +function Get-Azure-Specs-Directory { + $packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..') + return Join-Path $packageRoot 'node_modules' '@azure-tools' 'azure-http-specs' +} + +function Get-Sorted-Specs { + $azureSpecsDirectory = Get-Azure-Specs-Directory + + # Only get azure resource-manager specs + $resourceManagerPath = Join-Path $azureSpecsDirectory "specs" "azure" "resource-manager" + $directories = @(Get-ChildItem -Path $resourceManagerPath -Directory -Recurse) + + $sep = [System.IO.Path]::DirectorySeparatorChar + $pattern = "${sep}specs${sep}" + + return $directories | Where-Object { IsValidSpecDir $_.FullName } | ForEach-Object { + + # Pick client.tsp if it exists, otherwise main.tsp + $specFile = Join-Path $_.FullName "client.tsp" + if (-not (Test-Path $specFile)) { + $specFile = Join-Path $_.FullName "main.tsp" + } + + # Extract the relative path after "specs/" and normalize slashes + $relativePath = ($specFile -replace '[\\\/]', '/').Substring($_.FullName.IndexOf($pattern) + $pattern.Length) + + # Remove the filename to get just the directory path + $dirPath = $relativePath -replace '/[^/]+\.tsp$', '' + + # Produce an object with the path for sorting + [PSCustomObject]@{ + SpecFile = $specFile + DirPath = $dirPath + } + } | Sort-Object -Property @{Expression = { $_.DirPath -replace '/', '!' }; Ascending = $true} | ForEach-Object { $_.SpecFile } +} + +function Get-SubPath { + param ( + [string]$fullPath + ) + $azureSpecsDirectory = Get-Azure-Specs-Directory + + $subPath = $fullPath.Substring($azureSpecsDirectory.Length + 1) + + # Keep consistent with the previous folder name because 'http' makes more sense then current 'specs' + $subPath = $subPath -replace '^specs', 'http' + + # also strip off the spec file name if present + $leaf = Split-Path -Leaf $subPath + if ($leaf -like '*.tsp') { + return (Split-Path $subPath) + } + + return $subPath +} + +Export-ModuleMember -Function "Get-Namespace" +Export-ModuleMember -Function "Get-Sorted-Specs" +Export-ModuleMember -Function "Get-SubPath" diff --git a/eng/packages/http-client-csharp-mgmt/eng/scripts/Test-Spector.ps1 b/eng/packages/http-client-csharp-mgmt/eng/scripts/Test-Spector.ps1 new file mode 100644 index 000000000000..adf43b5c2390 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/eng/scripts/Test-Spector.ps1 @@ -0,0 +1,82 @@ +#Requires -Version 7.0 + +param($filter) + +Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force; +Import-Module "$PSScriptRoot\Spector-Helper.psm1" -DisableNameChecking -Force; + +$packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..') + +Refresh-Mgmt-Build + +$spectorRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector' +$spectorCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector.Tests' 'Azure.Generator.Spector.Tests.csproj' + +$coverageDir = Join-Path $packageRoot 'generator' 'artifacts' 'coverage' + +if (-not (Test-Path $coverageDir)) { + New-Item -ItemType Directory -Path $coverageDir | Out-Null +} + +foreach ($specFile in Get-Sorted-Specs) { + $subPath = Get-SubPath $specFile + + # skip the HTTP root folder when computing the namespace filter + $folders = $subPath.Split([System.IO.Path]::DirectorySeparatorChar) | Select-Object -Skip 1 + + if (-not (Compare-Paths $subPath $filter)) { + continue + } + + $testPath = Join-Path "$spectorRoot.Tests" "Http" + $testFilter = "TestProjects.Spector.Tests.Http" + foreach ($folder in $folders) { + $segment = "$(Get-Namespace $folder)" + + # the test directory names match the test namespace names, but the source directory names will not have the leading underscore + # so check to see if the filter should contain a leading underscore by comparing with the test directory + if (-not (Test-Path (Join-Path $testPath $segment))) { + $testFilter += "._$segment" + $testPath = Join-Path $testPath "_$segment" + } + else{ + $testFilter += ".$segment" + $testPath = Join-Path $testPath $segment + } + } + + Write-Host "Regenerating $subPath" -ForegroundColor Cyan + + $outputDir = Join-Path $spectorRoot $subPath + + $command = Get-Mgmt-TspCommand $specFile $outputDir + Invoke $command + + # exit if the generation failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + + Write-Host "Testing $subPath" -ForegroundColor Cyan + $command = "dotnet test $spectorCsproj --filter `"FullyQualifiedName~$testFilter`"" + Invoke $command + # exit if the testing failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + + Write-Host "Restoring $subPath" -ForegroundColor Cyan + + $command = "git clean -xfd $outputDir" + Invoke $command + # exit if the restore failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + $command = "git restore $outputDir" + Invoke $command + # exit if the restore failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Properties/launchSettings.json b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Properties/launchSettings.json index 3fbdd62340df..cd5240b99bd7 100644 --- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Properties/launchSettings.json +++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Properties/launchSettings.json @@ -1,5 +1,30 @@ { "profiles": { + "http-azure-resource-manager-common-properties": { + "commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/azure/resource-manager/common-properties -g AzureStubGenerator", + "commandName": "Executable", + "executablePath": "dotnet" + }, + "http-azure-resource-manager-large-header": { + "commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/azure/resource-manager/large-header -g AzureStubGenerator", + "commandName": "Executable", + "executablePath": "dotnet" + }, + "http-azure-resource-manager-non-resource": { + "commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/azure/resource-manager/non-resource -g AzureStubGenerator", + "commandName": "Executable", + "executablePath": "dotnet" + }, + "http-azure-resource-manager-operation-templates": { + "commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/azure/resource-manager/operation-templates -g AzureStubGenerator", + "commandName": "Executable", + "executablePath": "dotnet" + }, + "http-azure-resource-manager-resources": { + "commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/azure/resource-manager/resources -g AzureStubGenerator", + "commandName": "Executable", + "executablePath": "dotnet" + }, "Mgmt-TypeSpec": { "commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Local/Mgmt-TypeSpec -g MgmtClientGenerator", "commandName": "Executable", diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Azure.Generator.Spector.Tests.csproj b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Azure.Generator.Spector.Tests.csproj new file mode 100644 index 000000000000..97de6e6bb995 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Azure.Generator.Spector.Tests.csproj @@ -0,0 +1,54 @@ + + + + net9.0 + net9.0 + + + + + + + + + + + + + + + + + + + + + + + + <_Parameter1>$(RepoRoot) + <_Parameter2>$(RepoRoot)\eng\packages\http-client-csharp-mgmt\generator\artifacts + + + + + + + + + + + + + + + + + + + + Always + + + + diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Http/Azure/ResourceManager/OperationTemplates/OrderDataTests.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Http/Azure/ResourceManager/OperationTemplates/OrderDataTests.cs new file mode 100644 index 000000000000..08374bf6bd93 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Http/Azure/ResourceManager/OperationTemplates/OrderDataTests.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.OperationTemplates; +using Azure.ResourceManager.OperationTemplates.Models; +using NUnit.Framework; +using TestProjects.Spector.Tests.Infrastructure; + +namespace TestProjects.Spector.Tests.Http.Azure.ResourceManager.OperationTemplates +{ + public class OrderDataTests : SpectorModelTests + { + private static readonly ModelReaderWriterOptions _wireOptions = new ModelReaderWriterOptions("W"); + + protected override string JsonPayload => """ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1", + "name": "order1", + "type": "Azure.ResourceManager.OperationTemplates/orders", + "location": "eastus", + "tags": { + "tagKey1": "tagValue1" + }, + "properties": { + "productId": "product1", + "amount": 5, + "provisioningState": "Succeeded" + } + } + """; + + protected override string WirePayload => JsonPayload; + + protected override OrderData GetModelInstance() + { + return new OrderData(AzureLocation.EastUS); + } + + protected override void VerifyModel(OrderData model, string format) + { + Assert.AreEqual("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1", model.Id.ToString()); + Assert.AreEqual("order1", model.Name); + Assert.AreEqual("eastus", model.Location.Name); + Assert.IsNotNull(model.Tags); + Assert.AreEqual("tagValue1", model.Tags["tagKey1"]); + Assert.IsNotNull(model.Properties); + Assert.AreEqual("product1", model.Properties.ProductId); + Assert.AreEqual(5, model.Properties.Amount); + Assert.AreEqual("Succeeded", model.Properties.ProvisioningState); + } + + protected override void CompareModels(OrderData model, OrderData model2, string format) + { + Assert.AreEqual(model.Id, model2.Id); + Assert.AreEqual(model.Name, model2.Name); + Assert.AreEqual(model.Location, model2.Location); + Assert.AreEqual(model.Properties?.ProductId, model2.Properties?.ProductId); + Assert.AreEqual(model.Properties?.Amount, model2.Properties?.Amount); + Assert.AreEqual(model.Properties?.ProvisioningState, model2.Properties?.ProvisioningState); + } + + protected override OrderData ToModel(Response response) + { + // Use ModelReaderWriter to deserialize since the FromResponse method is internal + return ModelReaderWriter.Read(response.Content, _wireOptions)!; + } + + protected override RequestContent ToRequestContent(OrderData model) + { + // Use ModelReaderWriter to serialize since the ToRequestContent method is internal + var binaryData = ModelReaderWriter.Write(model, _wireOptions); + return RequestContent.Create(binaryData); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/AssemblyCleanFixture.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/AssemblyCleanFixture.cs new file mode 100644 index 000000000000..3d5865a36078 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/AssemblyCleanFixture.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using NUnit.Framework; + +namespace TestProjects.Spector.Tests +{ + [SetUpFixture] + public static class AssemblyCleanFixture + { + [OneTimeTearDown] + public static void RunOnAssemblyCleanUp() + { + SpectorServerSession.Start().Server?.Dispose(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/BinaryDataAssert.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/BinaryDataAssert.cs new file mode 100644 index 000000000000..1ea9d6c6061c --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/BinaryDataAssert.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using NUnit.Framework; + +namespace TestProjects.Spector.Tests +{ + public static class BinaryDataAssert + { + public static void AreEqual(BinaryData expected, BinaryData result) + { + CollectionAssert.AreEqual(expected?.ToArray(), result?.ToArray()); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/BuildPropertiesAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/BuildPropertiesAttribute.cs new file mode 100644 index 000000000000..2de3a28415d1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/BuildPropertiesAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; + +namespace TestProjects.Spector.Tests +{ + [AttributeUsage(AttributeTargets.Assembly)] + internal sealed class BuildPropertiesAttribute : Attribute + { + public string RepoRoot { get; } + public string ArtifactsDirectory { get; } + + public BuildPropertiesAttribute(string repoRoot, string artifactsDirectory) + { + RepoRoot = repoRoot; + ArtifactsDirectory = artifactsDirectory; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorModelJsonTests.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorModelJsonTests.cs new file mode 100644 index 000000000000..c67e57f431ac --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorModelJsonTests.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using Azure.Generator.Management.Tests.Common; + +namespace TestProjects.Spector.Tests.Infrastructure +{ + public abstract class SpectorModelJsonTests : SpectorModelTests where T : IJsonModel + { + [SpectorTest] + public void RoundTripWithJsonInterfaceOfTWire() + => RoundTripTest("W", new JsonInterfaceStrategy()); + + [SpectorTest] + public void RoundTripWithJsonInterfaceOfTJson() + => RoundTripTest("J", new JsonInterfaceStrategy()); + + [SpectorTest] + public void RoundTripWithJsonInterfaceNonGenericWire() + => RoundTripTest("W", new JsonInterfaceAsObjectStrategy()); + + [SpectorTest] + public void RoundTripWithJsonInterfaceNonGenericJson() + => RoundTripTest("J", new JsonInterfaceAsObjectStrategy()); + + [SpectorTest] + public void RoundTripWithJsonInterfaceUtf8ReaderWire() + => RoundTripTest("W", new JsonInterfaceUtf8ReaderStrategy()); + + [SpectorTest] + public void RoundTripWithJsonInterfaceUtf8ReaderJson() + => RoundTripTest("J", new JsonInterfaceUtf8ReaderStrategy()); + + [SpectorTest] + public void RoundTripWithJsonInterfaceUtf8ReaderNonGenericWire() + => RoundTripTest("W", new JsonInterfaceUtf8ReaderAsObjectStrategy()); + + [SpectorTest] + public void RoundTripWithJsonInterfaceUtf8ReaderNonGenericJson() + => RoundTripTest("J", new JsonInterfaceUtf8ReaderAsObjectStrategy()); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorModelTests.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorModelTests.cs new file mode 100644 index 000000000000..0c69db248e1f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorModelTests.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using Azure.Generator.Management.Tests.Common; + +namespace TestProjects.Spector.Tests.Infrastructure +{ + public abstract class SpectorModelTests : ModelTests where T : IPersistableModel + { + [SpectorTest] + public void RoundTripWithModelReaderWriterWire() + => RoundTripWithModelReaderWriterBase("W"); + + [SpectorTest] + public void RoundTripWithModelReaderWriterJson() + => RoundTripWithModelReaderWriterBase("J"); + + [SpectorTest] + public void RoundTripWithModelReaderWriterNonGenericWire() + => RoundTripWithModelReaderWriterNonGenericBase("W"); + + [SpectorTest] + public void RoundTripWithModelReaderWriterNonGenericJson() + => RoundTripWithModelReaderWriterNonGenericBase("J"); + + [SpectorTest] + public void RoundTripWithModelInterfaceWire() + => RoundTripWithModelInterfaceBase("W"); + + [SpectorTest] + public void RoundTripWithModelInterfaceJson() + => RoundTripWithModelInterfaceBase("J"); + + [SpectorTest] + public void RoundTripWithModelInterfaceNonGenericWire() + => RoundTripWithModelInterfaceNonGenericBase("W"); + + [SpectorTest] + public void RoundTripWithModelInterfaceNonGenericJson() + => RoundTripWithModelInterfaceNonGenericBase("J"); + + [SpectorTest] + public void RoundTripWithModelCast() + => RoundTripWithModelCastBase("W"); + + [SpectorTest] + public void ThrowsIfUnknownFormat() + => ThrowsIfUnknownFormatBase(); + + [SpectorTest] + public void ThrowsIfWireIsNotJson() + => ThrowsIfWireIsNotJsonBase(); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorServer.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorServer.cs new file mode 100644 index 000000000000..14175aa21105 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorServer.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +namespace TestProjects.Spector.Tests +{ + public class SpectorServer : TestServerBase + { + public SpectorServer() : base(GetProcessPath(), $"serve {string.Join(" ", GetScenariosPaths())} --port 0 --coverageFile {GetCoverageFilePath()}") + { + } + + internal static string GetProcessPath() + { + var nodeModules = GetNodeModulesDirectory(); + return Path.Combine(nodeModules, "@typespec", "spector", "dist", "src", "cli", "cli.js"); + } + + internal static string GetAzureSpecDirectory() + { + var nodeModules = GetNodeModulesDirectory(); + return Path.Combine(nodeModules, "@azure-tools", "azure-http-specs"); + } + + internal static IEnumerable GetScenariosPaths() + { + yield return Path.Combine(GetAzureSpecDirectory(), "specs"); + } + + internal static string GetCoverageFilePath() + { + return Path.Combine(GetCoverageDirectory(), "tsp-spector-coverage-mgmt.json"); + } + + protected override void Stop(Process process) + { + Process.Start(new ProcessStartInfo("node", $"{GetProcessPath()} server stop --port {Port}")); + process.WaitForExit(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorServerSession.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorServerSession.cs new file mode 100644 index 000000000000..1b6086c9e84f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorServerSession.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading.Tasks; + +namespace TestProjects.Spector.Tests +{ + public class SpectorServerSession : TestServerSessionBase + { + private SpectorServerSession() : base() + { + } + + public static SpectorServerSession Start() + { + var server = new SpectorServerSession(); + return server; + } + + public override ValueTask DisposeAsync() + { + Return(); + return new ValueTask(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorTestAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorTestAttribute.cs new file mode 100644 index 000000000000..51b1fda3b8bd --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/SpectorTestAttribute.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using NUnit.Framework; +using NUnit.Framework.Interfaces; +using NUnit.Framework.Internal; + +namespace TestProjects.Spector.Tests +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + internal partial class SpectorTestAttribute : TestAttribute, IApplyToTest + { + [GeneratedRegex("(?<=[a-z])([A-Z])")] + private static partial Regex ToKebabCase(); + + public new void ApplyToTest(Test test) + { + string clientCodeDirectory = GetGeneratedDirectory(test); + + if (!Directory.Exists(clientCodeDirectory)) + { + // Not all spector scenarios use kebab-case directories, so try again without kebab-case. + clientCodeDirectory = GetGeneratedDirectory(test, false); + } + + var clientCsFile = GetClientCsFile(clientCodeDirectory); + + TestContext.Progress.WriteLine($"Checking if '{clientCsFile}' is a stubbed implementation."); + if (clientCsFile is null || IsLibraryStubbed(clientCsFile)) + { + SkipTest(test); + } + } + + private static bool IsLibraryStubbed(string clientCsFile) + { + SyntaxTree tree = CSharpSyntaxTree.ParseText(File.ReadAllText(clientCsFile)); + CompilationUnitSyntax root = tree.GetCompilationUnitRoot(); + + var constructors = root.DescendantNodes() + .OfType() + .ToList(); + + if (constructors.Count != 0) + { + ConstructorDeclarationSyntax? constructorWithMostParameters = constructors + .OrderByDescending(c => c.ParameterList.Parameters.Count) + .FirstOrDefault(); + + return constructorWithMostParameters?.ExpressionBody != null; + } + + return true; + } + + private static void SkipTest(Test test) + { + test.RunState = RunState.Ignored; + TestContext.Progress.WriteLine($"Test skipped because {test.FullName} is currently a stubbed implementation."); + test.Properties.Set(PropertyNames.SkipReason, $"Test skipped because {test.FullName} is currently a stubbed implementation."); + } + + private static string? GetClientCsFile(string clientCodeDirectory) + { + return Directory.GetFiles(clientCodeDirectory, "*.cs", SearchOption.TopDirectoryOnly) + .Where(f => f.EndsWith("Client.cs", StringComparison.Ordinal) && !f.EndsWith("RestClient.cs", StringComparison.Ordinal)) + .FirstOrDefault(); + } + + private static string GetGeneratedDirectory(Test test, bool kebabCaseDirectories = true) + { + var namespaceParts = test.FullName.Split('.').Skip(3); + namespaceParts = namespaceParts.Take(namespaceParts.Count() - 2); + var clientCodeDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "..", "..", "..", "eng", "packages", "http-client-csharp-mgmt", "generator", "TestProjects", "Spector"); + foreach (var part in namespaceParts) + { + clientCodeDirectory = Path.Combine(clientCodeDirectory, FixName(part, kebabCaseDirectories)); + } + return Path.Combine(clientCodeDirectory, "src", "Generated"); + } + + private static string FixName(string part, bool kebabCaseDirectories) + { + if (kebabCaseDirectories) + { + return ToKebabCase().Replace(part.StartsWith("_", StringComparison.Ordinal) ? part.Substring(1) : part, "-$1").ToLowerInvariant(); + } + // Use camelCase + return char.ToLowerInvariant(part[0]) + part[1..]; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/TestServerBase.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/TestServerBase.cs new file mode 100644 index 000000000000..f4824d0332a3 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/TestServerBase.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; +using System; +using System.Diagnostics; +using System.IO; +using System.Net.Http; +using System.Threading.Tasks; + +namespace TestProjects.Spector.Tests +{ + public class TestServerBase : IDisposable + { + private static Lazy _buildProperties = new(() => (BuildPropertiesAttribute)typeof(TestServerBase).Assembly.GetCustomAttributes(typeof(BuildPropertiesAttribute), false)[0]); + + private readonly Process? _process; + public HttpClient Client { get; } + public Uri Host { get; } + public string Port { get; } + + public TestServerBase(string processPath, string processArguments) + { + var portPhrase = "Started server on "; + + var processStartInfo = new ProcessStartInfo("node", $"{processPath} {processArguments}") + { + RedirectStandardOutput = true, + RedirectStandardError = true + }; + + _process = Process.Start(processStartInfo); + if (_process == null) + { + throw new InvalidOperationException($"Unable to start process {processStartInfo.FileName} {processStartInfo.Arguments}"); + } + ProcessTracker.Add(_process); + Debug.Assert(_process != null); + while (!_process.HasExited) + { + var s = _process.StandardOutput.ReadLine(); + var indexOfPort = s?.IndexOf(portPhrase); + if (indexOfPort > 0) + { + Port = s!.Substring(indexOfPort.Value + portPhrase.Length).Trim(); + Host = new Uri($"http://localhost:{Port}"); + Client = new HttpClient + { + BaseAddress = Host + }; + _ = Task.Run(ReadOutput); + return; + } + } + + if (Client == null || Host == null || Port == null) + { + throw new InvalidOperationException($"Unable to detect server port {_process.StandardOutput.ReadToEnd()} {_process.StandardError.ReadToEnd()}"); + } + } + + protected static string GetCoverageDirectory() + { + return Path.Combine(_buildProperties.Value.ArtifactsDirectory, "coverage"); + } + + protected static string GetRepoRootDirectory() + { + return _buildProperties.Value.RepoRoot; + } + + protected static string GetNodeModulesDirectory() + { + var repoRoot = _buildProperties.Value.RepoRoot; + var nodeModulesDirectory = Path.Combine(repoRoot, "eng", "packages", "http-client-csharp-mgmt", "node_modules"); + if (Directory.Exists(nodeModulesDirectory)) + { + return nodeModulesDirectory; + } + + throw new InvalidOperationException($"Cannot find 'node_modules' in parent directories of {typeof(SpectorServer).Assembly.Location}."); + } + + private void ReadOutput() + { + while (_process is not null && !_process.HasExited && !_process.StandardOutput.EndOfStream) + { + _process.StandardOutput.ReadToEnd(); + _process.StandardError.ReadToEnd(); + } + } + + protected virtual void Stop(Process process) + { + process.Kill(true); + } + + public void Dispose() + { + if (_process is not null) + Stop(_process); + + _process?.Dispose(); + Client?.Dispose(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/TestServerSessionBase.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/TestServerSessionBase.cs new file mode 100644 index 000000000000..a2d40991ed54 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Infrastructure/TestServerSessionBase.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading.Tasks; + +namespace TestProjects.Spector.Tests +{ + public abstract class TestServerSessionBase : IAsyncDisposable where T : TestServerBase + { + private static readonly object _serverCacheLock = new object(); + private static T? s_serverCache; + + public T? Server { get; private set; } + public Uri Host => Server?.Host ?? throw new InvalidOperationException("Server is not instantiated"); + + protected TestServerSessionBase() + { + Server = GetServer(); + } + + private ref T? GetServerCache() + { + return ref s_serverCache; + } + + private T CreateServer() + { + var server = Activator.CreateInstance(typeof(T)); + if (server is null) + { + throw new InvalidOperationException($"Unable to construct a new instance of {typeof(T).Name}"); + } + + return (T)server; + } + + private T GetServer() + { + T? server; + lock (_serverCacheLock) + { + ref var cache = ref GetServerCache(); + server = cache; + cache = null; + } + + if (server == null) + { + server = CreateServer(); + } + + return server; + } + + public abstract ValueTask DisposeAsync(); + + protected void Return() + { + bool disposeServer = true; + lock (_serverCacheLock) + { + ref var cache = ref GetServerCache(); + if (cache == null) + { + cache = Server; + Server = null; + disposeServer = false; + } + } + + if (disposeServer) + { + Server?.Dispose(); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/SpectorTestBase.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/SpectorTestBase.cs new file mode 100644 index 000000000000..dbfceca70d52 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/SpectorTestBase.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace TestProjects.Spector.Tests +{ + public abstract class SpectorTestBase + { + public async Task Test(Func test) + { + var server = SpectorServerSession.Start(); + + try + { + await test(server.Host); + } + catch (Exception ex) + { + try + { + await server.DisposeAsync(); + } + catch (Exception disposeException) + { + throw new AggregateException(ex, disposeException); + } + + throw; + } + + await server.DisposeAsync(); + } + + internal static async Task InvokeMethodAsync(object obj, string methodName, params object[] args) + { + Task? task = (Task?)InvokeMethod(obj, methodName, args); + if (task != null) + { + await task; + return GetProperty(task, "Result"); + } + return null; + } + + internal static object? GetProperty(object obj, string propertyName) + { + return obj.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public)!.GetValue(obj); + } + + internal static object? InvokeMethod(object obj, string methodName, params object[] args) + => InvokeMethodInternal(obj.GetType(), obj, methodName, [], + BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, args); + + private static object? InvokeMethodInternal(Type type, + object obj, + string methodName, + IEnumerable genericArgs, + BindingFlags flags, + params object[] args) + { + var methods = type.GetMethods(flags); + MethodInfo? methodInfo = null; + foreach (var method in methods) + { + var methodToTry = method; + if (genericArgs.Any()) + { + methodToTry = methodToTry.MakeGenericMethod([.. genericArgs]); + } + + if (!methodToTry.Name.Equals(methodName, StringComparison.Ordinal)) + continue; + + var parameters = methodToTry.GetParameters(); + if (parameters.Length < args.Length) + continue; + + //verify the types match for all the args passed in + int i = 0; + bool isMatch = true; + foreach (var parameter in parameters.Take(args.Length)) + { + if (!parameter.ParameterType.IsAssignableFrom(args[i++]?.GetType()) && + !CanAssignNull(parameter.ParameterType, args[i - 1])) + { + isMatch = false; + break; + } + } + + if (isMatch) + { + methodInfo = methodToTry; + break; + } + } + + if (methodInfo == null) + throw new MissingMethodException( + $"No matching method found for type {type} with the provided name {methodName}."); + + return methodInfo.Invoke(obj, + [.. args, .. methodInfo.GetParameters().Skip(args.Length).Select(p => p.DefaultValue)]); + } + + private static bool CanAssignNull(Type parameterType, object arg) + { + if (arg is not null) + return false; + + return !parameterType.IsValueType || + (parameterType.IsGenericType && parameterType.GetGenericTypeDefinition().Equals(typeof(Nullable<>))); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/Azure.ResourceManager.CommonProperties.sln b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/Azure.ResourceManager.CommonProperties.sln new file mode 100644 index 000000000000..3cafb7da7cda --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/Azure.ResourceManager.CommonProperties.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.CommonProperties", "src\Azure.ResourceManager.CommonProperties.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/Configuration.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/Configuration.json new file mode 100644 index 000000000000..448e0fb518fe --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/Configuration.json @@ -0,0 +1,11 @@ +{ + "package-name": "Azure.ResourceManager.CommonProperties", + "model-namespace": true, + "license": { + "name": "MIT License", + "company": "Microsoft Corporation", + "link": "https://mit-license.org", + "header": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.", + "description": "Copyright (c) Microsoft Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the “Software”), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE." + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Azure.ResourceManager.CommonProperties.csproj b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Azure.ResourceManager.CommonProperties.csproj new file mode 100644 index 000000000000..c5b32077427f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Azure.ResourceManager.CommonProperties.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.CommonProperties client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.CommonProperties + 1.0.0-beta.1 + Azure.ResourceManager.CommonProperties + true + + diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ArmCommonPropertiesModelFactory.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ArmCommonPropertiesModelFactory.cs new file mode 100644 index 000000000000..bf027cc81868 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ArmCommonPropertiesModelFactory.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure; +using Azure.Core; +using Azure.ResourceManager.CommonProperties; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CommonProperties.Models +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ArmCommonPropertiesModelFactory + { + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. + /// The status of the last operation. + /// The managed service identities assigned to this resource. + /// A new instance for mocking. + public static ManagedIdentityTrackedResourceData ManagedIdentityTrackedResourceData(string id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, string managedIdentityTrackedResourceProvisioningState = default, ManagedServiceIdentity identity = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new ManagedIdentityTrackedResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + managedIdentityTrackedResourceProvisioningState is null ? default : new ManagedIdentityTrackedResourceProperties(managedIdentityTrackedResourceProvisioningState, null), + identity); + } + + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ConfidentialResourceData ConfidentialResourceData(string id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, ConfidentialResourceProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new ConfidentialResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Confidential Resource Properties. + /// The status of the last operation. + /// + /// A new instance for mocking. + public static ConfidentialResourceProperties ConfidentialResourceProperties(string provisioningState = default, string username = default) + { + return new ConfidentialResourceProperties(provisioningState, username, additionalBinaryDataProperties: null); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResource.Serialization.cs new file mode 100644 index 000000000000..6994fa20e099 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.CommonProperties +{ + /// + public partial class ConfidentialResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ConfidentialResourceData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + ConfidentialResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerCommonPropertiesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + ConfidentialResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerCommonPropertiesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResource.cs new file mode 100644 index 000000000000..459bbb66fba2 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResource.cs @@ -0,0 +1,555 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.CommonProperties +{ + /// + /// A class representing a ConfidentialResource along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetConfidentialResources method. + /// + public partial class ConfidentialResource : ArmResource + { + private readonly ClientDiagnostics _errorClientDiagnostics; + private readonly Error _errorRestClient; + private readonly ConfidentialResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Azure.ResourceManager.CommonProperties/confidentialResources"; + + /// Initializes a new instance of ConfidentialResource for mocking. + protected ConfidentialResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ConfidentialResource(ArmClient client, ConfidentialResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ConfidentialResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string confidentialResourceApiVersion); + _errorClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CommonProperties", ResourceType.Namespace, Diagnostics); + _errorRestClient = new Error(_errorClientDiagnostics, Pipeline, Endpoint, confidentialResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual ConfidentialResourceData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The confidentialResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string confidentialResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_GetForPredefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_GetForPredefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_CreateForUserDefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ConfidentialResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateCreateForUserDefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ConfidentialResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + CommonPropertiesArmOperation operation = new CommonPropertiesArmOperation(Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_CreateForUserDefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ConfidentialResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateCreateForUserDefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ConfidentialResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + CommonPropertiesArmOperation operation = new CommonPropertiesArmOperation(Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ConfidentialResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + ArmOperation result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ConfidentialResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + ArmOperation result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ConfidentialResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ConfidentialResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + ArmOperation result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ConfidentialResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ConfidentialResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + ArmOperation result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceCollection.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceCollection.cs new file mode 100644 index 000000000000..c6be8f8c489a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceCollection.cs @@ -0,0 +1,500 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.CommonProperties +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetConfidentialResources method from an instance of . + /// + public partial class ConfidentialResourceCollection : ArmCollection + { + private readonly ClientDiagnostics _errorClientDiagnostics; + private readonly Error _errorRestClient; + + /// Initializes a new instance of ConfidentialResourceCollection for mocking. + protected ConfidentialResourceCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ConfidentialResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ConfidentialResource.ResourceType, out string confidentialResourceApiVersion); + _errorClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CommonProperties", ConfidentialResource.ResourceType.Namespace, Diagnostics); + _errorRestClient = new Error(_errorClientDiagnostics, Pipeline, Endpoint, confidentialResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Create a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_CreateForUserDefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the ConfidentialResource. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string confidentialResourceName, ConfidentialResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(confidentialResourceName, nameof(confidentialResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateCreateForUserDefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, confidentialResourceName, ConfidentialResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + CommonPropertiesArmOperation operation = new CommonPropertiesArmOperation(Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_CreateForUserDefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the ConfidentialResource. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string confidentialResourceName, ConfidentialResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(confidentialResourceName, nameof(confidentialResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateCreateForUserDefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, confidentialResourceName, ConfidentialResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + CommonPropertiesArmOperation operation = new CommonPropertiesArmOperation(Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_GetForPredefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ConfidentialResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetForPredefinedErrorAsync(string confidentialResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(confidentialResourceName, nameof(confidentialResourceName)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResourceCollection.GetForPredefinedError"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, confidentialResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_GetForPredefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ConfidentialResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetForPredefinedError(string confidentialResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(confidentialResourceName, nameof(confidentialResourceName)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResourceCollection.GetForPredefinedError"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, confidentialResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_GetForPredefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ConfidentialResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string confidentialResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(confidentialResourceName, nameof(confidentialResourceName)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, confidentialResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ConfidentialResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_GetForPredefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ConfidentialResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string confidentialResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(confidentialResourceName, nameof(confidentialResourceName)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, confidentialResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ConfidentialResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_GetForPredefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ConfidentialResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string confidentialResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(confidentialResourceName, nameof(confidentialResourceName)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, confidentialResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ConfidentialResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ConfidentialResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}. + /// + /// + /// Operation Id. + /// Error_GetForPredefinedError. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ConfidentialResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string confidentialResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(confidentialResourceName, nameof(confidentialResourceName)); + + using DiagnosticScope scope = _errorClientDiagnostics.CreateScope("ConfidentialResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _errorRestClient.CreateGetForPredefinedErrorRequest(Id.SubscriptionId, Id.ResourceGroupName, confidentialResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ConfidentialResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ConfidentialResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ConfidentialResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.Serialization.cs new file mode 100644 index 000000000000..934083c86337 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.Serialization.cs @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.CommonProperties.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CommonProperties +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class ConfidentialResourceData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ConfidentialResourceData() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConfidentialResourceData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ConfidentialResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ConfidentialResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConfidentialResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConfidentialResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ConfidentialResourceData DeserializeConfidentialResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + ConfidentialResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerCommonPropertiesContext.Default); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ConfidentialResourceProperties.DeserializeConfidentialResourceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ConfidentialResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerCommonPropertiesContext.Default); + default: + throw new FormatException($"The model {nameof(ConfidentialResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ConfidentialResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ConfidentialResourceData)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeConfidentialResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConfidentialResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ConfidentialResourceData confidentialResourceData) + { + if (confidentialResourceData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(confidentialResourceData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static ConfidentialResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeConfidentialResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.cs new file mode 100644 index 000000000000..2fa3c11c35e0 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.CommonProperties.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CommonProperties +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class ConfidentialResourceData : TrackedResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The geo-location where the resource lives. + public ConfidentialResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + internal ConfidentialResourceData(string id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, ConfidentialResourceProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public ConfidentialResourceProperties Properties { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Extensions/CommonPropertiesExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Extensions/CommonPropertiesExtensions.cs new file mode 100644 index 000000000000..abb75e419e15 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Extensions/CommonPropertiesExtensions.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.CommonProperties.Mocking; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.CommonProperties +{ + /// A class to add extension methods to Azure.ResourceManager.CommonProperties. + public static partial class CommonPropertiesExtensions + { + /// + private static MockableCommonPropertiesArmClient GetMockableCommonPropertiesArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableCommonPropertiesArmClient(client0, ResourceIdentifier.Root)); + } + + /// + private static MockableCommonPropertiesResourceGroupResource GetMockableCommonPropertiesResourceGroupResource(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient(client => new MockableCommonPropertiesResourceGroupResource(client, resourceGroupResource.Id)); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ManagedIdentityTrackedResource GetManagedIdentityTrackedResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableCommonPropertiesArmClient(client).GetManagedIdentityTrackedResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ConfidentialResource GetConfidentialResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableCommonPropertiesArmClient(client).GetConfidentialResource(id); + } + + /// + /// Gets a collection of ManagedIdentityTrackedResources in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of ManagedIdentityTrackedResources and their operations over a ManagedIdentityTrackedResource. + public static ManagedIdentityTrackedResourceCollection GetManagedIdentityTrackedResources(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableCommonPropertiesResourceGroupResource(resourceGroupResource).GetManagedIdentityTrackedResources(); + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetManagedIdentityTrackedResourceAsync(this ResourceGroupResource resourceGroupResource, string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableCommonPropertiesResourceGroupResource(resourceGroupResource).GetManagedIdentityTrackedResourceAsync(managedIdentityTrackedResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetManagedIdentityTrackedResource(this ResourceGroupResource resourceGroupResource, string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableCommonPropertiesResourceGroupResource(resourceGroupResource).GetManagedIdentityTrackedResource(managedIdentityTrackedResourceName, cancellationToken); + } + + /// + /// Gets a collection of ConfidentialResources in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of ConfidentialResources and their operations over a ConfidentialResource. + public static ConfidentialResourceCollection GetConfidentialResources(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableCommonPropertiesResourceGroupResource(resourceGroupResource).GetConfidentialResources(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Extensions/MockableCommonPropertiesArmClient.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Extensions/MockableCommonPropertiesArmClient.cs new file mode 100644 index 000000000000..02b3e9328850 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Extensions/MockableCommonPropertiesArmClient.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.CommonProperties; + +namespace Azure.ResourceManager.CommonProperties.Mocking +{ + /// A class to add extension methods to . + public partial class MockableCommonPropertiesArmClient : ArmResource + { + /// Initializes a new instance of MockableCommonPropertiesArmClient for mocking. + protected MockableCommonPropertiesArmClient() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableCommonPropertiesArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ManagedIdentityTrackedResource GetManagedIdentityTrackedResource(ResourceIdentifier id) + { + ManagedIdentityTrackedResource.ValidateResourceId(id); + return new ManagedIdentityTrackedResource(Client, id); + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ConfidentialResource GetConfidentialResource(ResourceIdentifier id) + { + ConfidentialResource.ValidateResourceId(id); + return new ConfidentialResource(Client, id); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Extensions/MockableCommonPropertiesResourceGroupResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Extensions/MockableCommonPropertiesResourceGroupResource.cs new file mode 100644 index 000000000000..5d302c942241 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Extensions/MockableCommonPropertiesResourceGroupResource.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.CommonProperties; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.CommonProperties.Mocking +{ + /// A class to add extension methods to . + public partial class MockableCommonPropertiesResourceGroupResource : ArmResource + { + /// Initializes a new instance of MockableCommonPropertiesResourceGroupResource for mocking. + protected MockableCommonPropertiesResourceGroupResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableCommonPropertiesResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets a collection of ManagedIdentityTrackedResources in the . + /// An object representing collection of ManagedIdentityTrackedResources and their operations over a ManagedIdentityTrackedResource. + public virtual ManagedIdentityTrackedResourceCollection GetManagedIdentityTrackedResources() + { + return GetCachedClient(client => new ManagedIdentityTrackedResourceCollection(client, Id)); + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetManagedIdentityTrackedResourceAsync(string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + + return await GetManagedIdentityTrackedResources().GetAsync(managedIdentityTrackedResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetManagedIdentityTrackedResource(string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + + return GetManagedIdentityTrackedResources().Get(managedIdentityTrackedResourceName, cancellationToken); + } + + /// Gets a collection of ConfidentialResources in the . + /// An object representing collection of ConfidentialResources and their operations over a ConfidentialResource. + public virtual ConfidentialResourceCollection GetConfidentialResources() + { + return GetCachedClient(client => new ConfidentialResourceCollection(client, Id)); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/Argument.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..e8bbbd6f8065 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/Argument.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CommonProperties +{ + internal static partial class Argument + { + /// The value. + /// The name. + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ChangeTrackingDictionary.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..89cc61a57668 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CommonProperties +{ + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerDictionary == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + /// Gets the Keys. + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + /// Gets the Values. + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + /// Gets or sets the value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + /// Gets the Keys. + IEnumerable IReadOnlyDictionary.Keys => Keys; + + /// Gets the Values. + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + /// The item to search for. + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + /// The array to copy. + /// The index. + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + /// The item to remove. + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + /// The key. + /// The value to add. + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + /// The key to search for. + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + /// The key. + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + /// The key to search for. + /// The value. + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ChangeTrackingList.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..100b75449eb2 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.CommonProperties +{ + internal partial class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + /// The inner list. + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + /// The inner list. + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerList == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureList().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + /// Gets or sets the value associated with the specified key. + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + /// The item. + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + /// The array to copy to. + /// The array index. + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + /// The item. + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + /// The item. + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + /// The inner list. + /// The item. + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + /// The inner list. + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ClientPipelineExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..1628b529b926 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.CommonProperties +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenMemberAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..ce3d3075d8e5 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.CommonProperties +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenSerializationAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..a0f1a552ec71 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.CommonProperties +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenSuppressAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..07e937a9056e --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.CommonProperties +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenTypeAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..6ecbb8f81f7c --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.CommonProperties +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ErrorResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..c8457159f7de --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.ResourceManager.CommonProperties +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ModelSerializationExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..5ddf649f9ab9 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; + +namespace Azure.ResourceManager.CommonProperties +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + Dictionary dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + List list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/Optional.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..17dcb4b3739c --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.CommonProperties +{ + internal static partial class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(string value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..205001928e9b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.CommonProperties +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/RequestContextExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..19a4816cbd30 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.CommonProperties +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/SerializationFormat.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..162e1d3cb9a0 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.CommonProperties +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/TypeFormatters.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..c2082f4f70b4 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.CommonProperties +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/Utf8JsonRequestContent.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..2d3912e96d8e --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.CommonProperties +{ + internal partial class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + /// Gets the JsonWriter. + public Utf8JsonWriter JsonWriter { get; } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + /// + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/LongRunningOperation/CommonPropertiesArmOperationOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/LongRunningOperation/CommonPropertiesArmOperationOfT.cs new file mode 100644 index 000000000000..64080bff8c8f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/LongRunningOperation/CommonPropertiesArmOperationOfT.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.CommonProperties +{ + internal partial class CommonPropertiesArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of CommonPropertiesArmOperation for mocking. + protected CommonPropertiesArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal CommonPropertiesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal CommonPropertiesArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "CommonPropertiesArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the Value. + public override T Value => _operation.Value; + + /// Gets the HasValue. + public override bool HasValue => _operation.HasValue; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResource.Serialization.cs new file mode 100644 index 000000000000..b846952d48d6 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.CommonProperties +{ + /// + public partial class ManagedIdentityTrackedResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ManagedIdentityTrackedResourceData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + ManagedIdentityTrackedResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerCommonPropertiesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + ManagedIdentityTrackedResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerCommonPropertiesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResource.cs new file mode 100644 index 000000000000..fdb6da5eddd2 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResource.cs @@ -0,0 +1,569 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.CommonProperties +{ + /// + /// A class representing a ManagedIdentityTrackedResource along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetManagedIdentityTrackedResources method. + /// + public partial class ManagedIdentityTrackedResource : ArmResource + { + private readonly ClientDiagnostics _managedIdentityClientDiagnostics; + private readonly ManagedIdentity _managedIdentityRestClient; + private readonly ManagedIdentityTrackedResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources"; + + /// Initializes a new instance of ManagedIdentityTrackedResource for mocking. + protected ManagedIdentityTrackedResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ManagedIdentityTrackedResource(ArmClient client, ManagedIdentityTrackedResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ManagedIdentityTrackedResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string managedIdentityTrackedResourceApiVersion); + _managedIdentityClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CommonProperties", ResourceType.Namespace, Diagnostics); + _managedIdentityRestClient = new ManagedIdentity(_managedIdentityClientDiagnostics, Pipeline, Endpoint, managedIdentityTrackedResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual ManagedIdentityTrackedResourceData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The managedIdentityTrackedResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string managedIdentityTrackedResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_UpdateWithUserAssignedAndSystemAssigned. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(ManagedIdentityTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateUpdateWithUserAssignedAndSystemAssignedRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ManagedIdentityTrackedResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_UpdateWithUserAssignedAndSystemAssigned. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(ManagedIdentityTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateUpdateWithUserAssignedAndSystemAssignedRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ManagedIdentityTrackedResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ManagedIdentityTrackedResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedIdentityTrackedResourceData patch = new ManagedIdentityTrackedResourceData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ManagedIdentityTrackedResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedIdentityTrackedResourceData patch = new ManagedIdentityTrackedResourceData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ManagedIdentityTrackedResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedIdentityTrackedResourceData patch = new ManagedIdentityTrackedResourceData(); + patch.Tags.ReplaceWith(tags); + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ManagedIdentityTrackedResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedIdentityTrackedResourceData patch = new ManagedIdentityTrackedResourceData(); + patch.Tags.ReplaceWith(tags); + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ManagedIdentityTrackedResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ManagedIdentityTrackedResourceData patch = new ManagedIdentityTrackedResourceData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ManagedIdentityTrackedResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + ManagedIdentityTrackedResourceData patch = new ManagedIdentityTrackedResourceData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceCollection.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceCollection.cs new file mode 100644 index 000000000000..3057ba8f6086 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceCollection.cs @@ -0,0 +1,500 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.CommonProperties +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetManagedIdentityTrackedResources method from an instance of . + /// + public partial class ManagedIdentityTrackedResourceCollection : ArmCollection + { + private readonly ClientDiagnostics _managedIdentityClientDiagnostics; + private readonly ManagedIdentity _managedIdentityRestClient; + + /// Initializes a new instance of ManagedIdentityTrackedResourceCollection for mocking. + protected ManagedIdentityTrackedResourceCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ManagedIdentityTrackedResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ManagedIdentityTrackedResource.ResourceType, out string managedIdentityTrackedResourceApiVersion); + _managedIdentityClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CommonProperties", ManagedIdentityTrackedResource.ResourceType.Namespace, Diagnostics); + _managedIdentityRestClient = new ManagedIdentity(_managedIdentityClientDiagnostics, Pipeline, Endpoint, managedIdentityTrackedResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Create a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_CreateWithSystemAssigned. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// arm resource name for path. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateCreateWithSystemAssignedRequest(Id.SubscriptionId, Id.ResourceGroupName, managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + CommonPropertiesArmOperation operation = new CommonPropertiesArmOperation(Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_CreateWithSystemAssigned. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// arm resource name for path. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateCreateWithSystemAssignedRequest(Id.SubscriptionId, Id.ResourceGroupName, managedIdentityTrackedResourceName, ManagedIdentityTrackedResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + CommonPropertiesArmOperation operation = new CommonPropertiesArmOperation(Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, managedIdentityTrackedResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, managedIdentityTrackedResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, managedIdentityTrackedResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedIdentityTrackedResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, managedIdentityTrackedResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedIdentityTrackedResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, managedIdentityTrackedResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedIdentityTrackedResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ManagedIdentityTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}. + /// + /// + /// Operation Id. + /// ManagedIdentity_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string managedIdentityTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(managedIdentityTrackedResourceName, nameof(managedIdentityTrackedResourceName)); + + using DiagnosticScope scope = _managedIdentityClientDiagnostics.CreateScope("ManagedIdentityTrackedResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _managedIdentityRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, managedIdentityTrackedResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ManagedIdentityTrackedResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ManagedIdentityTrackedResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ManagedIdentityTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.Serialization.cs new file mode 100644 index 000000000000..f453695d291d --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.Serialization.cs @@ -0,0 +1,243 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.CommonProperties.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CommonProperties +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class ManagedIdentityTrackedResourceData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ManagedIdentityTrackedResourceData() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedIdentityTrackedResourceData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + ((IJsonModel)Identity).Write(writer, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ManagedIdentityTrackedResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ManagedIdentityTrackedResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedIdentityTrackedResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedIdentityTrackedResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedIdentityTrackedResourceData DeserializeManagedIdentityTrackedResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + ManagedIdentityTrackedResourceProperties properties = default; + ManagedServiceIdentity identity = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerCommonPropertiesContext.Default); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ManagedIdentityTrackedResourceProperties.DeserializeManagedIdentityTrackedResourceProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("identity"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerCommonPropertiesContext.Default); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ManagedIdentityTrackedResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + identity); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerCommonPropertiesContext.Default); + default: + throw new FormatException($"The model {nameof(ManagedIdentityTrackedResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ManagedIdentityTrackedResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ManagedIdentityTrackedResourceData)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeManagedIdentityTrackedResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedIdentityTrackedResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ManagedIdentityTrackedResourceData managedIdentityTrackedResourceData) + { + if (managedIdentityTrackedResourceData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(managedIdentityTrackedResourceData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static ManagedIdentityTrackedResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagedIdentityTrackedResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.cs new file mode 100644 index 000000000000..2c31f5b6e06c --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.CommonProperties.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CommonProperties +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class ManagedIdentityTrackedResourceData : TrackedResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The geo-location where the resource lives. + public ManagedIdentityTrackedResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// The managed service identities assigned to this resource. + internal ManagedIdentityTrackedResourceData(string id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, ManagedIdentityTrackedResourceProperties properties, ManagedServiceIdentity identity) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + Identity = identity; + } + + /// The resource-specific properties for this resource. + internal ManagedIdentityTrackedResourceProperties Properties { get; set; } + + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + + /// The status of the last operation. + public string ManagedIdentityTrackedResourceProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/AzureResourceManagerCommonPropertiesContext.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/AzureResourceManagerCommonPropertiesContext.cs new file mode 100644 index 000000000000..d7bfff55cf3b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/AzureResourceManagerCommonPropertiesContext.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.CommonProperties.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CommonProperties +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(ConfidentialResource))] + [ModelReaderWriterBuildable(typeof(ConfidentialResourceData))] + [ModelReaderWriterBuildable(typeof(ConfidentialResourceProperties))] + [ModelReaderWriterBuildable(typeof(ManagedIdentityTrackedResource))] + [ModelReaderWriterBuildable(typeof(ManagedIdentityTrackedResourceData))] + [ModelReaderWriterBuildable(typeof(ManagedIdentityTrackedResourceProperties))] + [ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(SystemData))] + [ModelReaderWriterBuildable(typeof(UserAssignedIdentity))] + public partial class AzureResourceManagerCommonPropertiesContext : ModelReaderWriterContext + { + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ConfidentialResourceProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ConfidentialResourceProperties.Serialization.cs new file mode 100644 index 000000000000..fabe049f4bc5 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ConfidentialResourceProperties.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.CommonProperties; + +namespace Azure.ResourceManager.CommonProperties.Models +{ + /// Confidential Resource Properties. + public partial class ConfidentialResourceProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ConfidentialResourceProperties() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConfidentialResourceProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W") + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } + writer.WritePropertyName("username"u8); + writer.WriteStringValue(Username); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ConfidentialResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ConfidentialResourceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConfidentialResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConfidentialResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ConfidentialResourceProperties DeserializeConfidentialResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string provisioningState = default; + string username = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + provisioningState = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("username"u8)) + { + username = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ConfidentialResourceProperties(provisioningState, username, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerCommonPropertiesContext.Default); + default: + throw new FormatException($"The model {nameof(ConfidentialResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ConfidentialResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ConfidentialResourceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeConfidentialResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConfidentialResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ConfidentialResourceProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ConfidentialResourceProperties.cs new file mode 100644 index 000000000000..acb8b82ae9ec --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ConfidentialResourceProperties.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.CommonProperties; + +namespace Azure.ResourceManager.CommonProperties.Models +{ + /// Confidential Resource Properties. + public partial class ConfidentialResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// is null. + public ConfidentialResourceProperties(string username) + { + Argument.AssertNotNull(username, nameof(username)); + + Username = username; + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// + /// Keeps track of any properties unknown to the library. + internal ConfidentialResourceProperties(string provisioningState, string username, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + Username = username; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public string ProvisioningState { get; } + + /// Gets or sets the Username. + public string Username { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ManagedIdentityTrackedResourceProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ManagedIdentityTrackedResourceProperties.Serialization.cs new file mode 100644 index 000000000000..18c2333eb6ad --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ManagedIdentityTrackedResourceProperties.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.CommonProperties; + +namespace Azure.ResourceManager.CommonProperties.Models +{ + /// Managed Identity Arm Resource Properties. + internal partial class ManagedIdentityTrackedResourceProperties : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedIdentityTrackedResourceProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W") + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ManagedIdentityTrackedResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ManagedIdentityTrackedResourceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedIdentityTrackedResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedIdentityTrackedResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedIdentityTrackedResourceProperties DeserializeManagedIdentityTrackedResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + provisioningState = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ManagedIdentityTrackedResourceProperties(provisioningState, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerCommonPropertiesContext.Default); + default: + throw new FormatException($"The model {nameof(ManagedIdentityTrackedResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ManagedIdentityTrackedResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ManagedIdentityTrackedResourceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeManagedIdentityTrackedResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedIdentityTrackedResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ManagedIdentityTrackedResourceProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ManagedIdentityTrackedResourceProperties.cs new file mode 100644 index 000000000000..44629bdb80b0 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/Models/ManagedIdentityTrackedResourceProperties.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CommonProperties.Models +{ + /// Managed Identity Arm Resource Properties. + internal partial class ManagedIdentityTrackedResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ManagedIdentityTrackedResourceProperties() + { + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal ManagedIdentityTrackedResourceProperties(string provisioningState, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public string ProvisioningState { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/RestOperations/ErrorRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/RestOperations/ErrorRestOperations.cs new file mode 100644 index 000000000000..9e7880807899 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/RestOperations/ErrorRestOperations.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.CommonProperties +{ + internal partial class Error + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Error for mocking. + protected Error() + { + } + + /// Initializes a new instance of Error. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Error(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetForPredefinedErrorRequest(string subscriptionId, string resourceGroupName, string confidentialResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.CommonProperties/confidentialResources/", false); + uri.AppendPath(confidentialResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateForUserDefinedErrorRequest(string subscriptionId, string resourceGroupName, string confidentialResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.CommonProperties/confidentialResources/", false); + uri.AppendPath(confidentialResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/RestOperations/ManagedIdentityRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/RestOperations/ManagedIdentityRestOperations.cs new file mode 100644 index 000000000000..222094ed827a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/RestOperations/ManagedIdentityRestOperations.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.CommonProperties +{ + internal partial class ManagedIdentity + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ManagedIdentity for mocking. + protected ManagedIdentity() + { + } + + /// Initializes a new instance of ManagedIdentity. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal ManagedIdentity(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string managedIdentityTrackedResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/", false); + uri.AppendPath(managedIdentityTrackedResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateWithSystemAssignedRequest(string subscriptionId, string resourceGroupName, string managedIdentityTrackedResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/", false); + uri.AppendPath(managedIdentityTrackedResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateWithUserAssignedAndSystemAssignedRequest(string subscriptionId, string resourceGroupName, string managedIdentityTrackedResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/", false); + uri.AppendPath(managedIdentityTrackedResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/tspCodeModel.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/tspCodeModel.json new file mode 100644 index 000000000000..a46a3446fa25 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/tspCodeModel.json @@ -0,0 +1,3591 @@ +{ + "name": "Azure.ResourceManager.CommonProperties", + "apiVersions": [ + "2023-12-01-preview" + ], + "enums": [ + { + "$id": "1", + "kind": "enum", + "name": "ManagedServiceIdentityType", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType", + "valueType": { + "$id": "2", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "3", + "kind": "enumvalue", + "name": "None", + "value": "None", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "No managed identity.", + "decorators": [] + }, + { + "$id": "4", + "kind": "enumvalue", + "name": "SystemAssigned", + "value": "SystemAssigned", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "System assigned managed identity.", + "decorators": [] + }, + { + "$id": "5", + "kind": "enumvalue", + "name": "UserAssigned", + "value": "UserAssigned", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "User assigned managed identity.", + "decorators": [] + }, + { + "$id": "6", + "kind": "enumvalue", + "name": "SystemAssigned,UserAssigned", + "value": "SystemAssigned,UserAssigned", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "System and user assigned managed identity.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + "isFixed": false, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "7", + "kind": "enum", + "name": "createdByType", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.createdByType", + "valueType": { + "$id": "8", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "9", + "kind": "enumvalue", + "name": "User", + "value": "User", + "valueType": { + "$ref": "8" + }, + "enumType": { + "$ref": "7" + }, + "doc": "The entity was created by a user.", + "decorators": [] + }, + { + "$id": "10", + "kind": "enumvalue", + "name": "Application", + "value": "Application", + "valueType": { + "$ref": "8" + }, + "enumType": { + "$ref": "7" + }, + "doc": "The entity was created by an application.", + "decorators": [] + }, + { + "$id": "11", + "kind": "enumvalue", + "name": "ManagedIdentity", + "value": "ManagedIdentity", + "valueType": { + "$ref": "8" + }, + "enumType": { + "$ref": "7" + }, + "doc": "The entity was created by a managed identity.", + "decorators": [] + }, + { + "$id": "12", + "kind": "enumvalue", + "name": "Key", + "value": "Key", + "valueType": { + "$ref": "8" + }, + "enumType": { + "$ref": "7" + }, + "doc": "The entity was created by a key.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "The kind of entity that created the resource.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json", + "decorators": [] + }, + { + "$id": "13", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Versions", + "valueType": { + "$id": "14", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "15", + "kind": "enumvalue", + "name": "v2023_12_01_preview", + "value": "2023-12-01-preview", + "valueType": { + "$ref": "14" + }, + "enumType": { + "$ref": "13" + }, + "doc": "Preview API version 2023-12-01-preview.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonProperties", + "doc": "Azure API versions.", + "isFixed": true, + "isFlags": false, + "usage": "ApiVersionEnum", + "decorators": [] + } + ], + "constants": [ + { + "$id": "16", + "kind": "constant", + "name": "getContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "18", + "kind": "constant", + "name": "createWithSystemAssignedContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "19", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "20", + "kind": "constant", + "name": "createWithSystemAssignedContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "21", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "22", + "kind": "constant", + "name": "updateWithUserAssignedAndSystemAssignedContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "23", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "24", + "kind": "constant", + "name": "updateWithUserAssignedAndSystemAssignedContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "25", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "26", + "kind": "constant", + "name": "getForPredefinedErrorContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "27", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "28", + "kind": "constant", + "name": "createForUserDefinedErrorContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "29", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "30", + "kind": "constant", + "name": "createForUserDefinedErrorContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "31", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + } + ], + "models": [ + { + "$id": "32", + "kind": "model", + "name": "ManagedIdentityTrackedResource", + "namespace": "Azure.ResourceManager.CommonProperties", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResource", + "usage": "Input,Output,Json", + "doc": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.Private.@armResourceInternal", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@resourceSchema", + "arguments": { + "resourceIdPattern": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}", + "resourceType": "Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources", + "methods": [ + { + "$id": "33", + "methodId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get", + "kind": "Get", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}" + }, + { + "$id": "34", + "methodId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned", + "kind": "Create", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}" + }, + { + "$id": "35", + "methodId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned", + "kind": "Update", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}" + } + ], + "resourceScope": "ResourceGroup", + "resourceName": "ManagedIdentityTrackedResource" + } + } + ], + "baseModel": { + "$id": "36", + "kind": "model", + "name": "TrackedResource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource", + "usage": "Input,Output,Json", + "doc": "The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'", + "summary": "Tracked Resource", + "decorators": [], + "baseModel": { + "$id": "37", + "kind": "model", + "name": "Resource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource", + "usage": "Input,Output,Json", + "doc": "Common fields that are returned in the response for all Azure Resource Manager resources", + "summary": "Resource", + "decorators": [], + "properties": [ + { + "$id": "38", + "kind": "property", + "name": "id", + "serializedName": "id", + "doc": "Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}", + "type": { + "$id": "39", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.id", + "serializationOptions": { + "json": { + "name": "id" + } + }, + "isHttpMetadata": false + }, + { + "$id": "40", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the resource", + "type": { + "$id": "41", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "42", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or \"Microsoft.Storage/storageAccounts\"", + "type": { + "$id": "43", + "kind": "string", + "name": "armResourceType", + "crossLanguageDefinitionId": "Azure.Core.armResourceType", + "baseType": { + "$id": "44", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + }, + { + "$id": "45", + "kind": "property", + "name": "systemData", + "serializedName": "systemData", + "doc": "Azure Resource Manager metadata containing createdBy and modifiedBy information.", + "type": { + "$id": "46", + "kind": "model", + "name": "SystemData", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData", + "usage": "Output,Json", + "doc": "Metadata pertaining to creation and last modification of the resource.", + "decorators": [], + "properties": [ + { + "$id": "47", + "kind": "property", + "name": "createdBy", + "serializedName": "createdBy", + "doc": "The identity that created the resource.", + "type": { + "$id": "48", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdBy", + "serializationOptions": { + "json": { + "name": "createdBy" + } + }, + "isHttpMetadata": false + }, + { + "$id": "49", + "kind": "property", + "name": "createdByType", + "serializedName": "createdByType", + "doc": "The type of identity that created the resource.", + "type": { + "$ref": "7" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdByType", + "serializationOptions": { + "json": { + "name": "createdByType" + } + }, + "isHttpMetadata": false + }, + { + "$id": "50", + "kind": "property", + "name": "createdAt", + "serializedName": "createdAt", + "doc": "The timestamp of resource creation (UTC).", + "type": { + "$id": "51", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "52", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdAt", + "serializationOptions": { + "json": { + "name": "createdAt" + } + }, + "isHttpMetadata": false + }, + { + "$id": "53", + "kind": "property", + "name": "lastModifiedBy", + "serializedName": "lastModifiedBy", + "doc": "The identity that last modified the resource.", + "type": { + "$id": "54", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedBy", + "serializationOptions": { + "json": { + "name": "lastModifiedBy" + } + }, + "isHttpMetadata": false + }, + { + "$id": "55", + "kind": "property", + "name": "lastModifiedByType", + "serializedName": "lastModifiedByType", + "doc": "The type of identity that last modified the resource.", + "type": { + "$ref": "7" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedByType", + "serializationOptions": { + "json": { + "name": "lastModifiedByType" + } + }, + "isHttpMetadata": false + }, + { + "$id": "56", + "kind": "property", + "name": "lastModifiedAt", + "serializedName": "lastModifiedAt", + "doc": "The timestamp of resource last modification (UTC)", + "type": { + "$id": "57", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "58", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedAt", + "serializationOptions": { + "json": { + "name": "lastModifiedAt" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.systemData", + "serializationOptions": { + "json": { + "name": "systemData" + } + }, + "isHttpMetadata": false + } + ] + }, + "properties": [ + { + "$id": "59", + "kind": "property", + "name": "tags", + "serializedName": "tags", + "doc": "Resource tags.", + "type": { + "$id": "60", + "kind": "dict", + "keyType": { + "$id": "61", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "valueType": { + "$id": "62", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource.tags", + "serializationOptions": { + "json": { + "name": "tags" + } + }, + "isHttpMetadata": false + }, + { + "$id": "63", + "kind": "property", + "name": "location", + "serializedName": "location", + "doc": "The geo-location where the resource lives", + "type": { + "$id": "64", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "65", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource.location", + "serializationOptions": { + "json": { + "name": "location" + } + }, + "isHttpMetadata": false + } + ] + }, + "properties": [ + { + "$id": "66", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "67", + "kind": "model", + "name": "ManagedIdentityTrackedResourceProperties", + "namespace": "Azure.ResourceManager.CommonProperties", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResourceProperties", + "usage": "Input,Output,Json", + "doc": "Managed Identity Arm Resource Properties.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "68", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The status of the last operation.", + "type": { + "$id": "69", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResourceProperties.provisioningState", + "serializationOptions": { + "json": { + "name": "provisioningState" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResource.properties", + "serializationOptions": { + "json": { + "name": "properties" + } + }, + "isHttpMetadata": false + }, + { + "$id": "70", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "arm resource name for path", + "type": { + "$id": "71", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": true + }, + { + "$id": "72", + "kind": "property", + "name": "identity", + "serializedName": "identity", + "doc": "The managed service identities assigned to this resource.", + "type": { + "$id": "73", + "kind": "model", + "name": "ManagedServiceIdentity", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity", + "usage": "Input,Output,Json", + "doc": "Managed service identity (system assigned and/or user assigned identities)", + "decorators": [], + "properties": [ + { + "$id": "74", + "kind": "property", + "name": "principalId", + "serializedName": "principalId", + "doc": "The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity.", + "type": { + "$id": "75", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "76", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity.principalId", + "serializationOptions": { + "json": { + "name": "principalId" + } + }, + "isHttpMetadata": false + }, + { + "$id": "77", + "kind": "property", + "name": "tenantId", + "serializedName": "tenantId", + "doc": "The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity.", + "type": { + "$id": "78", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "79", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity.tenantId", + "serializationOptions": { + "json": { + "name": "tenantId" + } + }, + "isHttpMetadata": false + }, + { + "$id": "80", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The type of managed identity assigned to this resource.", + "type": { + "$ref": "1" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + }, + { + "$id": "81", + "kind": "property", + "name": "userAssignedIdentities", + "serializedName": "userAssignedIdentities", + "doc": "The identities assigned to this resource by the user.", + "type": { + "$id": "82", + "kind": "dict", + "keyType": { + "$id": "83", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "valueType": { + "$id": "84", + "kind": "model", + "name": "UserAssignedIdentity", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.UserAssignedIdentity", + "usage": "Input,Output,Json", + "doc": "User assigned identity properties", + "decorators": [], + "properties": [ + { + "$id": "85", + "kind": "property", + "name": "principalId", + "serializedName": "principalId", + "doc": "The principal ID of the assigned identity.", + "type": { + "$id": "86", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "87", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.UserAssignedIdentity.principalId", + "serializationOptions": { + "json": { + "name": "principalId" + } + }, + "isHttpMetadata": false + }, + { + "$id": "88", + "kind": "property", + "name": "clientId", + "serializedName": "clientId", + "doc": "The client ID of the assigned identity.", + "type": { + "$id": "89", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "90", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.UserAssignedIdentity.clientId", + "serializationOptions": { + "json": { + "name": "clientId" + } + }, + "isHttpMetadata": false + } + ] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity.userAssignedIdentities", + "serializationOptions": { + "json": { + "name": "userAssignedIdentities" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentityTrackedResource.identity", + "serializationOptions": { + "json": { + "name": "identity" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$ref": "67" + }, + { + "$ref": "73" + }, + { + "$ref": "84" + }, + { + "$ref": "36" + }, + { + "$ref": "37" + }, + { + "$ref": "46" + }, + { + "$id": "91", + "kind": "model", + "name": "ErrorResponse", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "usage": "Json,Exception", + "doc": "Common error response for all Azure Resource Manager APIs to return error details for failed operations.", + "summary": "Error response", + "decorators": [], + "properties": [ + { + "$id": "92", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "The error object.", + "type": { + "$id": "93", + "kind": "model", + "name": "ErrorDetail", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "usage": "Json,Exception", + "doc": "The error detail.", + "decorators": [], + "properties": [ + { + "$id": "94", + "kind": "property", + "name": "code", + "serializedName": "code", + "doc": "The error code.", + "type": { + "$id": "95", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.code", + "serializationOptions": { + "json": { + "name": "code" + } + }, + "isHttpMetadata": false + }, + { + "$id": "96", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "The error message.", + "type": { + "$id": "97", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.message", + "serializationOptions": { + "json": { + "name": "message" + } + }, + "isHttpMetadata": false + }, + { + "$id": "98", + "kind": "property", + "name": "target", + "serializedName": "target", + "doc": "The error target.", + "type": { + "$id": "99", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.target", + "serializationOptions": { + "json": { + "name": "target" + } + }, + "isHttpMetadata": false + }, + { + "$id": "100", + "kind": "property", + "name": "details", + "serializedName": "details", + "doc": "The error details.", + "type": { + "$id": "101", + "kind": "array", + "name": "ArrayErrorDetail", + "valueType": { + "$ref": "93" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.details", + "serializationOptions": { + "json": { + "name": "details" + } + }, + "isHttpMetadata": false + }, + { + "$id": "102", + "kind": "property", + "name": "additionalInfo", + "serializedName": "additionalInfo", + "doc": "The error additional info.", + "type": { + "$id": "103", + "kind": "array", + "name": "ArrayErrorAdditionalInfo", + "valueType": { + "$id": "104", + "kind": "model", + "name": "ErrorAdditionalInfo", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "usage": "Json,Exception", + "doc": "The resource management error additional info.", + "decorators": [], + "properties": [ + { + "$id": "105", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The additional info type.", + "type": { + "$id": "106", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + }, + { + "$id": "107", + "kind": "property", + "name": "info", + "serializedName": "info", + "doc": "The additional info.", + "type": { + "$id": "108", + "kind": "unknown", + "name": "unknown", + "crossLanguageDefinitionId": "", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info", + "serializationOptions": { + "json": { + "name": "info" + } + }, + "isHttpMetadata": false + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.additionalInfo", + "serializationOptions": { + "json": { + "name": "additionalInfo" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse.error", + "serializationOptions": { + "json": { + "name": "error" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$ref": "93" + }, + { + "$ref": "104" + }, + { + "$id": "109", + "kind": "model", + "name": "ConfidentialResource", + "namespace": "Azure.ResourceManager.CommonProperties", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ConfidentialResource", + "usage": "Input,Output,Json", + "doc": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.Private.@armResourceInternal", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@resourceSchema", + "arguments": { + "resourceIdPattern": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}", + "resourceType": "Azure.ResourceManager.CommonProperties/confidentialResources", + "methods": [ + { + "$id": "110", + "methodId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError", + "kind": "Get", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}" + }, + { + "$id": "111", + "methodId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError", + "kind": "Create", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}" + } + ], + "resourceScope": "ResourceGroup", + "resourceName": "ConfidentialResource" + } + } + ], + "baseModel": { + "$ref": "36" + }, + "properties": [ + { + "$id": "112", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "113", + "kind": "model", + "name": "ConfidentialResourceProperties", + "namespace": "Azure.ResourceManager.CommonProperties", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ConfidentialResourceProperties", + "usage": "Input,Output,Json", + "doc": "Confidential Resource Properties.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "114", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The status of the last operation.", + "type": { + "$id": "115", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ConfidentialResourceProperties.provisioningState", + "serializationOptions": { + "json": { + "name": "provisioningState" + } + }, + "isHttpMetadata": false + }, + { + "$id": "116", + "kind": "property", + "name": "username", + "serializedName": "username", + "type": { + "$id": "117", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ConfidentialResourceProperties.username", + "serializationOptions": { + "json": { + "name": "username" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ConfidentialResource.properties", + "serializationOptions": { + "json": { + "name": "properties" + } + }, + "isHttpMetadata": false + }, + { + "$id": "118", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the ConfidentialResource", + "type": { + "$id": "119", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ConfidentialResource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": true + } + ] + }, + { + "$ref": "113" + }, + { + "$id": "120", + "kind": "model", + "name": "CloudError", + "namespace": "Azure.ResourceManager.CommonProperties", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.CloudError", + "usage": "Json,Exception", + "doc": "An error response.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "121", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "Api error.", + "type": { + "$id": "122", + "kind": "model", + "name": "ApiError", + "namespace": "Azure.ResourceManager.CommonProperties", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiError", + "usage": "Json,Exception", + "doc": "Api error.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "123", + "kind": "property", + "name": "details", + "serializedName": "details", + "doc": "The Api error details", + "type": { + "$id": "124", + "kind": "array", + "name": "ArrayApiErrorBase", + "valueType": { + "$id": "125", + "kind": "model", + "name": "ApiErrorBase", + "namespace": "Azure.ResourceManager.CommonProperties", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiErrorBase", + "usage": "Json,Exception", + "doc": "Api error base.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "126", + "kind": "property", + "name": "code", + "serializedName": "code", + "doc": "The error code.", + "type": { + "$id": "127", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiErrorBase.code", + "serializationOptions": { + "json": { + "name": "code" + } + }, + "isHttpMetadata": false + }, + { + "$id": "128", + "kind": "property", + "name": "target", + "serializedName": "target", + "doc": "The target of the particular error.", + "type": { + "$id": "129", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiErrorBase.target", + "serializationOptions": { + "json": { + "name": "target" + } + }, + "isHttpMetadata": false + }, + { + "$id": "130", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "The error message.", + "type": { + "$id": "131", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiErrorBase.message", + "serializationOptions": { + "json": { + "name": "message" + } + }, + "isHttpMetadata": false + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiError.details", + "serializationOptions": { + "json": { + "name": "details" + } + }, + "isHttpMetadata": false + }, + { + "$id": "132", + "kind": "property", + "name": "innererror", + "serializedName": "innererror", + "doc": "The Api inner error", + "type": { + "$id": "133", + "kind": "model", + "name": "InnerError", + "namespace": "Azure.ResourceManager.CommonProperties", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.InnerError", + "usage": "Json,Exception", + "doc": "Inner error details.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "134", + "kind": "property", + "name": "exceptiontype", + "serializedName": "exceptiontype", + "doc": "The exception type.", + "type": { + "$id": "135", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.InnerError.exceptiontype", + "serializationOptions": { + "json": { + "name": "exceptiontype" + } + }, + "isHttpMetadata": false + }, + { + "$id": "136", + "kind": "property", + "name": "errordetail", + "serializedName": "errordetail", + "doc": "The internal error message or exception dump.", + "type": { + "$id": "137", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.InnerError.errordetail", + "serializationOptions": { + "json": { + "name": "errordetail" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiError.innererror", + "serializationOptions": { + "json": { + "name": "innererror" + } + }, + "isHttpMetadata": false + }, + { + "$id": "138", + "kind": "property", + "name": "code", + "serializedName": "code", + "doc": "The error code.", + "type": { + "$id": "139", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiError.code", + "serializationOptions": { + "json": { + "name": "code" + } + }, + "isHttpMetadata": false + }, + { + "$id": "140", + "kind": "property", + "name": "target", + "serializedName": "target", + "doc": "The target of the particular error.", + "type": { + "$id": "141", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiError.target", + "serializationOptions": { + "json": { + "name": "target" + } + }, + "isHttpMetadata": false + }, + { + "$id": "142", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "The error message.", + "type": { + "$id": "143", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ApiError.message", + "serializationOptions": { + "json": { + "name": "message" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.CloudError.error", + "serializationOptions": { + "json": { + "name": "error" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$ref": "122" + }, + { + "$ref": "125" + }, + { + "$ref": "133" + } + ], + "clients": [ + { + "$id": "144", + "kind": "client", + "name": "CommonPropertiesClient", + "namespace": "Azure.ResourceManager.CommonProperties", + "doc": "Arm Managed Identity Provider management API.", + "methods": [], + "parameters": [ + { + "$id": "145", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "146", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "147", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.endpoint" + }, + { + "$id": "148", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "149", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "150", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "151", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "152", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 1, + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@nonResourceMethodSchema", + "arguments": { + "nonResourceMethods": [] + } + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties", + "apiVersions": [ + "2023-12-01-preview" + ], + "children": [ + { + "$id": "153", + "kind": "client", + "name": "ManagedIdentity", + "namespace": "Azure.ResourceManager.CommonProperties", + "methods": [ + { + "$id": "154", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Get a ManagedIdentityTrackedResource", + "operation": { + "$id": "155", + "name": "get", + "resourceName": "ManagedIdentityTrackedResource", + "doc": "Get a ManagedIdentityTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "156", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "157", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "158", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.apiVersion", + "readOnly": false + }, + { + "$id": "159", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "160", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.subscriptionId" + }, + { + "$id": "161", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "162", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.resourceGroupName" + }, + { + "$id": "163", + "kind": "path", + "name": "managedIdentityTrackedResourceName", + "serializedName": "managedIdentityTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "164", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.managedIdentityTrackedResourceName" + }, + { + "$id": "165", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "16" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "32" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceRead", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "166", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "167", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "168", + "kind": "method", + "name": "managedIdentityTrackedResourceName", + "serializedName": "managedIdentityTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "169", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.managedIdentityTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "170", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "16" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "32" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.get" + }, + { + "$id": "171", + "kind": "basic", + "name": "createWithSystemAssigned", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Create a ManagedIdentityTrackedResource", + "operation": { + "$id": "172", + "name": "createWithSystemAssigned", + "resourceName": "ManagedIdentityTrackedResource", + "doc": "Create a ManagedIdentityTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "173", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "174", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "175", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.apiVersion", + "readOnly": false + }, + { + "$id": "176", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "177", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.subscriptionId" + }, + { + "$id": "178", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "179", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.resourceGroupName" + }, + { + "$id": "180", + "kind": "path", + "name": "managedIdentityTrackedResourceName", + "serializedName": "managedIdentityTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "181", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.managedIdentityTrackedResourceName" + }, + { + "$id": "182", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "18" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.contentType" + }, + { + "$id": "183", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "20" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.accept" + }, + { + "$id": "184", + "kind": "body", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "32" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.resource" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "32" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 201 + ], + "bodyType": { + "$ref": "32" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceCreateOrUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "185", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "186", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "187", + "kind": "method", + "name": "managedIdentityTrackedResourceName", + "serializedName": "managedIdentityTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "188", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.managedIdentityTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "189", + "kind": "method", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "32" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.resource", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "190", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "18" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "191", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "20" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "32" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.createWithSystemAssigned" + }, + { + "$id": "192", + "kind": "basic", + "name": "updateWithUserAssignedAndSystemAssigned", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Update a ManagedIdentityTrackedResource", + "operation": { + "$id": "193", + "name": "updateWithUserAssignedAndSystemAssigned", + "resourceName": "ManagedIdentityTrackedResource", + "doc": "Update a ManagedIdentityTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "194", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "195", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "196", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.apiVersion", + "readOnly": false + }, + { + "$id": "197", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "198", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.subscriptionId" + }, + { + "$id": "199", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "200", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.resourceGroupName" + }, + { + "$id": "201", + "kind": "path", + "name": "managedIdentityTrackedResourceName", + "serializedName": "managedIdentityTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "202", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.managedIdentityTrackedResourceName" + }, + { + "$id": "203", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "22" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.contentType" + }, + { + "$id": "204", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "24" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.accept" + }, + { + "$id": "205", + "kind": "body", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "32" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.properties" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "32" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PATCH", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "206", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "207", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "208", + "kind": "method", + "name": "managedIdentityTrackedResourceName", + "serializedName": "managedIdentityTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "209", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.managedIdentityTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "210", + "kind": "method", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "32" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.properties", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "211", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "22" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "212", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "24" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "32" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity.updateWithUserAssignedAndSystemAssigned" + } + ], + "parameters": [ + { + "$id": "213", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "214", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "215", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.endpoint" + }, + { + "$ref": "148" + }, + { + "$ref": "151" + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.ManagedIdentity", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "144" + } + }, + { + "$id": "216", + "kind": "client", + "name": "Error", + "namespace": "Azure.ResourceManager.CommonProperties", + "methods": [ + { + "$id": "217", + "kind": "basic", + "name": "getForPredefinedError", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Get a ConfidentialResource", + "operation": { + "$id": "218", + "name": "getForPredefinedError", + "resourceName": "ConfidentialResource", + "doc": "Get a ConfidentialResource", + "accessibility": "public", + "parameters": [ + { + "$id": "219", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "220", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "221", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.apiVersion", + "readOnly": false + }, + { + "$id": "222", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "223", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.subscriptionId" + }, + { + "$id": "224", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "225", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.resourceGroupName" + }, + { + "$id": "226", + "kind": "path", + "name": "confidentialResourceName", + "serializedName": "confidentialResourceName", + "doc": "The name of the ConfidentialResource", + "type": { + "$id": "227", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.confidentialResourceName" + }, + { + "$id": "228", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "26" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "109" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceRead", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "229", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "230", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "231", + "kind": "method", + "name": "confidentialResourceName", + "serializedName": "confidentialResourceName", + "doc": "The name of the ConfidentialResource", + "type": { + "$id": "232", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.confidentialResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "233", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "26" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "109" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError" + }, + { + "$id": "234", + "kind": "basic", + "name": "createForUserDefinedError", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Create a ConfidentialResource", + "operation": { + "$id": "235", + "name": "createForUserDefinedError", + "resourceName": "ConfidentialResource", + "doc": "Create a ConfidentialResource", + "accessibility": "public", + "parameters": [ + { + "$id": "236", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "237", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "238", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.apiVersion", + "readOnly": false + }, + { + "$id": "239", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "240", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.subscriptionId" + }, + { + "$id": "241", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "242", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.resourceGroupName" + }, + { + "$id": "243", + "kind": "path", + "name": "confidentialResourceName", + "serializedName": "confidentialResourceName", + "doc": "The name of the ConfidentialResource", + "type": { + "$id": "244", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.confidentialResourceName" + }, + { + "$id": "245", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "28" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.contentType" + }, + { + "$id": "246", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "30" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.accept" + }, + { + "$id": "247", + "kind": "body", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "109" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.resource" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "109" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 201 + ], + "bodyType": { + "$ref": "109" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/confidentialResources/{confidentialResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceCreateOrUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "248", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "249", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "250", + "kind": "method", + "name": "confidentialResourceName", + "serializedName": "confidentialResourceName", + "doc": "The name of the ConfidentialResource", + "type": { + "$id": "251", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.confidentialResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "252", + "kind": "method", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "109" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.resource", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "253", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "28" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "254", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "30" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "109" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.createForUserDefinedError" + } + ], + "parameters": [ + { + "$id": "255", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "256", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "257", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.endpoint" + }, + { + "$id": "258", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "259", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "260", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "261", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "262", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error.getForPredefinedError.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonProperties.Error", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "144" + } + } + ] + } + ], + "auth": { + "oAuth2": { + "flows": [ + { + "scopes": [ + "user_impersonation" + ], + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize" + } + ] + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/Azure.ResourceManager.LargeHeader.sln b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/Azure.ResourceManager.LargeHeader.sln new file mode 100644 index 000000000000..954c7cc66284 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/Azure.ResourceManager.LargeHeader.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.LargeHeader", "src\Azure.ResourceManager.LargeHeader.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/Configuration.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/Configuration.json new file mode 100644 index 000000000000..8ede32f1d9a9 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/Configuration.json @@ -0,0 +1,11 @@ +{ + "package-name": "Azure.ResourceManager.LargeHeader", + "model-namespace": true, + "license": { + "name": "MIT License", + "company": "Microsoft Corporation", + "link": "https://mit-license.org", + "header": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.", + "description": "Copyright (c) Microsoft Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the “Software”), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE." + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Azure.ResourceManager.LargeHeader.csproj b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Azure.ResourceManager.LargeHeader.csproj new file mode 100644 index 000000000000..63e75cdc4863 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Azure.ResourceManager.LargeHeader.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.LargeHeader client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.LargeHeader + 1.0.0-beta.1 + Azure.ResourceManager.LargeHeader + true + + diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Extensions/LargeHeaderExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Extensions/LargeHeaderExtensions.cs new file mode 100644 index 000000000000..0388da2cbacd --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Extensions/LargeHeaderExtensions.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.LargeHeader +{ + /// A class to add extension methods to Azure.ResourceManager.LargeHeader. + public static partial class LargeHeaderExtensions + { + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenMemberAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..6172f3030ff7 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.LargeHeader +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenSerializationAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..776f03424a3e --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.LargeHeader +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenSuppressAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..91d9514158f8 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.LargeHeader +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenTypeAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..b12e5417c3cf --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.LargeHeader +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..f8bee3f48bee --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.LargeHeader +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/SerializationFormat.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..1bfdbe15fc56 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.LargeHeader +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/TypeFormatters.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..3ae0f15bebd0 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.LargeHeader +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Models/AzureResourceManagerLargeHeaderContext.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Models/AzureResourceManagerLargeHeaderContext.cs new file mode 100644 index 000000000000..fc894e365eaf --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Models/AzureResourceManagerLargeHeaderContext.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; + +namespace Azure.ResourceManager.LargeHeader +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(ResponseError))] + public partial class AzureResourceManagerLargeHeaderContext : ModelReaderWriterContext + { + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/tspCodeModel.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/tspCodeModel.json new file mode 100644 index 000000000000..c14ca10b972a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/large-header/tspCodeModel.json @@ -0,0 +1,1136 @@ +{ + "name": "Azure.ResourceManager.LargeHeader", + "apiVersions": [ + "2023-12-01-preview" + ], + "enums": [ + { + "$id": "1", + "kind": "enum", + "name": "ResourceProvisioningState", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceProvisioningState", + "valueType": { + "$id": "2", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "3", + "kind": "enumvalue", + "name": "Succeeded", + "value": "Succeeded", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Resource has been created.", + "decorators": [] + }, + { + "$id": "4", + "kind": "enumvalue", + "name": "Failed", + "value": "Failed", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Resource creation failed.", + "decorators": [] + }, + { + "$id": "5", + "kind": "enumvalue", + "name": "Canceled", + "value": "Canceled", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Resource creation was canceled.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager", + "doc": "The provisioning state of a resource type.", + "isFixed": false, + "isFlags": false, + "usage": "LroPolling", + "decorators": [] + }, + { + "$id": "6", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.Versions", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "8", + "kind": "enumvalue", + "name": "v2023_12_01_preview", + "value": "2023-12-01-preview", + "valueType": { + "$ref": "7" + }, + "enumType": { + "$ref": "6" + }, + "doc": "Preview API version 2023-12-01-preview.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.LargeHeader", + "doc": "Azure API versions.", + "isFixed": true, + "isFlags": false, + "usage": "ApiVersionEnum", + "decorators": [] + } + ], + "constants": [ + { + "$id": "9", + "kind": "constant", + "name": "two6kContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "10", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "11", + "kind": "constant", + "name": "two6kContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "12", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + } + ], + "models": [ + { + "$id": "13", + "kind": "model", + "name": "CancelResult", + "namespace": "Azure.ResourceManager.LargeHeader", + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.CancelResult", + "usage": "Output,Json,LroInitial,LroFinalEnvelope", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "14", + "kind": "property", + "name": "succeeded", + "serializedName": "succeeded", + "type": { + "$id": "15", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.CancelResult.succeeded", + "serializationOptions": { + "json": { + "name": "succeeded" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "16", + "kind": "model", + "name": "ErrorResponse", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "usage": "Json,Exception", + "doc": "Common error response for all Azure Resource Manager APIs to return error details for failed operations.", + "summary": "Error response", + "decorators": [], + "properties": [ + { + "$id": "17", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "The error object.", + "type": { + "$id": "18", + "kind": "model", + "name": "ErrorDetail", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "usage": "Json,Exception,LroPolling", + "doc": "The error detail.", + "decorators": [], + "properties": [ + { + "$id": "19", + "kind": "property", + "name": "code", + "serializedName": "code", + "doc": "The error code.", + "type": { + "$id": "20", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.code", + "serializationOptions": { + "json": { + "name": "code" + } + }, + "isHttpMetadata": false + }, + { + "$id": "21", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "The error message.", + "type": { + "$id": "22", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.message", + "serializationOptions": { + "json": { + "name": "message" + } + }, + "isHttpMetadata": false + }, + { + "$id": "23", + "kind": "property", + "name": "target", + "serializedName": "target", + "doc": "The error target.", + "type": { + "$id": "24", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.target", + "serializationOptions": { + "json": { + "name": "target" + } + }, + "isHttpMetadata": false + }, + { + "$id": "25", + "kind": "property", + "name": "details", + "serializedName": "details", + "doc": "The error details.", + "type": { + "$id": "26", + "kind": "array", + "name": "ArrayErrorDetail", + "valueType": { + "$ref": "18" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.details", + "serializationOptions": { + "json": { + "name": "details" + } + }, + "isHttpMetadata": false + }, + { + "$id": "27", + "kind": "property", + "name": "additionalInfo", + "serializedName": "additionalInfo", + "doc": "The error additional info.", + "type": { + "$id": "28", + "kind": "array", + "name": "ArrayErrorAdditionalInfo", + "valueType": { + "$id": "29", + "kind": "model", + "name": "ErrorAdditionalInfo", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "usage": "Json,Exception,LroPolling", + "doc": "The resource management error additional info.", + "decorators": [], + "properties": [ + { + "$id": "30", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The additional info type.", + "type": { + "$id": "31", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + }, + { + "$id": "32", + "kind": "property", + "name": "info", + "serializedName": "info", + "doc": "The additional info.", + "type": { + "$id": "33", + "kind": "unknown", + "name": "unknown", + "crossLanguageDefinitionId": "", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info", + "serializationOptions": { + "json": { + "name": "info" + } + }, + "isHttpMetadata": false + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.additionalInfo", + "serializationOptions": { + "json": { + "name": "additionalInfo" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse.error", + "serializationOptions": { + "json": { + "name": "error" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$ref": "18" + }, + { + "$ref": "29" + }, + { + "$id": "34", + "kind": "model", + "name": "ArmOperationStatusResourceProvisioningState", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus", + "usage": "LroPolling", + "doc": "Standard Azure Resource Manager operation status response", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "35", + "kind": "property", + "name": "status", + "serializedName": "status", + "doc": "The operation status", + "type": { + "$ref": "1" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.status", + "serializationOptions": { + "json": { + "name": "status" + } + }, + "isHttpMetadata": false + }, + { + "$id": "36", + "kind": "property", + "name": "id", + "serializedName": "id", + "doc": "The unique identifier for the operationStatus resource", + "type": { + "$id": "37", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.id", + "serializationOptions": { + "json": { + "name": "id" + } + }, + "isHttpMetadata": true + }, + { + "$id": "38", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the operationStatus resource", + "type": { + "$id": "39", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "40", + "kind": "property", + "name": "startTime", + "serializedName": "startTime", + "doc": "Operation start time", + "type": { + "$id": "41", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "42", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.startTime", + "serializationOptions": { + "json": { + "name": "startTime" + } + }, + "isHttpMetadata": false + }, + { + "$id": "43", + "kind": "property", + "name": "endTime", + "serializedName": "endTime", + "doc": "Operation complete time", + "type": { + "$id": "44", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "45", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.endTime", + "serializationOptions": { + "json": { + "name": "endTime" + } + }, + "isHttpMetadata": false + }, + { + "$id": "46", + "kind": "property", + "name": "percentComplete", + "serializedName": "percentComplete", + "doc": "The progress made toward completing the operation", + "type": { + "$id": "47", + "kind": "float64", + "name": "float64", + "crossLanguageDefinitionId": "TypeSpec.float64", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.percentComplete", + "serializationOptions": { + "json": { + "name": "percentComplete" + } + }, + "isHttpMetadata": false + }, + { + "$id": "48", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "Errors that occurred if the operation ended with Canceled or Failed status", + "type": { + "$ref": "18" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.error", + "serializationOptions": { + "json": { + "name": "error" + } + }, + "isHttpMetadata": false + } + ] + } + ], + "clients": [ + { + "$id": "49", + "kind": "client", + "name": "LargeHeaderClient", + "namespace": "Azure.ResourceManager.LargeHeader", + "doc": "Arm Resource Provider management API.", + "methods": [], + "parameters": [ + { + "$id": "50", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "51", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "52", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.endpoint" + }, + { + "$id": "53", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "54", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "55", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "56", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "57", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "58", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 1, + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@nonResourceMethodSchema", + "arguments": { + "nonResourceMethods": [] + } + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader", + "apiVersions": [ + "2023-12-01-preview" + ], + "children": [ + { + "$id": "59", + "kind": "client", + "name": "LargeHeaders", + "namespace": "Azure.ResourceManager.LargeHeader", + "methods": [ + { + "$id": "60", + "kind": "lro", + "name": "two6k", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "A long-running resource action.", + "operation": { + "$id": "61", + "name": "two6k", + "resourceName": "LargeHeaders", + "doc": "A long-running resource action.", + "accessibility": "public", + "parameters": [ + { + "$id": "62", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "63", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "64", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.apiVersion", + "readOnly": false + }, + { + "$id": "65", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "66", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "67", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.subscriptionId" + }, + { + "$id": "68", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "69", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.resourceGroupName" + }, + { + "$id": "70", + "kind": "path", + "name": "largeHeaderName", + "serializedName": "largeHeaderName", + "doc": "The name of the LargeHeader", + "type": { + "$id": "71", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.largeHeaderName" + }, + { + "$id": "72", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "9" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 202 + ], + "headers": [ + { + "name": "azureAsyncOperation", + "nameInResponse": "Azure-AsyncOperation", + "doc": "A link to the status monitor", + "type": { + "$id": "73", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "74", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + } + }, + { + "name": "location", + "nameInResponse": "Location", + "doc": "The Location header contains the URL where the status of the long running operation can be checked.", + "type": { + "$id": "75", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "76", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false + }, + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "13" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.LargeHeader/largeHeaders/{largeHeaderName}/two6k", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceAction", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "77", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "78", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "79", + "kind": "method", + "name": "largeHeaderName", + "serializedName": "largeHeaderName", + "doc": "The name of the LargeHeader", + "type": { + "$id": "80", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.largeHeaderName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "81", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "11" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "13" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k", + "lroMetadata": { + "finalStateVia": 1, + "finalResponse": { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "13" + } + } + } + } + ], + "parameters": [ + { + "$id": "82", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "83", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "84", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.endpoint" + }, + { + "$ref": "53" + }, + { + "$ref": "56" + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "49" + } + } + ] + } + ], + "auth": { + "oAuth2": { + "flows": [ + { + "scopes": [ + "user_impersonation" + ], + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize" + } + ] + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/Azure.ResourceManager.NonResource.sln b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/Azure.ResourceManager.NonResource.sln new file mode 100644 index 000000000000..25d7a3603310 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/Azure.ResourceManager.NonResource.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.NonResource", "src\Azure.ResourceManager.NonResource.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/Configuration.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/Configuration.json new file mode 100644 index 000000000000..10f0fff807d1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/Configuration.json @@ -0,0 +1,11 @@ +{ + "package-name": "Azure.ResourceManager.NonResource", + "model-namespace": true, + "license": { + "name": "MIT License", + "company": "Microsoft Corporation", + "link": "https://mit-license.org", + "header": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.", + "description": "Copyright (c) Microsoft Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the “Software”), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE." + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Azure.ResourceManager.NonResource.csproj b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Azure.ResourceManager.NonResource.csproj new file mode 100644 index 000000000000..bc19719a239f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Azure.ResourceManager.NonResource.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.NonResource client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.NonResource + 1.0.0-beta.1 + Azure.ResourceManager.NonResource + true + + diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Extensions/MockableNonResourceSubscriptionResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Extensions/MockableNonResourceSubscriptionResource.cs new file mode 100644 index 000000000000..3f88f07a9499 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Extensions/MockableNonResourceSubscriptionResource.cs @@ -0,0 +1,251 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.NonResource; +using Azure.ResourceManager.NonResource.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.NonResource.Mocking +{ + /// A class to add extension methods to . + public partial class MockableNonResourceSubscriptionResource : ArmResource + { + private ClientDiagnostics _nonResourceOperationsClientDiagnostics; + private NonResourceOperations _nonResourceOperationsRestClient; + + /// Initializes a new instance of MockableNonResourceSubscriptionResource for mocking. + protected MockableNonResourceSubscriptionResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableNonResourceSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics NonResourceOperationsClientDiagnostics => _nonResourceOperationsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.NonResource.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private NonResourceOperations NonResourceOperationsRestClient => _nonResourceOperationsRestClient ??= new NonResourceOperations(NonResourceOperationsClientDiagnostics, Pipeline, Endpoint, "2023-12-01-preview"); + + /// + /// Get + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.NonResource/locations/{location}/otherParameters/{parameter}. + /// + /// + /// Operation Id. + /// NonResourceOperations_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The location parameter. + /// Another parameter. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string location, string parameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + Argument.AssertNotNullOrEmpty(parameter, nameof(parameter)); + + using DiagnosticScope scope = NonResourceOperationsClientDiagnostics.CreateScope("MockableNonResourceSubscriptionResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = NonResourceOperationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), location, parameter, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(Models.NonResource.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.NonResource/locations/{location}/otherParameters/{parameter}. + /// + /// + /// Operation Id. + /// NonResourceOperations_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The location parameter. + /// Another parameter. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response Get(string location, string parameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + Argument.AssertNotNullOrEmpty(parameter, nameof(parameter)); + + using DiagnosticScope scope = NonResourceOperationsClientDiagnostics.CreateScope("MockableNonResourceSubscriptionResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = NonResourceOperationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), location, parameter, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(Models.NonResource.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.NonResource/locations/{location}/otherParameters/{parameter}. + /// + /// + /// Operation Id. + /// NonResourceOperations_Create. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The location parameter. + /// Another parameter. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> CreateAsync(string location, string parameter, Models.NonResource body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + Argument.AssertNotNullOrEmpty(parameter, nameof(parameter)); + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = NonResourceOperationsClientDiagnostics.CreateScope("MockableNonResourceSubscriptionResource.Create"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = NonResourceOperationsRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), location, parameter, Models.NonResource.ToRequestContent(body), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(Models.NonResource.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.NonResource/locations/{location}/otherParameters/{parameter}. + /// + /// + /// Operation Id. + /// NonResourceOperations_Create. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The location parameter. + /// Another parameter. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response Create(string location, string parameter, Models.NonResource body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + Argument.AssertNotNullOrEmpty(parameter, nameof(parameter)); + Argument.AssertNotNull(body, nameof(body)); + + using DiagnosticScope scope = NonResourceOperationsClientDiagnostics.CreateScope("MockableNonResourceSubscriptionResource.Create"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = NonResourceOperationsRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), location, parameter, Models.NonResource.ToRequestContent(body), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(Models.NonResource.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Extensions/NonResourceExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Extensions/NonResourceExtensions.cs new file mode 100644 index 000000000000..f34139a51a71 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Extensions/NonResourceExtensions.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.ResourceManager.NonResource.Mocking; +using Azure.ResourceManager.NonResource.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.NonResource +{ + /// A class to add extension methods to Azure.ResourceManager.NonResource. + public static partial class NonResourceExtensions + { + /// + private static MockableNonResourceSubscriptionResource GetMockableNonResourceSubscriptionResource(SubscriptionResource subscriptionResource) + { + return subscriptionResource.GetCachedClient(client => new MockableNonResourceSubscriptionResource(client, subscriptionResource.Id)); + } + + /// + /// Get + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The location parameter. + /// Another parameter. + /// The cancellation token to use. + /// is null. + public static async Task> GetAsync(this SubscriptionResource subscriptionResource, string location, string parameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableNonResourceSubscriptionResource(subscriptionResource).GetAsync(location, parameter, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The location parameter. + /// Another parameter. + /// The cancellation token to use. + /// is null. + public static Response Get(this SubscriptionResource subscriptionResource, string location, string parameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNonResourceSubscriptionResource(subscriptionResource).Get(location, parameter, cancellationToken); + } + + /// + /// Create + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The location parameter. + /// Another parameter. + /// The request body. + /// The cancellation token to use. + /// is null. + public static async Task> CreateAsync(this SubscriptionResource subscriptionResource, string location, string parameter, Models.NonResource body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableNonResourceSubscriptionResource(subscriptionResource).CreateAsync(location, parameter, body, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The location parameter. + /// Another parameter. + /// The request body. + /// The cancellation token to use. + /// is null. + public static Response Create(this SubscriptionResource subscriptionResource, string location, string parameter, Models.NonResource body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNonResourceSubscriptionResource(subscriptionResource).Create(location, parameter, body, cancellationToken); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/Argument.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..5df0d9d2d264 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/Argument.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.NonResource +{ + internal static partial class Argument + { + /// The value. + /// The name. + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ChangeTrackingDictionary.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..2533d60f6249 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.NonResource +{ + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerDictionary == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + /// Gets the Keys. + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + /// Gets the Values. + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + /// Gets or sets the value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + /// Gets the Keys. + IEnumerable IReadOnlyDictionary.Keys => Keys; + + /// Gets the Values. + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + /// The item to search for. + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + /// The array to copy. + /// The index. + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + /// The item to remove. + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + /// The key. + /// The value to add. + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + /// The key to search for. + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + /// The key. + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + /// The key to search for. + /// The value. + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ChangeTrackingList.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..2dd1cfcd5bb6 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.NonResource +{ + internal partial class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + /// The inner list. + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + /// The inner list. + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerList == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureList().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + /// Gets or sets the value associated with the specified key. + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + /// The item. + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + /// The array to copy to. + /// The array index. + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + /// The item. + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + /// The item. + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + /// The inner list. + /// The item. + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + /// The inner list. + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ClientPipelineExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..0ab2445e2610 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.NonResource +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenMemberAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..819e7690c2d1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.NonResource +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenSerializationAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..38d741b1d146 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.NonResource +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenSuppressAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..351086d09926 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.NonResource +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenTypeAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..dda5e696ea29 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.NonResource +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ErrorResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..ad2971ab6ab2 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.ResourceManager.NonResource +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ModelSerializationExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..b9d2aab049c5 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; + +namespace Azure.ResourceManager.NonResource +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + Dictionary dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + List list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/Optional.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..ec19af857a48 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.NonResource +{ + internal static partial class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(string value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..d85a668a7ab7 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.NonResource +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/RequestContextExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..b50b69faf29b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.NonResource +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/SerializationFormat.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..9c2267e40113 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.NonResource +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/TypeFormatters.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..8bb79b7c2eb1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.NonResource +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/Utf8JsonRequestContent.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..5a5e096b959b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.NonResource +{ + internal partial class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + /// Gets the JsonWriter. + public Utf8JsonWriter JsonWriter { get; } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + /// + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Models/AzureResourceManagerNonResourceContext.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Models/AzureResourceManagerNonResourceContext.cs new file mode 100644 index 000000000000..d3a052ccbe8d --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Models/AzureResourceManagerNonResourceContext.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.NonResource.Models; + +namespace Azure.ResourceManager.NonResource +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(Models.NonResource))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + public partial class AzureResourceManagerNonResourceContext : ModelReaderWriterContext + { + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Models/NonResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Models/NonResource.Serialization.cs new file mode 100644 index 000000000000..cbfe9d56fdac --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Models/NonResource.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.NonResource; + +namespace Azure.ResourceManager.NonResource.Models +{ + /// Though this model has `id`, `name`, `type` properties, it is not a resource as it doesn't extends `Resource`. + public partial class NonResource : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NonResource)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + NonResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual NonResource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NonResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNonResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NonResource DeserializeNonResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string name = default; + string @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new NonResource(id, name, @type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNonResourceContext.Default); + default: + throw new FormatException($"The model {nameof(NonResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + NonResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual NonResource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeNonResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NonResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(NonResource nonResource) + { + if (nonResource == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(nonResource, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static NonResource FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNonResource(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Models/NonResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Models/NonResource.cs new file mode 100644 index 000000000000..d755984c8a41 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/Models/NonResource.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.NonResource.Models +{ + /// Though this model has `id`, `name`, `type` properties, it is not a resource as it doesn't extends `Resource`. + public partial class NonResource + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public NonResource() + { + } + + /// Initializes a new instance of . + /// An id. + /// A name. + /// A type. + /// Keeps track of any properties unknown to the library. + internal NonResource(string id, string name, string @type, IDictionary additionalBinaryDataProperties) + { + Id = id; + Name = name; + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// An id. + public string Id { get; set; } + + /// A name. + public string Name { get; set; } + + /// A type. + public string Type { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/ProviderConstants.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..e45e42a8c771 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/ProviderConstants.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.NonResource +{ + internal static partial class ProviderConstants + { + /// Gets the DefaultProviderNamespace. + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/RestOperations/NonResourceOperationsRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/RestOperations/NonResourceOperationsRestOperations.cs new file mode 100644 index 000000000000..501e74029faf --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/src/Generated/RestOperations/NonResourceOperationsRestOperations.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.NonResource +{ + internal partial class NonResourceOperations + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NonResourceOperations for mocking. + protected NonResourceOperations() + { + } + + /// Initializes a new instance of NonResourceOperations. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal NonResourceOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string location, string parameter, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Microsoft.NonResource/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/otherParameters/", false); + uri.AppendPath(parameter, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateRequest(Guid subscriptionId, string location, string parameter, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Microsoft.NonResource/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/otherParameters/", false); + uri.AppendPath(parameter, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/tspCodeModel.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/tspCodeModel.json new file mode 100644 index 000000000000..e59e72b85c79 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/non-resource/tspCodeModel.json @@ -0,0 +1,1187 @@ +{ + "name": "Azure.ResourceManager.NonResource", + "apiVersions": [ + "2023-12-01-preview" + ], + "enums": [ + { + "$id": "1", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.Versions", + "valueType": { + "$id": "2", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "3", + "kind": "enumvalue", + "name": "v2023_12_01_preview", + "value": "2023-12-01-preview", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Preview API version 2023-12-01-preview.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.NonResource", + "doc": "Azure API versions.", + "isFixed": true, + "isFlags": false, + "usage": "ApiVersionEnum", + "decorators": [] + } + ], + "constants": [ + { + "$id": "4", + "kind": "constant", + "name": "getContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "6", + "kind": "constant", + "name": "createContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "8", + "kind": "constant", + "name": "createContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "9", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + } + ], + "models": [ + { + "$id": "10", + "kind": "model", + "name": "NonResource", + "namespace": "Azure.ResourceManager.NonResource", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResource", + "usage": "Input,Output,Json", + "doc": "Though this model has `id`, `name`, `type` properties, it is not a resource as it doesn't extends `Resource`.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "11", + "kind": "property", + "name": "id", + "serializedName": "id", + "doc": "An id.", + "type": { + "$id": "12", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResource.id", + "serializationOptions": { + "json": { + "name": "id" + } + }, + "isHttpMetadata": false + }, + { + "$id": "13", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "A name.", + "type": { + "$id": "14", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "15", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "A type.", + "type": { + "$id": "16", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResource.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "17", + "kind": "model", + "name": "ErrorResponse", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "usage": "Json,Exception", + "doc": "Common error response for all Azure Resource Manager APIs to return error details for failed operations.", + "summary": "Error response", + "decorators": [], + "properties": [ + { + "$id": "18", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "The error object.", + "type": { + "$id": "19", + "kind": "model", + "name": "ErrorDetail", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "usage": "Json,Exception", + "doc": "The error detail.", + "decorators": [], + "properties": [ + { + "$id": "20", + "kind": "property", + "name": "code", + "serializedName": "code", + "doc": "The error code.", + "type": { + "$id": "21", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.code", + "serializationOptions": { + "json": { + "name": "code" + } + }, + "isHttpMetadata": false + }, + { + "$id": "22", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "The error message.", + "type": { + "$id": "23", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.message", + "serializationOptions": { + "json": { + "name": "message" + } + }, + "isHttpMetadata": false + }, + { + "$id": "24", + "kind": "property", + "name": "target", + "serializedName": "target", + "doc": "The error target.", + "type": { + "$id": "25", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.target", + "serializationOptions": { + "json": { + "name": "target" + } + }, + "isHttpMetadata": false + }, + { + "$id": "26", + "kind": "property", + "name": "details", + "serializedName": "details", + "doc": "The error details.", + "type": { + "$id": "27", + "kind": "array", + "name": "ArrayErrorDetail", + "valueType": { + "$ref": "19" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.details", + "serializationOptions": { + "json": { + "name": "details" + } + }, + "isHttpMetadata": false + }, + { + "$id": "28", + "kind": "property", + "name": "additionalInfo", + "serializedName": "additionalInfo", + "doc": "The error additional info.", + "type": { + "$id": "29", + "kind": "array", + "name": "ArrayErrorAdditionalInfo", + "valueType": { + "$id": "30", + "kind": "model", + "name": "ErrorAdditionalInfo", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "usage": "Json,Exception", + "doc": "The resource management error additional info.", + "decorators": [], + "properties": [ + { + "$id": "31", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The additional info type.", + "type": { + "$id": "32", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + }, + { + "$id": "33", + "kind": "property", + "name": "info", + "serializedName": "info", + "doc": "The additional info.", + "type": { + "$id": "34", + "kind": "unknown", + "name": "unknown", + "crossLanguageDefinitionId": "", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info", + "serializationOptions": { + "json": { + "name": "info" + } + }, + "isHttpMetadata": false + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.additionalInfo", + "serializationOptions": { + "json": { + "name": "additionalInfo" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse.error", + "serializationOptions": { + "json": { + "name": "error" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$ref": "19" + }, + { + "$ref": "30" + } + ], + "clients": [ + { + "$id": "35", + "kind": "client", + "name": "NonResourceClient", + "namespace": "Azure.ResourceManager.NonResource", + "doc": "Arm Resource Provider management API.", + "methods": [], + "parameters": [ + { + "$id": "36", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "37", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "38", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.endpoint" + }, + { + "$id": "39", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "40", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "41", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "42", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "43", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "44", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 1, + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@nonResourceMethodSchema", + "arguments": { + "nonResourceMethods": [ + { + "methodId": "Azure.ResourceManager.NonResource.NonResourceOperations.get", + "operationPath": "/subscriptions/{subscriptionId}/providers/Microsoft.NonResource/locations/{location}/otherParameters/{parameter}", + "operationScope": "Subscription" + }, + { + "methodId": "Azure.ResourceManager.NonResource.NonResourceOperations.create", + "operationPath": "/subscriptions/{subscriptionId}/providers/Microsoft.NonResource/locations/{location}/otherParameters/{parameter}", + "operationScope": "Subscription" + } + ] + } + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource", + "apiVersions": [ + "2023-12-01-preview" + ], + "children": [ + { + "$id": "45", + "kind": "client", + "name": "NonResourceOperations", + "namespace": "Azure.ResourceManager.NonResource", + "doc": "Operations on non resource model should not be marked as `@armResourceOperations`.", + "methods": [ + { + "$id": "46", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "operation": { + "$id": "47", + "name": "get", + "resourceName": "NonResourceOperations", + "accessibility": "public", + "parameters": [ + { + "$id": "48", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "49", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "50", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.apiVersion", + "readOnly": false + }, + { + "$id": "51", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "52", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "53", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.subscriptionId" + }, + { + "$id": "54", + "kind": "path", + "name": "location", + "serializedName": "location", + "doc": "The location parameter.", + "type": { + "$id": "55", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.location" + }, + { + "$id": "56", + "kind": "path", + "name": "parameter", + "serializedName": "parameter", + "doc": "Another parameter.", + "type": { + "$id": "57", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.parameter" + }, + { + "$id": "58", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "4" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "10" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Microsoft.NonResource/locations/{location}/otherParameters/{parameter}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get", + "decorators": [] + }, + "parameters": [ + { + "$id": "59", + "kind": "method", + "name": "location", + "serializedName": "location", + "doc": "The location parameter.", + "type": { + "$id": "60", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.location", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "61", + "kind": "method", + "name": "parameter", + "serializedName": "parameter", + "doc": "Another parameter.", + "type": { + "$id": "62", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.parameter", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "63", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "4" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "10" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.get" + }, + { + "$id": "64", + "kind": "basic", + "name": "create", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "operation": { + "$id": "65", + "name": "create", + "resourceName": "NonResourceOperations", + "accessibility": "public", + "parameters": [ + { + "$id": "66", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "67", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "68", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.apiVersion", + "readOnly": false + }, + { + "$id": "69", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "70", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "71", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.subscriptionId" + }, + { + "$id": "72", + "kind": "path", + "name": "location", + "serializedName": "location", + "doc": "The location parameter.", + "type": { + "$id": "73", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.location" + }, + { + "$id": "74", + "kind": "path", + "name": "parameter", + "serializedName": "parameter", + "doc": "Another parameter.", + "type": { + "$id": "75", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.parameter" + }, + { + "$id": "76", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "6" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.contentType" + }, + { + "$id": "77", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "8" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.accept" + }, + { + "$id": "78", + "kind": "body", + "name": "body", + "serializedName": "body", + "doc": "The request body.", + "type": { + "$ref": "10" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.body" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "10" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Microsoft.NonResource/locations/{location}/otherParameters/{parameter}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create", + "decorators": [] + }, + "parameters": [ + { + "$id": "79", + "kind": "method", + "name": "location", + "serializedName": "location", + "doc": "The location parameter.", + "type": { + "$id": "80", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.location", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "81", + "kind": "method", + "name": "parameter", + "serializedName": "parameter", + "doc": "Another parameter.", + "type": { + "$id": "82", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.parameter", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "83", + "kind": "method", + "name": "body", + "serializedName": "body", + "doc": "The request body.", + "type": { + "$ref": "10" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.body", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "84", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "6" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "85", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "8" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "10" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations.create" + } + ], + "parameters": [ + { + "$id": "86", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "87", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "88", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.endpoint" + }, + { + "$ref": "39" + }, + { + "$ref": "42" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.NonResource.NonResourceOperations", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "35" + } + } + ] + } + ], + "auth": { + "oAuth2": { + "flows": [ + { + "scopes": [ + "user_impersonation" + ], + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize" + } + ] + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/Azure.ResourceManager.OperationTemplates.sln b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/Azure.ResourceManager.OperationTemplates.sln new file mode 100644 index 000000000000..8f62e219e11c --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/Azure.ResourceManager.OperationTemplates.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.OperationTemplates", "src\Azure.ResourceManager.OperationTemplates.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/Configuration.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/Configuration.json new file mode 100644 index 000000000000..c712cbe5df34 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/Configuration.json @@ -0,0 +1,11 @@ +{ + "package-name": "Azure.ResourceManager.OperationTemplates", + "model-namespace": true, + "license": { + "name": "MIT License", + "company": "Microsoft Corporation", + "link": "https://mit-license.org", + "header": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.", + "description": "Copyright (c) Microsoft Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the “Software”), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE." + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Azure.ResourceManager.OperationTemplates.csproj b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Azure.ResourceManager.OperationTemplates.csproj new file mode 100644 index 000000000000..48be96201aba --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Azure.ResourceManager.OperationTemplates.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.OperationTemplates client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.OperationTemplates + 1.0.0-beta.1 + Azure.ResourceManager.OperationTemplates + true + + diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/ArmOperationTemplatesModelFactory.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/ArmOperationTemplatesModelFactory.cs new file mode 100644 index 000000000000..900d286b86ae --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/ArmOperationTemplatesModelFactory.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ArmOperationTemplatesModelFactory + { + + /// The check availability result. + /// Indicates if the resource name is available. + /// The reason why the given name is not available. + /// Detailed reason why the given name is not available. + /// A new instance for mocking. + public static CheckNameAvailabilityResponse CheckNameAvailabilityResponse(bool? nameAvailable = default, CheckNameAvailabilityReason? reason = default, string message = default) + { + return new CheckNameAvailabilityResponse(nameAvailable, reason, message, additionalBinaryDataProperties: null); + } + + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static OrderData OrderData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, OrderProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new OrderData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// The OrderProperties. + /// The product ID of the order. + /// Amount of the product. + /// The provisioning state of the product. + /// A new instance for mocking. + public static OrderProperties OrderProperties(string productId = default, int amount = default, string provisioningState = default) + { + return new OrderProperties(productId, amount, provisioningState, additionalBinaryDataProperties: null); + } + + /// The ExportRequest. + /// Format of the exported order. + /// A new instance for mocking. + public static ExportRequest ExportRequest(string format = default) + { + return new ExportRequest(format, additionalBinaryDataProperties: null); + } + + /// The ExportResult. + /// Content of the exported order. + /// A new instance for mocking. + public static ExportResult ExportResult(string content = default) + { + return new ExportResult(content, additionalBinaryDataProperties: null); + } + + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static WidgetData WidgetData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, WidgetProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new WidgetData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// The WidgetProperties. + /// The name of the widget. + /// The description of the widget. + /// The provisioning state of the widget. + /// A new instance for mocking. + public static WidgetProperties WidgetProperties(string name = default, string description = default, string provisioningState = default) + { + return new WidgetProperties(name, description, provisioningState, additionalBinaryDataProperties: null); + } + + /// The ActionResult. + /// The result of the action. + /// A new instance for mocking. + public static ActionResult ActionResult(string result = default) + { + return new ActionResult(result, additionalBinaryDataProperties: null); + } + + /// The ChangeAllowanceResult. + /// The new total allowed widgets. + /// The status of the change. + /// A new instance for mocking. + public static ChangeAllowanceResult ChangeAllowanceResult(int totalAllowed = default, string status = default) + { + return new ChangeAllowanceResult(totalAllowed, status, additionalBinaryDataProperties: null); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/MockableOperationTemplatesArmClient.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/MockableOperationTemplatesArmClient.cs new file mode 100644 index 000000000000..95eadc4d7464 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/MockableOperationTemplatesArmClient.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Mocking +{ + /// A class to add extension methods to . + public partial class MockableOperationTemplatesArmClient : ArmResource + { + /// Initializes a new instance of MockableOperationTemplatesArmClient for mocking. + protected MockableOperationTemplatesArmClient() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableOperationTemplatesArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual OrderResource GetOrderResource(ResourceIdentifier id) + { + OrderResource.ValidateResourceId(id); + return new OrderResource(Client, id); + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual WidgetResource GetWidgetResource(ResourceIdentifier id) + { + WidgetResource.ValidateResourceId(id); + return new WidgetResource(Client, id); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/MockableOperationTemplatesResourceGroupResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/MockableOperationTemplatesResourceGroupResource.cs new file mode 100644 index 000000000000..1c30c740c779 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/MockableOperationTemplatesResourceGroupResource.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.OperationTemplates; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.OperationTemplates.Mocking +{ + /// A class to add extension methods to . + public partial class MockableOperationTemplatesResourceGroupResource : ArmResource + { + /// Initializes a new instance of MockableOperationTemplatesResourceGroupResource for mocking. + protected MockableOperationTemplatesResourceGroupResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableOperationTemplatesResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets a collection of Orders in the . + /// An object representing collection of Orders and their operations over a OrderResource. + public virtual OrderCollection GetOrders() + { + return GetCachedClient(client => new OrderCollection(client, Id)); + } + + /// Gets a collection of Widgets in the . + /// An object representing collection of Widgets and their operations over a WidgetResource. + public virtual WidgetCollection GetWidgets() + { + return GetCachedClient(client => new WidgetCollection(client, Id)); + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetWidgetAsync(string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + return await GetWidgets().GetAsync(widgetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetWidget(string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + return GetWidgets().Get(widgetName, cancellationToken); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/MockableOperationTemplatesSubscriptionResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/MockableOperationTemplatesSubscriptionResource.cs new file mode 100644 index 000000000000..30b5e45336b8 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/MockableOperationTemplatesSubscriptionResource.cs @@ -0,0 +1,269 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.OperationTemplates; +using Azure.ResourceManager.OperationTemplates.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.OperationTemplates.Mocking +{ + /// A class to add extension methods to . + public partial class MockableOperationTemplatesSubscriptionResource : ArmResource + { + private ClientDiagnostics _checkNameAvailabilityClientDiagnostics; + private CheckNameAvailability _checkNameAvailabilityRestClient; + private ClientDiagnostics _optionalBodyClientDiagnostics; + private OptionalBody _optionalBodyRestClient; + + /// Initializes a new instance of MockableOperationTemplatesSubscriptionResource for mocking. + protected MockableOperationTemplatesSubscriptionResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableOperationTemplatesSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics CheckNameAvailabilityClientDiagnostics => _checkNameAvailabilityClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.OperationTemplates.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private CheckNameAvailability CheckNameAvailabilityRestClient => _checkNameAvailabilityRestClient ??= new CheckNameAvailability(CheckNameAvailabilityClientDiagnostics, Pipeline, Endpoint, "2023-12-01-preview"); + + private ClientDiagnostics OptionalBodyClientDiagnostics => _optionalBodyClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.OperationTemplates.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private OptionalBody OptionalBodyRestClient => _optionalBodyRestClient ??= new OptionalBody(OptionalBodyClientDiagnostics, Pipeline, Endpoint, "2023-12-01-preview"); + + /// Implements global CheckNameAvailability operations. + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public virtual async Task> CheckGlobalAsync(CheckNameAvailabilityRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = CheckNameAvailabilityClientDiagnostics.CreateScope("MockableOperationTemplatesSubscriptionResource.CheckGlobal"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = CheckNameAvailabilityRestClient.CreateCheckGlobalRequest(Guid.Parse(Id.SubscriptionId), CheckNameAvailabilityRequest.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(CheckNameAvailabilityResponse.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Implements global CheckNameAvailability operations. + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public virtual Response CheckGlobal(CheckNameAvailabilityRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = CheckNameAvailabilityClientDiagnostics.CreateScope("MockableOperationTemplatesSubscriptionResource.CheckGlobal"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = CheckNameAvailabilityRestClient.CreateCheckGlobalRequest(Guid.Parse(Id.SubscriptionId), CheckNameAvailabilityRequest.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(CheckNameAvailabilityResponse.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Implements local CheckNameAvailability operations. + /// The name of the Azure region. + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public virtual async Task> CheckLocalAsync(AzureLocation location, CheckNameAvailabilityRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = CheckNameAvailabilityClientDiagnostics.CreateScope("MockableOperationTemplatesSubscriptionResource.CheckLocal"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = CheckNameAvailabilityRestClient.CreateCheckLocalRequest(Guid.Parse(Id.SubscriptionId), location, CheckNameAvailabilityRequest.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(CheckNameAvailabilityResponse.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Implements local CheckNameAvailability operations. + /// The name of the Azure region. + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public virtual Response CheckLocal(AzureLocation location, CheckNameAvailabilityRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = CheckNameAvailabilityClientDiagnostics.CreateScope("MockableOperationTemplatesSubscriptionResource.CheckLocal"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = CheckNameAvailabilityRestClient.CreateCheckLocalRequest(Guid.Parse(Id.SubscriptionId), location, CheckNameAvailabilityRequest.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(CheckNameAvailabilityResponse.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// ProviderPost + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/providerPost. + /// + /// + /// Operation Id. + /// OptionalBody_ProviderPost. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The request body. + /// The cancellation token to use. + public virtual async Task> ProviderPostAsync(ChangeAllowanceRequest body = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = OptionalBodyClientDiagnostics.CreateScope("MockableOperationTemplatesSubscriptionResource.ProviderPost"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = OptionalBodyRestClient.CreateProviderPostRequest(Guid.Parse(Id.SubscriptionId), ChangeAllowanceRequest.ToRequestContent(body), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ChangeAllowanceResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// ProviderPost + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/providerPost. + /// + /// + /// Operation Id. + /// OptionalBody_ProviderPost. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The request body. + /// The cancellation token to use. + public virtual Response ProviderPost(ChangeAllowanceRequest body = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = OptionalBodyClientDiagnostics.CreateScope("MockableOperationTemplatesSubscriptionResource.ProviderPost"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = OptionalBodyRestClient.CreateProviderPostRequest(Guid.Parse(Id.SubscriptionId), ChangeAllowanceRequest.ToRequestContent(body), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ChangeAllowanceResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/OperationTemplatesExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/OperationTemplatesExtensions.cs new file mode 100644 index 000000000000..81d640551752 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Extensions/OperationTemplatesExtensions.cs @@ -0,0 +1,259 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.OperationTemplates.Mocking; +using Azure.ResourceManager.OperationTemplates.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// A class to add extension methods to Azure.ResourceManager.OperationTemplates. + public static partial class OperationTemplatesExtensions + { + /// + private static MockableOperationTemplatesArmClient GetMockableOperationTemplatesArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableOperationTemplatesArmClient(client0, ResourceIdentifier.Root)); + } + + /// + private static MockableOperationTemplatesResourceGroupResource GetMockableOperationTemplatesResourceGroupResource(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient(client => new MockableOperationTemplatesResourceGroupResource(client, resourceGroupResource.Id)); + } + + /// + private static MockableOperationTemplatesSubscriptionResource GetMockableOperationTemplatesSubscriptionResource(SubscriptionResource subscriptionResource) + { + return subscriptionResource.GetCachedClient(client => new MockableOperationTemplatesSubscriptionResource(client, subscriptionResource.Id)); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static OrderResource GetOrderResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableOperationTemplatesArmClient(client).GetOrderResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static WidgetResource GetWidgetResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableOperationTemplatesArmClient(client).GetWidgetResource(id); + } + + /// + /// Gets a collection of Orders in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of Orders and their operations over a OrderResource. + public static OrderCollection GetOrders(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableOperationTemplatesResourceGroupResource(resourceGroupResource).GetOrders(); + } + + /// + /// Gets a collection of Widgets in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of Widgets and their operations over a WidgetResource. + public static WidgetCollection GetWidgets(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableOperationTemplatesResourceGroupResource(resourceGroupResource).GetWidgets(); + } + + /// + /// Get a Widget + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetWidgetAsync(this ResourceGroupResource resourceGroupResource, string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableOperationTemplatesResourceGroupResource(resourceGroupResource).GetWidgetAsync(widgetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Widget + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetWidget(this ResourceGroupResource resourceGroupResource, string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableOperationTemplatesResourceGroupResource(resourceGroupResource).GetWidget(widgetName, cancellationToken); + } + + /// + /// Implements global CheckNameAvailability operations + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public static async Task> CheckGlobalAsync(this SubscriptionResource subscriptionResource, CheckNameAvailabilityRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableOperationTemplatesSubscriptionResource(subscriptionResource).CheckGlobalAsync(content, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements global CheckNameAvailability operations + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public static Response CheckGlobal(this SubscriptionResource subscriptionResource, CheckNameAvailabilityRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableOperationTemplatesSubscriptionResource(subscriptionResource).CheckGlobal(content, cancellationToken); + } + + /// + /// Implements local CheckNameAvailability operations + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Azure region. + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public static async Task> CheckLocalAsync(this SubscriptionResource subscriptionResource, AzureLocation location, CheckNameAvailabilityRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableOperationTemplatesSubscriptionResource(subscriptionResource).CheckLocalAsync(location, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements local CheckNameAvailability operations + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Azure region. + /// The CheckAvailability request. + /// The cancellation token to use. + /// is null. + public static Response CheckLocal(this SubscriptionResource subscriptionResource, AzureLocation location, CheckNameAvailabilityRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableOperationTemplatesSubscriptionResource(subscriptionResource).CheckLocal(location, content, cancellationToken); + } + + /// + /// ProviderPost + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The request body. + /// The cancellation token to use. + /// is null. + public static async Task> ProviderPostAsync(this SubscriptionResource subscriptionResource, ChangeAllowanceRequest body = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableOperationTemplatesSubscriptionResource(subscriptionResource).ProviderPostAsync(body, cancellationToken).ConfigureAwait(false); + } + + /// + /// ProviderPost + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The request body. + /// The cancellation token to use. + /// is null. + public static Response ProviderPost(this SubscriptionResource subscriptionResource, ChangeAllowanceRequest body = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableOperationTemplatesSubscriptionResource(subscriptionResource).ProviderPost(body, cancellationToken); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/Argument.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..a6c06e1f8c34 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/Argument.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal static partial class Argument + { + /// The value. + /// The name. + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ChangeTrackingDictionary.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..42b6663667d0 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerDictionary == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + /// Gets the Keys. + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + /// Gets the Values. + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + /// Gets or sets the value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + /// Gets the Keys. + IEnumerable IReadOnlyDictionary.Keys => Keys; + + /// Gets the Values. + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + /// The item to search for. + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + /// The array to copy. + /// The index. + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + /// The item to remove. + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + /// The key. + /// The value to add. + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + /// The key to search for. + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + /// The key. + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + /// The key to search for. + /// The value. + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ChangeTrackingList.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..93285db6b02f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal partial class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + /// The inner list. + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + /// The inner list. + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerList == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureList().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + /// Gets or sets the value associated with the specified key. + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + /// The item. + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + /// The array to copy to. + /// The array index. + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + /// The item. + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + /// The item. + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + /// The inner list. + /// The item. + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + /// The inner list. + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ClientPipelineExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..a3964833b4b1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenMemberAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..8bb78bb22573 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.OperationTemplates +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenSerializationAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dd63045eada5 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.OperationTemplates +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenSuppressAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..eb8c34fc8774 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.OperationTemplates +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenTypeAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..1dcda92a206a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.OperationTemplates +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ErrorResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..19c339fcacfa --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ModelSerializationExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..40ef83aae816 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + Dictionary dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + List list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/Optional.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..2d28c7033ce9 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal static partial class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(string value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..f51d6be421da --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/RequestContextExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..f7d9152406d4 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/SerializationFormat.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..56a7068a9627 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.OperationTemplates +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/TypeFormatters.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..728c7424b56d --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/Utf8JsonRequestContent.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..f1df0ca35d1e --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal partial class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + /// Gets the JsonWriter. + public Utf8JsonWriter JsonWriter { get; } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + /// + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/ExportResultOperationSource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/ExportResultOperationSource.cs new file mode 100644 index 000000000000..737cfca68e3a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/ExportResultOperationSource.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager.OperationTemplates.Models; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// + internal partial class ExportResultOperationSource : IOperationSource + { + /// + internal ExportResultOperationSource() + { + } + + /// The response from the service. + /// The cancellation token to use. + /// + ExportResult IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + ExportResult result = ExportResult.DeserializeExportResult(document.RootElement, ModelSerializationExtensions.WireOptions); + return result; + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + ExportResult result = ExportResult.DeserializeExportResult(document.RootElement, ModelSerializationExtensions.WireOptions); + return result; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/OperationTemplatesArmOperation.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/OperationTemplatesArmOperation.cs new file mode 100644 index 000000000000..251e14c8683e --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/OperationTemplatesArmOperation.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal partial class OperationTemplatesArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of OperationTemplatesArmOperation for mocking. + protected OperationTemplatesArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal OperationTemplatesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal OperationTemplatesArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "OperationTemplatesArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/OperationTemplatesArmOperationOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/OperationTemplatesArmOperationOfT.cs new file mode 100644 index 000000000000..81bea5dfd672 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/OperationTemplatesArmOperationOfT.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal partial class OperationTemplatesArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of OperationTemplatesArmOperation for mocking. + protected OperationTemplatesArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal OperationTemplatesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal OperationTemplatesArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "OperationTemplatesArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the Value. + public override T Value => _operation.Value; + + /// Gets the HasValue. + public override bool HasValue => _operation.HasValue; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/OrderOperationSource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/OrderOperationSource.cs new file mode 100644 index 000000000000..36660fd9684b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/LongRunningOperation/OrderOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// + internal partial class OrderOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal OrderOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + OrderResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + OrderData data = OrderData.DeserializeOrderData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new OrderResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + OrderData data = OrderData.DeserializeOrderData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new OrderResource(_client, data); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionRequest.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionRequest.Serialization.cs new file mode 100644 index 000000000000..bd86de4e7996 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionRequest.Serialization.cs @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ActionRequest. + public partial class ActionRequest : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ActionRequest)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ActionType)) + { + writer.WritePropertyName("actionType"u8); + writer.WriteStringValue(ActionType); + } + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); + writer.WriteStringValue(Parameters); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ActionRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ActionRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ActionRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeActionRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ActionRequest DeserializeActionRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string actionType = default; + string parameters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("actionType"u8)) + { + actionType = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + parameters = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ActionRequest(actionType, parameters, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(ActionRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ActionRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ActionRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeActionRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ActionRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ActionRequest actionRequest) + { + if (actionRequest == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(actionRequest, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionRequest.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionRequest.cs new file mode 100644 index 000000000000..01a8f67d470d --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionRequest.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ActionRequest. + public partial class ActionRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ActionRequest() + { + } + + /// Initializes a new instance of . + /// The action type to perform. + /// Additional action parameters. + /// Keeps track of any properties unknown to the library. + internal ActionRequest(string actionType, string parameters, IDictionary additionalBinaryDataProperties) + { + ActionType = actionType; + Parameters = parameters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The action type to perform. + public string ActionType { get; set; } + + /// Additional action parameters. + public string Parameters { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionResult.Serialization.cs new file mode 100644 index 000000000000..a204c5fb6d1c --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ActionResult. + public partial class ActionResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ActionResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ActionResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ActionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ActionResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ActionResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeActionResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ActionResult DeserializeActionResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string result = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("result"u8)) + { + result = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ActionResult(result, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(ActionResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ActionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ActionResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeActionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ActionResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ActionResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeActionResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionResult.cs new file mode 100644 index 000000000000..e0b74892068b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ActionResult.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ActionResult. + public partial class ActionResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The result of the action. + internal ActionResult(string result) + { + Result = result; + } + + /// Initializes a new instance of . + /// The result of the action. + /// Keeps track of any properties unknown to the library. + internal ActionResult(string result, IDictionary additionalBinaryDataProperties) + { + Result = result; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The result of the action. + public string Result { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/AzureResourceManagerOperationTemplatesContext.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/AzureResourceManagerOperationTemplatesContext.cs new file mode 100644 index 000000000000..118810c20d3f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/AzureResourceManagerOperationTemplatesContext.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.OperationTemplates.Models; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(ActionRequest))] + [ModelReaderWriterBuildable(typeof(ActionResult))] + [ModelReaderWriterBuildable(typeof(ChangeAllowanceRequest))] + [ModelReaderWriterBuildable(typeof(ChangeAllowanceResult))] + [ModelReaderWriterBuildable(typeof(CheckNameAvailabilityRequest))] + [ModelReaderWriterBuildable(typeof(CheckNameAvailabilityResponse))] + [ModelReaderWriterBuildable(typeof(ExportRequest))] + [ModelReaderWriterBuildable(typeof(ExportResult))] + [ModelReaderWriterBuildable(typeof(OrderData))] + [ModelReaderWriterBuildable(typeof(OrderProperties))] + [ModelReaderWriterBuildable(typeof(OrderResource))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(SystemData))] + [ModelReaderWriterBuildable(typeof(WidgetData))] + [ModelReaderWriterBuildable(typeof(WidgetProperties))] + [ModelReaderWriterBuildable(typeof(WidgetResource))] + public partial class AzureResourceManagerOperationTemplatesContext : ModelReaderWriterContext + { + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceRequest.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceRequest.Serialization.cs new file mode 100644 index 000000000000..3af62d0b240d --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceRequest.Serialization.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ChangeAllowanceRequest. + public partial class ChangeAllowanceRequest : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChangeAllowanceRequest)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(TotalAllowed)) + { + writer.WritePropertyName("totalAllowed"u8); + writer.WriteNumberValue(TotalAllowed.Value); + } + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ChangeAllowanceRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChangeAllowanceRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChangeAllowanceRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChangeAllowanceRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ChangeAllowanceRequest DeserializeChangeAllowanceRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? totalAllowed = default; + string reason = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("totalAllowed"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + totalAllowed = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("reason"u8)) + { + reason = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChangeAllowanceRequest(totalAllowed, reason, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(ChangeAllowanceRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ChangeAllowanceRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChangeAllowanceRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeChangeAllowanceRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChangeAllowanceRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ChangeAllowanceRequest changeAllowanceRequest) + { + if (changeAllowanceRequest == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(changeAllowanceRequest, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceRequest.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceRequest.cs new file mode 100644 index 000000000000..5a9a4ee451c4 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceRequest.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ChangeAllowanceRequest. + public partial class ChangeAllowanceRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ChangeAllowanceRequest() + { + } + + /// Initializes a new instance of . + /// The new total allowed widgets. + /// The reason for the change. + /// Keeps track of any properties unknown to the library. + internal ChangeAllowanceRequest(int? totalAllowed, string reason, IDictionary additionalBinaryDataProperties) + { + TotalAllowed = totalAllowed; + Reason = reason; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The new total allowed widgets. + public int? TotalAllowed { get; set; } + + /// The reason for the change. + public string Reason { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceResult.Serialization.cs new file mode 100644 index 000000000000..c825506d9b11 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceResult.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ChangeAllowanceResult. + public partial class ChangeAllowanceResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ChangeAllowanceResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChangeAllowanceResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("totalAllowed"u8); + writer.WriteNumberValue(TotalAllowed); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ChangeAllowanceResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChangeAllowanceResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChangeAllowanceResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChangeAllowanceResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ChangeAllowanceResult DeserializeChangeAllowanceResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int totalAllowed = default; + string status = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("totalAllowed"u8)) + { + totalAllowed = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChangeAllowanceResult(totalAllowed, status, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(ChangeAllowanceResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ChangeAllowanceResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChangeAllowanceResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeChangeAllowanceResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChangeAllowanceResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ChangeAllowanceResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChangeAllowanceResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceResult.cs new file mode 100644 index 000000000000..d1e1f62a62fe --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ChangeAllowanceResult.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ChangeAllowanceResult. + public partial class ChangeAllowanceResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The new total allowed widgets. + /// The status of the change. + internal ChangeAllowanceResult(int totalAllowed, string status) + { + TotalAllowed = totalAllowed; + Status = status; + } + + /// Initializes a new instance of . + /// The new total allowed widgets. + /// The status of the change. + /// Keeps track of any properties unknown to the library. + internal ChangeAllowanceResult(int totalAllowed, string status, IDictionary additionalBinaryDataProperties) + { + TotalAllowed = totalAllowed; + Status = status; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The new total allowed widgets. + public int TotalAllowed { get; } + + /// The status of the change. + public string Status { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityReason.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityReason.cs new file mode 100644 index 000000000000..3e14c1de96bb --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityReason.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// Possible reasons for a name not being available. + public readonly partial struct CheckNameAvailabilityReason : IEquatable + { + private readonly string _value; + /// Name is invalid. + private const string InvalidValue = "Invalid"; + /// Name already exists. + private const string AlreadyExistsValue = "AlreadyExists"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public CheckNameAvailabilityReason(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Name is invalid. + public static CheckNameAvailabilityReason Invalid { get; } = new CheckNameAvailabilityReason(InvalidValue); + + /// Name already exists. + public static CheckNameAvailabilityReason AlreadyExists { get; } = new CheckNameAvailabilityReason(AlreadyExistsValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(CheckNameAvailabilityReason left, CheckNameAvailabilityReason right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(CheckNameAvailabilityReason left, CheckNameAvailabilityReason right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator CheckNameAvailabilityReason(string value) => new CheckNameAvailabilityReason(value); + + /// Converts a string to a . + /// The value. + public static implicit operator CheckNameAvailabilityReason?(string value) => value == null ? null : new CheckNameAvailabilityReason(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CheckNameAvailabilityReason other && Equals(other); + + /// + public bool Equals(CheckNameAvailabilityReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityRequest.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityRequest.Serialization.cs new file mode 100644 index 000000000000..fbaf05417072 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityRequest.Serialization.cs @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The check availability request body. + public partial class CheckNameAvailabilityRequest : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckNameAvailabilityRequest)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + CheckNameAvailabilityRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CheckNameAvailabilityRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckNameAvailabilityRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCheckNameAvailabilityRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CheckNameAvailabilityRequest DeserializeCheckNameAvailabilityRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new CheckNameAvailabilityRequest(name, @type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(CheckNameAvailabilityRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + CheckNameAvailabilityRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CheckNameAvailabilityRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeCheckNameAvailabilityRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CheckNameAvailabilityRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(CheckNameAvailabilityRequest checkNameAvailabilityRequest) + { + if (checkNameAvailabilityRequest == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(checkNameAvailabilityRequest, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityRequest.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityRequest.cs new file mode 100644 index 000000000000..6f3e02c56e76 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityRequest.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The check availability request body. + public partial class CheckNameAvailabilityRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public CheckNameAvailabilityRequest() + { + } + + /// Initializes a new instance of . + /// The name of the resource for which availability needs to be checked. + /// The resource type. + /// Keeps track of any properties unknown to the library. + internal CheckNameAvailabilityRequest(string name, string @type, IDictionary additionalBinaryDataProperties) + { + Name = name; + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the resource for which availability needs to be checked. + public string Name { get; set; } + + /// The resource type. + public string Type { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityResponse.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityResponse.Serialization.cs new file mode 100644 index 000000000000..4ade890f9d08 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityResponse.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The check availability result. + public partial class CheckNameAvailabilityResponse : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckNameAvailabilityResponse)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(NameAvailable)) + { + writer.WritePropertyName("nameAvailable"u8); + writer.WriteBooleanValue(NameAvailable.Value); + } + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason.Value.ToString()); + } + if (Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + CheckNameAvailabilityResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CheckNameAvailabilityResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckNameAvailabilityResponse)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCheckNameAvailabilityResponse(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CheckNameAvailabilityResponse DeserializeCheckNameAvailabilityResponse(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? nameAvailable = default; + CheckNameAvailabilityReason? reason = default; + string message = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("nameAvailable"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nameAvailable = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("reason"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + reason = new CheckNameAvailabilityReason(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("message"u8)) + { + message = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new CheckNameAvailabilityResponse(nameAvailable, reason, message, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(CheckNameAvailabilityResponse)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + CheckNameAvailabilityResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CheckNameAvailabilityResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeCheckNameAvailabilityResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CheckNameAvailabilityResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static CheckNameAvailabilityResponse FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCheckNameAvailabilityResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityResponse.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityResponse.cs new file mode 100644 index 000000000000..baa8e5c05564 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/CheckNameAvailabilityResponse.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The check availability result. + public partial class CheckNameAvailabilityResponse + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal CheckNameAvailabilityResponse() + { + } + + /// Initializes a new instance of . + /// Indicates if the resource name is available. + /// The reason why the given name is not available. + /// Detailed reason why the given name is not available. + /// Keeps track of any properties unknown to the library. + internal CheckNameAvailabilityResponse(bool? nameAvailable, CheckNameAvailabilityReason? reason, string message, IDictionary additionalBinaryDataProperties) + { + NameAvailable = nameAvailable; + Reason = reason; + Message = message; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Indicates if the resource name is available. + public bool? NameAvailable { get; } + + /// The reason why the given name is not available. + public CheckNameAvailabilityReason? Reason { get; } + + /// Detailed reason why the given name is not available. + public string Message { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportRequest.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportRequest.Serialization.cs new file mode 100644 index 000000000000..1cd93da07659 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportRequest.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ExportRequest. + public partial class ExportRequest : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ExportRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExportRequest)} does not support writing '{format}' format."); + } + writer.WritePropertyName("format"u8); + writer.WriteStringValue(Format); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ExportRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ExportRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExportRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExportRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ExportRequest DeserializeExportRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string format = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("format"u8)) + { + format = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ExportRequest(format, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(ExportRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ExportRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ExportRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeExportRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExportRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ExportRequest exportRequest) + { + if (exportRequest == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(exportRequest, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportRequest.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportRequest.cs new file mode 100644 index 000000000000..ba2edfa63251 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportRequest.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ExportRequest. + public partial class ExportRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Format of the exported order. + /// is null. + public ExportRequest(string format) + { + Argument.AssertNotNull(format, nameof(format)); + + Format = format; + } + + /// Initializes a new instance of . + /// Format of the exported order. + /// Keeps track of any properties unknown to the library. + internal ExportRequest(string format, IDictionary additionalBinaryDataProperties) + { + Format = format; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Format of the exported order. + public string Format { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportResult.Serialization.cs new file mode 100644 index 000000000000..4209ecf2b183 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ExportResult. + public partial class ExportResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ExportResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExportResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ExportResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ExportResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExportResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExportResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ExportResult DeserializeExportResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string content = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ExportResult(content, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(ExportResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ExportResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ExportResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeExportResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExportResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ExportResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeExportResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportResult.cs new file mode 100644 index 000000000000..33b6bcc533da --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/ExportResult.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The ExportResult. + public partial class ExportResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Content of the exported order. + internal ExportResult(string content) + { + Content = content; + } + + /// Initializes a new instance of . + /// Content of the exported order. + /// Keeps track of any properties unknown to the library. + internal ExportResult(string content, IDictionary additionalBinaryDataProperties) + { + Content = content; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Content of the exported order. + public string Content { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/OrderProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/OrderProperties.Serialization.cs new file mode 100644 index 000000000000..45873058c21a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/OrderProperties.Serialization.cs @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The OrderProperties. + public partial class OrderProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OrderProperties() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OrderProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("productId"u8); + writer.WriteStringValue(ProductId); + writer.WritePropertyName("amount"u8); + writer.WriteNumberValue(Amount); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OrderProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OrderProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OrderProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOrderProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OrderProperties DeserializeOrderProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string productId = default; + int amount = default; + string provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("productId"u8)) + { + productId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("amount"u8)) + { + amount = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + provisioningState = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OrderProperties(productId, amount, provisioningState, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(OrderProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OrderProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OrderProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOrderProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OrderProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/OrderProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/OrderProperties.cs new file mode 100644 index 000000000000..792a57e41bea --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/OrderProperties.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The OrderProperties. + public partial class OrderProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The product ID of the order. + /// Amount of the product. + /// is null. + public OrderProperties(string productId, int amount) + { + Argument.AssertNotNull(productId, nameof(productId)); + + ProductId = productId; + Amount = amount; + } + + /// Initializes a new instance of . + /// The product ID of the order. + /// Amount of the product. + /// The provisioning state of the product. + /// Keeps track of any properties unknown to the library. + internal OrderProperties(string productId, int amount, string provisioningState, IDictionary additionalBinaryDataProperties) + { + ProductId = productId; + Amount = amount; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The product ID of the order. + public string ProductId { get; set; } + + /// Amount of the product. + public int Amount { get; set; } + + /// The provisioning state of the product. + public string ProvisioningState { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/WidgetProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/WidgetProperties.Serialization.cs new file mode 100644 index 000000000000..14efcd2cc40c --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/WidgetProperties.Serialization.cs @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.OperationTemplates; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The WidgetProperties. + public partial class WidgetProperties : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WidgetProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + WidgetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WidgetProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WidgetProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWidgetProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WidgetProperties DeserializeWidgetProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + string provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + provisioningState = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WidgetProperties(name, description, provisioningState, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(WidgetProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + WidgetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WidgetProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeWidgetProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WidgetProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/WidgetProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/WidgetProperties.cs new file mode 100644 index 000000000000..5cb78017005f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/Models/WidgetProperties.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.OperationTemplates.Models +{ + /// The WidgetProperties. + public partial class WidgetProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public WidgetProperties() + { + } + + /// Initializes a new instance of . + /// The name of the widget. + /// The description of the widget. + /// The provisioning state of the widget. + /// Keeps track of any properties unknown to the library. + internal WidgetProperties(string name, string description, string provisioningState, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the widget. + public string Name { get; set; } + + /// The description of the widget. + public string Description { get; set; } + + /// The provisioning state of the widget. + public string ProvisioningState { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderCollection.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderCollection.cs new file mode 100644 index 000000000000..00e4ff3eaf54 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderCollection.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetOrders method from an instance of . + /// + public partial class OrderCollection : ArmCollection + { + private readonly ClientDiagnostics _lroClientDiagnostics; + private readonly Lro _lroRestClient; + + /// Initializes a new instance of OrderCollection for mocking. + protected OrderCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal OrderCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(OrderResource.ResourceType, out string orderApiVersion); + _lroClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.OperationTemplates", OrderResource.ResourceType.Namespace, Diagnostics); + _lroRestClient = new Lro(_lroClientDiagnostics, Pipeline, Endpoint, orderApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Create a Order + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}. + /// + /// + /// Operation Id. + /// Lro_CreateOrReplace. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Order. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string orderName, OrderData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(orderName, nameof(orderName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _lroClientDiagnostics.CreateScope("OrderCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _lroRestClient.CreateCreateOrReplaceRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, orderName, OrderData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + OperationTemplatesArmOperation operation = new OperationTemplatesArmOperation( + new OrderOperationSource(Client), + _lroClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Order + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}. + /// + /// + /// Operation Id. + /// Lro_CreateOrReplace. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Order. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string orderName, OrderData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(orderName, nameof(orderName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _lroClientDiagnostics.CreateScope("OrderCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _lroRestClient.CreateCreateOrReplaceRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, orderName, OrderData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + OperationTemplatesArmOperation operation = new OperationTemplatesArmOperation( + new OrderOperationSource(Client), + _lroClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderData.Serialization.cs new file mode 100644 index 000000000000..bcf07ed443fa --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderData.Serialization.cs @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.OperationTemplates.Models; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class OrderData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OrderData() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OrderData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OrderData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OrderData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OrderData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOrderData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OrderData DeserializeOrderData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + OrderProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerOperationTemplatesContext.Default); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = OrderProperties.DeserializeOrderProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OrderData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(OrderData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OrderData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OrderData)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOrderData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OrderData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(OrderData orderData) + { + if (orderData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(orderData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static OrderData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOrderData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderData.cs new file mode 100644 index 000000000000..9558ec8a17d1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderData.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.OperationTemplates.Models; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class OrderData : TrackedResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The geo-location where the resource lives. + public OrderData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + internal OrderData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, OrderProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public OrderProperties Properties { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderResource.Serialization.cs new file mode 100644 index 000000000000..6232002b495f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// + public partial class OrderResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new OrderData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + OrderData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerOperationTemplatesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + OrderData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerOperationTemplatesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderResource.cs new file mode 100644 index 000000000000..fd0c0c727d19 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/OrderResource.cs @@ -0,0 +1,429 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.OperationTemplates.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// + /// A class representing a Order along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetOrders method. + /// + public partial class OrderResource : ArmResource + { + private readonly ClientDiagnostics _lroClientDiagnostics; + private readonly Lro _lroRestClient; + private readonly OrderData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Azure.ResourceManager.OperationTemplates/orders"; + + /// Initializes a new instance of OrderResource for mocking. + protected OrderResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal OrderResource(ArmClient client, OrderData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal OrderResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string orderApiVersion); + _lroClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.OperationTemplates", ResourceType.Namespace, Diagnostics); + _lroRestClient = new Lro(_lroClientDiagnostics, Pipeline, Endpoint, orderApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual OrderData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The orderName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string orderName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// A long-running resource action. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}/export. + /// + /// + /// Operation Id. + /// Lro_Export. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> ExportAsync(WaitUntil waitUntil, ExportRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _lroClientDiagnostics.CreateScope("OrderResource.Export"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _lroRestClient.CreateExportRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, ExportRequest.ToRequestContent(content), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + OperationTemplatesArmOperation operation = new OperationTemplatesArmOperation( + new ExportResultOperationSource(), + _lroClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// A long-running resource action. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}/export. + /// + /// + /// Operation Id. + /// Lro_Export. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Export(WaitUntil waitUntil, ExportRequest content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _lroClientDiagnostics.CreateScope("OrderResource.Export"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _lroRestClient.CreateExportRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, ExportRequest.ToRequestContent(content), context); + Response response = Pipeline.ProcessMessage(message, context); + OperationTemplatesArmOperation operation = new OperationTemplatesArmOperation( + new ExportResultOperationSource(), + _lroClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Order + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}. + /// + /// + /// Operation Id. + /// Lro_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _lroClientDiagnostics.CreateScope("OrderResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _lroRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + OperationTemplatesArmOperation operation = new OperationTemplatesArmOperation(_lroClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Order + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}. + /// + /// + /// Operation Id. + /// Lro_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _lroClientDiagnostics.CreateScope("OrderResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _lroRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + OperationTemplatesArmOperation operation = new OperationTemplatesArmOperation(_lroClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Order + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}. + /// + /// + /// Operation Id. + /// Lro_CreateOrReplace. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, OrderData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _lroClientDiagnostics.CreateScope("OrderResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _lroRestClient.CreateCreateOrReplaceRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, OrderData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + OperationTemplatesArmOperation operation = new OperationTemplatesArmOperation( + new OrderOperationSource(Client), + _lroClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Order + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}. + /// + /// + /// Operation Id. + /// Lro_CreateOrReplace. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, OrderData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _lroClientDiagnostics.CreateScope("OrderResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _lroRestClient.CreateCreateOrReplaceRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, OrderData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + OperationTemplatesArmOperation operation = new OperationTemplatesArmOperation( + new OrderOperationSource(Client), + _lroClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/ProviderConstants.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..780e3fb94389 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/ProviderConstants.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal static partial class ProviderConstants + { + /// Gets the DefaultProviderNamespace. + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/RestOperations/CheckNameAvailabilityRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/RestOperations/CheckNameAvailabilityRestOperations.cs new file mode 100644 index 000000000000..346e7b72c984 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/RestOperations/CheckNameAvailabilityRestOperations.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal partial class CheckNameAvailability + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CheckNameAvailability for mocking. + protected CheckNameAvailability() + { + } + + /// Initializes a new instance of CheckNameAvailability. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal CheckNameAvailability(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateCheckGlobalRequest(Guid subscriptionId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Azure.ResourceManager.OperationTemplates/checkNameAvailability", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCheckLocalRequest(Guid subscriptionId, AzureLocation location, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Azure.ResourceManager.OperationTemplates/locations/", false); + uri.AppendPath(location.ToString(), true); + uri.AppendPath("/checkNameAvailability", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/RestOperations/LroRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/RestOperations/LroRestOperations.cs new file mode 100644 index 000000000000..78e988ff7e38 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/RestOperations/LroRestOperations.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal partial class Lro + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Lro for mocking. + protected Lro() + { + } + + /// Initializes a new instance of Lro. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Lro(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateCreateOrReplaceRequest(Guid subscriptionId, string resourceGroupName, string orderName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.OperationTemplates/orders/", false); + uri.AppendPath(orderName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateExportRequest(Guid subscriptionId, string resourceGroupName, string orderName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.OperationTemplates/orders/", false); + uri.AppendPath(orderName, true); + uri.AppendPath("/export", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string orderName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.OperationTemplates/orders/", false); + uri.AppendPath(orderName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/RestOperations/OptionalBodyRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/RestOperations/OptionalBodyRestOperations.cs new file mode 100644 index 000000000000..f1159e77d07b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/RestOperations/OptionalBodyRestOperations.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.OperationTemplates +{ + internal partial class OptionalBody + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of OptionalBody for mocking. + protected OptionalBody() + { + } + + /// Initializes a new instance of OptionalBody. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal OptionalBody(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string widgetName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.OperationTemplates/widgets/", false); + uri.AppendPath(widgetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreatePatchRequest(Guid subscriptionId, string resourceGroupName, string widgetName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.OperationTemplates/widgets/", false); + uri.AppendPath(widgetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + if ("application/json" != null) + { + request.Headers.SetValue("Content-Type", "application/json"); + } + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreatePostRequest(Guid subscriptionId, string resourceGroupName, string widgetName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.OperationTemplates/widgets/", false); + uri.AppendPath(widgetName, true); + uri.AppendPath("/post", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + if ("application/json" != null) + { + request.Headers.SetValue("Content-Type", "application/json"); + } + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateProviderPostRequest(Guid subscriptionId, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Azure.ResourceManager.OperationTemplates/providerPost", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + if ("application/json" != null) + { + request.Headers.SetValue("Content-Type", "application/json"); + } + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetCollection.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetCollection.cs new file mode 100644 index 000000000000..1fd76e154220 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetCollection.cs @@ -0,0 +1,390 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetWidgets method from an instance of . + /// + public partial class WidgetCollection : ArmCollection + { + private readonly ClientDiagnostics _optionalBodyClientDiagnostics; + private readonly OptionalBody _optionalBodyRestClient; + + /// Initializes a new instance of WidgetCollection for mocking. + protected WidgetCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal WidgetCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(WidgetResource.ResourceType, out string widgetApiVersion); + _optionalBodyClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.OperationTemplates", WidgetResource.ResourceType.Namespace, Diagnostics); + _optionalBodyRestClient = new OptionalBody(_optionalBodyClientDiagnostics, Pipeline, Endpoint, widgetApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, widgetName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, widgetName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, widgetName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WidgetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WidgetData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, widgetName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WidgetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WidgetData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, widgetName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WidgetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WidgetData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the Widget. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string widgetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, widgetName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WidgetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WidgetData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetData.Serialization.cs new file mode 100644 index 000000000000..ccc1e4b238b1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetData.Serialization.cs @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.OperationTemplates.Models; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class WidgetData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WidgetData() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WidgetData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + WidgetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (WidgetData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WidgetData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWidgetData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WidgetData DeserializeWidgetData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + WidgetProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerOperationTemplatesContext.Default); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = WidgetProperties.DeserializeWidgetProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WidgetData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerOperationTemplatesContext.Default); + default: + throw new FormatException($"The model {nameof(WidgetData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + WidgetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (WidgetData)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeWidgetData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WidgetData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(WidgetData widgetData) + { + if (widgetData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(widgetData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static WidgetData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWidgetData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetData.cs new file mode 100644 index 000000000000..2a34e5c880f6 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetData.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.OperationTemplates.Models; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class WidgetData : TrackedResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The geo-location where the resource lives. + public WidgetData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + internal WidgetData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, WidgetProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public WidgetProperties Properties { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetResource.Serialization.cs new file mode 100644 index 000000000000..276557e545b4 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// + public partial class WidgetResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new WidgetData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + WidgetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerOperationTemplatesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + WidgetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerOperationTemplatesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetResource.cs new file mode 100644 index 000000000000..032aa35ae242 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/src/Generated/WidgetResource.cs @@ -0,0 +1,662 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.OperationTemplates.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.OperationTemplates +{ + /// + /// A class representing a Widget along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetWidgets method. + /// + public partial class WidgetResource : ArmResource + { + private readonly ClientDiagnostics _optionalBodyClientDiagnostics; + private readonly OptionalBody _optionalBodyRestClient; + private readonly WidgetData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Azure.ResourceManager.OperationTemplates/widgets"; + + /// Initializes a new instance of WidgetResource for mocking. + protected WidgetResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal WidgetResource(ArmClient client, WidgetData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal WidgetResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string widgetApiVersion); + _optionalBodyClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.OperationTemplates", ResourceType.Namespace, Diagnostics); + _optionalBodyRestClient = new OptionalBody(_optionalBodyClientDiagnostics, Pipeline, Endpoint, widgetApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual WidgetData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The widgetName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string widgetName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Patch. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(WidgetData data = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreatePatchRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, WidgetData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Widget + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}. + /// + /// + /// Operation Id. + /// OptionalBody_Patch. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + public virtual Response Update(WidgetData data = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreatePatchRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, WidgetData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// A synchronous resource action. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}/post. + /// + /// + /// Operation Id. + /// OptionalBody_Post. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + public virtual async Task> PostAsync(ActionRequest body = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.Post"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreatePostRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, ActionRequest.ToRequestContent(body), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ActionResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// A synchronous resource action. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}/post. + /// + /// + /// Operation Id. + /// OptionalBody_Post. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + public virtual Response Post(ActionRequest body = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.Post"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreatePostRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, ActionRequest.ToRequestContent(body), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ActionResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WidgetData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + WidgetData patch = new WidgetData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WidgetData current = Get(cancellationToken: cancellationToken).Value.Data; + WidgetData patch = new WidgetData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WidgetData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + WidgetData patch = new WidgetData(); + patch.Tags.ReplaceWith(tags); + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WidgetData current = Get(cancellationToken: cancellationToken).Value.Data; + WidgetData patch = new WidgetData(); + patch.Tags.ReplaceWith(tags); + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WidgetData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + WidgetData patch = new WidgetData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _optionalBodyClientDiagnostics.CreateScope("WidgetResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _optionalBodyRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WidgetData.FromResponse(result), result); + return Response.FromValue(new WidgetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WidgetData current = Get(cancellationToken: cancellationToken).Value.Data; + WidgetData patch = new WidgetData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/tspCodeModel.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/tspCodeModel.json new file mode 100644 index 000000000000..a6d457a3c087 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/operation-templates/tspCodeModel.json @@ -0,0 +1,5952 @@ +{ + "name": "Azure.ResourceManager.OperationTemplates", + "apiVersions": [ + "2023-12-01-preview" + ], + "enums": [ + { + "$id": "1", + "kind": "enum", + "name": "Origin", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Origin", + "valueType": { + "$id": "2", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "3", + "kind": "enumvalue", + "name": "user", + "value": "user", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Indicates the operation is initiated by a user.", + "decorators": [] + }, + { + "$id": "4", + "kind": "enumvalue", + "name": "system", + "value": "system", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Indicates the operation is initiated by a system.", + "decorators": [] + }, + { + "$id": "5", + "kind": "enumvalue", + "name": "user,system", + "value": "user,system", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Indicates the operation is initiated by a user or system.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is \"user,system\"", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json", + "decorators": [] + }, + { + "$id": "6", + "kind": "enum", + "name": "ActionType", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ActionType", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "8", + "kind": "enumvalue", + "name": "Internal", + "value": "Internal", + "valueType": { + "$ref": "7" + }, + "enumType": { + "$ref": "6" + }, + "doc": "Actions are for internal-only APIs.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for internal only APIs.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json", + "decorators": [] + }, + { + "$id": "9", + "kind": "enum", + "name": "CheckNameAvailabilityReason", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityReason", + "valueType": { + "$id": "10", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "11", + "kind": "enumvalue", + "name": "Invalid", + "value": "Invalid", + "valueType": { + "$ref": "10" + }, + "enumType": { + "$ref": "9" + }, + "doc": "Name is invalid.", + "decorators": [] + }, + { + "$id": "12", + "kind": "enumvalue", + "name": "AlreadyExists", + "value": "AlreadyExists", + "valueType": { + "$ref": "10" + }, + "enumType": { + "$ref": "9" + }, + "doc": "Name already exists.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "Possible reasons for a name not being available.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json", + "decorators": [] + }, + { + "$id": "13", + "kind": "enum", + "name": "createdByType", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.createdByType", + "valueType": { + "$id": "14", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "15", + "kind": "enumvalue", + "name": "User", + "value": "User", + "valueType": { + "$ref": "14" + }, + "enumType": { + "$ref": "13" + }, + "doc": "The entity was created by a user.", + "decorators": [] + }, + { + "$id": "16", + "kind": "enumvalue", + "name": "Application", + "value": "Application", + "valueType": { + "$ref": "14" + }, + "enumType": { + "$ref": "13" + }, + "doc": "The entity was created by an application.", + "decorators": [] + }, + { + "$id": "17", + "kind": "enumvalue", + "name": "ManagedIdentity", + "value": "ManagedIdentity", + "valueType": { + "$ref": "14" + }, + "enumType": { + "$ref": "13" + }, + "doc": "The entity was created by a managed identity.", + "decorators": [] + }, + { + "$id": "18", + "kind": "enumvalue", + "name": "Key", + "value": "Key", + "valueType": { + "$ref": "14" + }, + "enumType": { + "$ref": "13" + }, + "doc": "The entity was created by a key.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "The kind of entity that created the resource.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json,LroInitial,LroFinalEnvelope", + "decorators": [] + }, + { + "$id": "19", + "kind": "enum", + "name": "ResourceProvisioningState", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceProvisioningState", + "valueType": { + "$id": "20", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "21", + "kind": "enumvalue", + "name": "Succeeded", + "value": "Succeeded", + "valueType": { + "$ref": "20" + }, + "enumType": { + "$ref": "19" + }, + "doc": "Resource has been created.", + "decorators": [] + }, + { + "$id": "22", + "kind": "enumvalue", + "name": "Failed", + "value": "Failed", + "valueType": { + "$ref": "20" + }, + "enumType": { + "$ref": "19" + }, + "doc": "Resource creation failed.", + "decorators": [] + }, + { + "$id": "23", + "kind": "enumvalue", + "name": "Canceled", + "value": "Canceled", + "valueType": { + "$ref": "20" + }, + "enumType": { + "$ref": "19" + }, + "doc": "Resource creation was canceled.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager", + "doc": "The provisioning state of a resource type.", + "isFixed": false, + "isFlags": false, + "usage": "LroPolling", + "decorators": [] + }, + { + "$id": "24", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Versions", + "valueType": { + "$id": "25", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "26", + "kind": "enumvalue", + "name": "v2023_12_01_preview", + "value": "2023-12-01-preview", + "valueType": { + "$ref": "25" + }, + "enumType": { + "$ref": "24" + }, + "doc": "Preview API version 2023-12-01-preview.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.OperationTemplates", + "doc": "Azure API versions.", + "isFixed": true, + "isFlags": false, + "usage": "ApiVersionEnum", + "decorators": [] + } + ], + "constants": [ + { + "$id": "27", + "kind": "constant", + "name": "listContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "28", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "29", + "kind": "constant", + "name": "checkGlobalContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "30", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "31", + "kind": "constant", + "name": "checkGlobalContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "32", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "33", + "kind": "constant", + "name": "checkLocalContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "34", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "35", + "kind": "constant", + "name": "checkLocalContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "36", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "37", + "kind": "constant", + "name": "createOrReplaceContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "38", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "39", + "kind": "constant", + "name": "createOrReplaceContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "40", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "41", + "kind": "constant", + "name": "createOrReplaceContentType2", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "42", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "43", + "kind": "constant", + "name": "createOrReplaceContentType3", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "44", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "45", + "kind": "constant", + "name": "exportContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "46", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "47", + "kind": "constant", + "name": "exportContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "48", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "49", + "kind": "constant", + "name": "exportContentType2", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "50", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "51", + "kind": "constant", + "name": "exportContentType3", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "52", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "53", + "kind": "constant", + "name": "getContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "54", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "55", + "kind": "constant", + "name": "patchContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "56", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "57", + "kind": "constant", + "name": "patchContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "58", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "59", + "kind": "constant", + "name": "postContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "60", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "61", + "kind": "constant", + "name": "postContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "62", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "63", + "kind": "constant", + "name": "providerPostContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "64", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "65", + "kind": "constant", + "name": "providerPostContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "66", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + } + ], + "models": [ + { + "$id": "67", + "kind": "model", + "name": "OperationListResult", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationListResult", + "usage": "Output,Json", + "doc": "A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results.", + "decorators": [], + "properties": [ + { + "$id": "68", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The Operation items on this page", + "type": { + "$id": "69", + "kind": "array", + "name": "ArrayOperation", + "valueType": { + "$id": "70", + "kind": "model", + "name": "Operation", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation", + "usage": "Output,Json", + "doc": "Details of a REST API operation, returned from the Resource Provider Operations API", + "summary": "REST API Operation", + "decorators": [], + "properties": [ + { + "$id": "71", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the operation, as per Resource-Based Access Control (RBAC). Examples: \"Microsoft.Compute/virtualMachines/write\", \"Microsoft.Compute/virtualMachines/capture/action\"", + "type": { + "$id": "72", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "73", + "kind": "property", + "name": "isDataAction", + "serializedName": "isDataAction", + "doc": "Whether the operation applies to data-plane. This is \"true\" for data-plane operations and \"false\" for Azure Resource Manager/control-plane operations.", + "type": { + "$id": "74", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.isDataAction", + "serializationOptions": { + "json": { + "name": "isDataAction" + } + }, + "isHttpMetadata": false + }, + { + "$id": "75", + "kind": "property", + "name": "display", + "serializedName": "display", + "doc": "Localized display information for this particular operation.", + "type": { + "$id": "76", + "kind": "model", + "name": "OperationDisplay", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "usage": "Output,Json", + "doc": "Localized display information for and operation.", + "decorators": [], + "properties": [ + { + "$id": "77", + "kind": "property", + "name": "provider", + "serializedName": "provider", + "doc": "The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring Insights\" or \"Microsoft Compute\".", + "type": { + "$id": "78", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay.provider", + "serializationOptions": { + "json": { + "name": "provider" + } + }, + "isHttpMetadata": false + }, + { + "$id": "79", + "kind": "property", + "name": "resource", + "serializedName": "resource", + "doc": "The localized friendly name of the resource type related to this operation. E.g. \"Virtual Machines\" or \"Job Schedule Collections\".", + "type": { + "$id": "80", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay.resource", + "serializationOptions": { + "json": { + "name": "resource" + } + }, + "isHttpMetadata": false + }, + { + "$id": "81", + "kind": "property", + "name": "operation", + "serializedName": "operation", + "doc": "The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create or Update Virtual Machine\", \"Restart Virtual Machine\".", + "type": { + "$id": "82", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay.operation", + "serializationOptions": { + "json": { + "name": "operation" + } + }, + "isHttpMetadata": false + }, + { + "$id": "83", + "kind": "property", + "name": "description", + "serializedName": "description", + "doc": "The short, localized friendly description of the operation; suitable for tool tips and detailed views.", + "type": { + "$id": "84", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay.description", + "serializationOptions": { + "json": { + "name": "description" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.display", + "serializationOptions": { + "json": { + "name": "display" + } + }, + "isHttpMetadata": false + }, + { + "$id": "85", + "kind": "property", + "name": "origin", + "serializedName": "origin", + "doc": "The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is \"user,system\"", + "type": { + "$ref": "1" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.origin", + "serializationOptions": { + "json": { + "name": "origin" + } + }, + "isHttpMetadata": false + }, + { + "$id": "86", + "kind": "property", + "name": "actionType", + "serializedName": "actionType", + "doc": "Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for internal only APIs.", + "type": { + "$ref": "6" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.actionType", + "serializationOptions": { + "json": { + "name": "actionType" + } + }, + "isHttpMetadata": false + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationListResult.value", + "serializationOptions": { + "json": { + "name": "value" + } + }, + "isHttpMetadata": false + }, + { + "$id": "87", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "88", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "89", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationListResult.nextLink", + "serializationOptions": { + "json": { + "name": "nextLink" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$ref": "70" + }, + { + "$ref": "76" + }, + { + "$id": "90", + "kind": "model", + "name": "ErrorResponse", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "usage": "Json,Exception", + "doc": "Common error response for all Azure Resource Manager APIs to return error details for failed operations.", + "summary": "Error response", + "decorators": [], + "properties": [ + { + "$id": "91", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "The error object.", + "type": { + "$id": "92", + "kind": "model", + "name": "ErrorDetail", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "usage": "Json,Exception,LroPolling", + "doc": "The error detail.", + "decorators": [], + "properties": [ + { + "$id": "93", + "kind": "property", + "name": "code", + "serializedName": "code", + "doc": "The error code.", + "type": { + "$id": "94", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.code", + "serializationOptions": { + "json": { + "name": "code" + } + }, + "isHttpMetadata": false + }, + { + "$id": "95", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "The error message.", + "type": { + "$id": "96", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.message", + "serializationOptions": { + "json": { + "name": "message" + } + }, + "isHttpMetadata": false + }, + { + "$id": "97", + "kind": "property", + "name": "target", + "serializedName": "target", + "doc": "The error target.", + "type": { + "$id": "98", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.target", + "serializationOptions": { + "json": { + "name": "target" + } + }, + "isHttpMetadata": false + }, + { + "$id": "99", + "kind": "property", + "name": "details", + "serializedName": "details", + "doc": "The error details.", + "type": { + "$id": "100", + "kind": "array", + "name": "ArrayErrorDetail", + "valueType": { + "$ref": "92" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.details", + "serializationOptions": { + "json": { + "name": "details" + } + }, + "isHttpMetadata": false + }, + { + "$id": "101", + "kind": "property", + "name": "additionalInfo", + "serializedName": "additionalInfo", + "doc": "The error additional info.", + "type": { + "$id": "102", + "kind": "array", + "name": "ArrayErrorAdditionalInfo", + "valueType": { + "$id": "103", + "kind": "model", + "name": "ErrorAdditionalInfo", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "usage": "Json,Exception,LroPolling", + "doc": "The resource management error additional info.", + "decorators": [], + "properties": [ + { + "$id": "104", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The additional info type.", + "type": { + "$id": "105", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + }, + { + "$id": "106", + "kind": "property", + "name": "info", + "serializedName": "info", + "doc": "The additional info.", + "type": { + "$id": "107", + "kind": "unknown", + "name": "unknown", + "crossLanguageDefinitionId": "", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info", + "serializationOptions": { + "json": { + "name": "info" + } + }, + "isHttpMetadata": false + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.additionalInfo", + "serializationOptions": { + "json": { + "name": "additionalInfo" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse.error", + "serializationOptions": { + "json": { + "name": "error" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$ref": "92" + }, + { + "$ref": "103" + }, + { + "$id": "108", + "kind": "model", + "name": "CheckNameAvailabilityRequest", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest", + "usage": "Input,Json", + "doc": "The check availability request body.", + "decorators": [], + "properties": [ + { + "$id": "109", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the resource for which availability needs to be checked.", + "type": { + "$id": "110", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "111", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The resource type.", + "type": { + "$id": "112", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "113", + "kind": "model", + "name": "CheckNameAvailabilityResponse", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse", + "usage": "Output,Json", + "doc": "The check availability result.", + "decorators": [], + "properties": [ + { + "$id": "114", + "kind": "property", + "name": "nameAvailable", + "serializedName": "nameAvailable", + "doc": "Indicates if the resource name is available.", + "type": { + "$id": "115", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse.nameAvailable", + "serializationOptions": { + "json": { + "name": "nameAvailable" + } + }, + "isHttpMetadata": false + }, + { + "$id": "116", + "kind": "property", + "name": "reason", + "serializedName": "reason", + "doc": "The reason why the given name is not available.", + "type": { + "$ref": "9" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse.reason", + "serializationOptions": { + "json": { + "name": "reason" + } + }, + "isHttpMetadata": false + }, + { + "$id": "117", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "Detailed reason why the given name is not available.", + "type": { + "$id": "118", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse.message", + "serializationOptions": { + "json": { + "name": "message" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "119", + "kind": "model", + "name": "Order", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Order", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.Private.@armResourceInternal", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@resourceSchema", + "arguments": { + "resourceIdPattern": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}", + "resourceType": "Azure.ResourceManager.OperationTemplates/orders", + "methods": [ + { + "$id": "120", + "methodId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace", + "kind": "Create", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}" + }, + { + "$id": "121", + "methodId": "Azure.ResourceManager.OperationTemplates.Lro.export", + "kind": "Action", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}/export", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}" + }, + { + "$id": "122", + "methodId": "Azure.ResourceManager.OperationTemplates.Lro.delete", + "kind": "Delete", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}" + } + ], + "resourceScope": "ResourceGroup", + "resourceName": "Order" + } + } + ], + "baseModel": { + "$id": "123", + "kind": "model", + "name": "TrackedResource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'", + "summary": "Tracked Resource", + "decorators": [], + "baseModel": { + "$id": "124", + "kind": "model", + "name": "Resource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Common fields that are returned in the response for all Azure Resource Manager resources", + "summary": "Resource", + "decorators": [], + "properties": [ + { + "$id": "125", + "kind": "property", + "name": "id", + "serializedName": "id", + "doc": "Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}", + "type": { + "$id": "126", + "kind": "string", + "name": "armResourceIdentifier", + "crossLanguageDefinitionId": "Azure.Core.armResourceIdentifier", + "baseType": { + "$id": "127", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.id", + "serializationOptions": { + "json": { + "name": "id" + } + }, + "isHttpMetadata": false + }, + { + "$id": "128", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the resource", + "type": { + "$id": "129", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "130", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or \"Microsoft.Storage/storageAccounts\"", + "type": { + "$id": "131", + "kind": "string", + "name": "armResourceType", + "crossLanguageDefinitionId": "Azure.Core.armResourceType", + "baseType": { + "$id": "132", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + }, + { + "$id": "133", + "kind": "property", + "name": "systemData", + "serializedName": "systemData", + "doc": "Azure Resource Manager metadata containing createdBy and modifiedBy information.", + "type": { + "$id": "134", + "kind": "model", + "name": "SystemData", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData", + "usage": "Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Metadata pertaining to creation and last modification of the resource.", + "decorators": [], + "properties": [ + { + "$id": "135", + "kind": "property", + "name": "createdBy", + "serializedName": "createdBy", + "doc": "The identity that created the resource.", + "type": { + "$id": "136", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdBy", + "serializationOptions": { + "json": { + "name": "createdBy" + } + }, + "isHttpMetadata": false + }, + { + "$id": "137", + "kind": "property", + "name": "createdByType", + "serializedName": "createdByType", + "doc": "The type of identity that created the resource.", + "type": { + "$ref": "13" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdByType", + "serializationOptions": { + "json": { + "name": "createdByType" + } + }, + "isHttpMetadata": false + }, + { + "$id": "138", + "kind": "property", + "name": "createdAt", + "serializedName": "createdAt", + "doc": "The timestamp of resource creation (UTC).", + "type": { + "$id": "139", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "140", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdAt", + "serializationOptions": { + "json": { + "name": "createdAt" + } + }, + "isHttpMetadata": false + }, + { + "$id": "141", + "kind": "property", + "name": "lastModifiedBy", + "serializedName": "lastModifiedBy", + "doc": "The identity that last modified the resource.", + "type": { + "$id": "142", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedBy", + "serializationOptions": { + "json": { + "name": "lastModifiedBy" + } + }, + "isHttpMetadata": false + }, + { + "$id": "143", + "kind": "property", + "name": "lastModifiedByType", + "serializedName": "lastModifiedByType", + "doc": "The type of identity that last modified the resource.", + "type": { + "$ref": "13" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedByType", + "serializationOptions": { + "json": { + "name": "lastModifiedByType" + } + }, + "isHttpMetadata": false + }, + { + "$id": "144", + "kind": "property", + "name": "lastModifiedAt", + "serializedName": "lastModifiedAt", + "doc": "The timestamp of resource last modification (UTC)", + "type": { + "$id": "145", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "146", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedAt", + "serializationOptions": { + "json": { + "name": "lastModifiedAt" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.systemData", + "serializationOptions": { + "json": { + "name": "systemData" + } + }, + "isHttpMetadata": false + } + ] + }, + "properties": [ + { + "$id": "147", + "kind": "property", + "name": "tags", + "serializedName": "tags", + "doc": "Resource tags.", + "type": { + "$id": "148", + "kind": "dict", + "keyType": { + "$id": "149", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "valueType": { + "$id": "150", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource.tags", + "serializationOptions": { + "json": { + "name": "tags" + } + }, + "isHttpMetadata": false + }, + { + "$id": "151", + "kind": "property", + "name": "location", + "serializedName": "location", + "doc": "The geo-location where the resource lives", + "type": { + "$id": "152", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "153", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource.location", + "serializationOptions": { + "json": { + "name": "location" + } + }, + "isHttpMetadata": false + } + ] + }, + "properties": [ + { + "$id": "154", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "155", + "kind": "model", + "name": "OrderProperties", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OrderProperties", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "156", + "kind": "property", + "name": "productId", + "serializedName": "productId", + "doc": "The product ID of the order.", + "type": { + "$id": "157", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OrderProperties.productId", + "serializationOptions": { + "json": { + "name": "productId" + } + }, + "isHttpMetadata": false + }, + { + "$id": "158", + "kind": "property", + "name": "amount", + "serializedName": "amount", + "doc": "Amount of the product.", + "type": { + "$id": "159", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OrderProperties.amount", + "serializationOptions": { + "json": { + "name": "amount" + } + }, + "isHttpMetadata": false + }, + { + "$id": "160", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The provisioning state of the product.", + "type": { + "$id": "161", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OrderProperties.provisioningState", + "serializationOptions": { + "json": { + "name": "provisioningState" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Order.properties", + "serializationOptions": { + "json": { + "name": "properties" + } + }, + "isHttpMetadata": false + }, + { + "$id": "162", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the Order", + "type": { + "$id": "163", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Order.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": true + } + ] + }, + { + "$ref": "155" + }, + { + "$ref": "123" + }, + { + "$ref": "124" + }, + { + "$ref": "134" + }, + { + "$id": "164", + "kind": "model", + "name": "ArmOperationStatusResourceProvisioningState", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus", + "usage": "LroPolling", + "doc": "Standard Azure Resource Manager operation status response", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "165", + "kind": "property", + "name": "status", + "serializedName": "status", + "doc": "The operation status", + "type": { + "$ref": "19" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.status", + "serializationOptions": { + "json": { + "name": "status" + } + }, + "isHttpMetadata": false + }, + { + "$id": "166", + "kind": "property", + "name": "id", + "serializedName": "id", + "doc": "The unique identifier for the operationStatus resource", + "type": { + "$id": "167", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.id", + "serializationOptions": { + "json": { + "name": "id" + } + }, + "isHttpMetadata": true + }, + { + "$id": "168", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the operationStatus resource", + "type": { + "$id": "169", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "170", + "kind": "property", + "name": "startTime", + "serializedName": "startTime", + "doc": "Operation start time", + "type": { + "$id": "171", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "172", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.startTime", + "serializationOptions": { + "json": { + "name": "startTime" + } + }, + "isHttpMetadata": false + }, + { + "$id": "173", + "kind": "property", + "name": "endTime", + "serializedName": "endTime", + "doc": "Operation complete time", + "type": { + "$id": "174", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "175", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.endTime", + "serializationOptions": { + "json": { + "name": "endTime" + } + }, + "isHttpMetadata": false + }, + { + "$id": "176", + "kind": "property", + "name": "percentComplete", + "serializedName": "percentComplete", + "doc": "The progress made toward completing the operation", + "type": { + "$id": "177", + "kind": "float64", + "name": "float64", + "crossLanguageDefinitionId": "TypeSpec.float64", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.percentComplete", + "serializationOptions": { + "json": { + "name": "percentComplete" + } + }, + "isHttpMetadata": false + }, + { + "$id": "178", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "Errors that occurred if the operation ended with Canceled or Failed status", + "type": { + "$ref": "92" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.error", + "serializationOptions": { + "json": { + "name": "error" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "179", + "kind": "model", + "name": "ExportRequest", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ExportRequest", + "usage": "Input,Json", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "180", + "kind": "property", + "name": "format", + "serializedName": "format", + "doc": "Format of the exported order.", + "type": { + "$id": "181", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ExportRequest.format", + "serializationOptions": { + "json": { + "name": "format" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "182", + "kind": "model", + "name": "ExportResult", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ExportResult", + "usage": "Output,Json,LroInitial,LroFinalEnvelope", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "183", + "kind": "property", + "name": "content", + "serializedName": "content", + "doc": "Content of the exported order.", + "type": { + "$id": "184", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ExportResult.content", + "serializationOptions": { + "json": { + "name": "content" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "185", + "kind": "model", + "name": "Widget", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Widget", + "usage": "Input,Output,Json", + "doc": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.Private.@armResourceInternal", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@resourceSchema", + "arguments": { + "resourceIdPattern": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}", + "resourceType": "Azure.ResourceManager.OperationTemplates/widgets", + "methods": [ + { + "$id": "186", + "methodId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get", + "kind": "Get", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}" + }, + { + "$id": "187", + "methodId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch", + "kind": "Update", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}" + }, + { + "$id": "188", + "methodId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post", + "kind": "Action", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}/post", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}" + } + ], + "resourceScope": "ResourceGroup", + "resourceName": "Widget" + } + } + ], + "baseModel": { + "$ref": "123" + }, + "properties": [ + { + "$id": "189", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "190", + "kind": "model", + "name": "WidgetProperties", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.WidgetProperties", + "usage": "Input,Output,Json", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "191", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the widget.", + "type": { + "$id": "192", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.WidgetProperties.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "193", + "kind": "property", + "name": "description", + "serializedName": "description", + "doc": "The description of the widget.", + "type": { + "$id": "194", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.WidgetProperties.description", + "serializationOptions": { + "json": { + "name": "description" + } + }, + "isHttpMetadata": false + }, + { + "$id": "195", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The provisioning state of the widget.", + "type": { + "$id": "196", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.WidgetProperties.provisioningState", + "serializationOptions": { + "json": { + "name": "provisioningState" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Widget.properties", + "serializationOptions": { + "json": { + "name": "properties" + } + }, + "isHttpMetadata": false + }, + { + "$id": "197", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the Widget", + "type": { + "$id": "198", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Widget.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": true + } + ] + }, + { + "$ref": "190" + }, + { + "$id": "199", + "kind": "model", + "name": "ActionRequest", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ActionRequest", + "usage": "Input,Json", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "200", + "kind": "property", + "name": "actionType", + "serializedName": "actionType", + "doc": "The action type to perform.", + "type": { + "$id": "201", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ActionRequest.actionType", + "serializationOptions": { + "json": { + "name": "actionType" + } + }, + "isHttpMetadata": false + }, + { + "$id": "202", + "kind": "property", + "name": "parameters", + "serializedName": "parameters", + "doc": "Additional action parameters.", + "type": { + "$id": "203", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ActionRequest.parameters", + "serializationOptions": { + "json": { + "name": "parameters" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "204", + "kind": "model", + "name": "ActionResult", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ActionResult", + "usage": "Output,Json", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "205", + "kind": "property", + "name": "result", + "serializedName": "result", + "doc": "The result of the action.", + "type": { + "$id": "206", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ActionResult.result", + "serializationOptions": { + "json": { + "name": "result" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "207", + "kind": "model", + "name": "ChangeAllowanceRequest", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ChangeAllowanceRequest", + "usage": "Input,Json", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "208", + "kind": "property", + "name": "totalAllowed", + "serializedName": "totalAllowed", + "doc": "The new total allowed widgets.", + "type": { + "$id": "209", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ChangeAllowanceRequest.totalAllowed", + "serializationOptions": { + "json": { + "name": "totalAllowed" + } + }, + "isHttpMetadata": false + }, + { + "$id": "210", + "kind": "property", + "name": "reason", + "serializedName": "reason", + "doc": "The reason for the change.", + "type": { + "$id": "211", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ChangeAllowanceRequest.reason", + "serializationOptions": { + "json": { + "name": "reason" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "212", + "kind": "model", + "name": "ChangeAllowanceResult", + "namespace": "Azure.ResourceManager.OperationTemplates", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ChangeAllowanceResult", + "usage": "Output,Json", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "213", + "kind": "property", + "name": "totalAllowed", + "serializedName": "totalAllowed", + "doc": "The new total allowed widgets.", + "type": { + "$id": "214", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ChangeAllowanceResult.totalAllowed", + "serializationOptions": { + "json": { + "name": "totalAllowed" + } + }, + "isHttpMetadata": false + }, + { + "$id": "215", + "kind": "property", + "name": "status", + "serializedName": "status", + "doc": "The status of the change.", + "type": { + "$id": "216", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.ChangeAllowanceResult.status", + "serializationOptions": { + "json": { + "name": "status" + } + }, + "isHttpMetadata": false + } + ] + } + ], + "clients": [ + { + "$id": "217", + "kind": "client", + "name": "OperationTemplatesClient", + "namespace": "Azure.ResourceManager.OperationTemplates", + "doc": "Arm Resource Provider management API.", + "methods": [], + "parameters": [ + { + "$id": "218", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "219", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "220", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.endpoint" + }, + { + "$id": "221", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "222", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "223", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Operations.list.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "224", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "225", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "226", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 1, + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@nonResourceMethodSchema", + "arguments": { + "nonResourceMethods": [ + { + "methodId": "Azure.ResourceManager.Operations.list", + "operationPath": "/providers/Azure.ResourceManager.OperationTemplates/operations", + "operationScope": "Tenant" + }, + { + "methodId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal", + "operationPath": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/checkNameAvailability", + "operationScope": "Subscription" + }, + { + "methodId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal", + "operationPath": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/locations/{location}/checkNameAvailability", + "operationScope": "Subscription" + }, + { + "methodId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost", + "operationPath": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/providerPost", + "operationScope": "Subscription" + } + ] + } + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates", + "apiVersions": [ + "2023-12-01-preview" + ], + "children": [ + { + "$id": "227", + "kind": "client", + "name": "Operations", + "namespace": "Azure.ResourceManager.OperationTemplates", + "methods": [ + { + "$id": "228", + "kind": "paging", + "name": "list", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "List the operations for the provider", + "operation": { + "$id": "229", + "name": "list", + "resourceName": "Operations", + "doc": "List the operations for the provider", + "accessibility": "public", + "parameters": [ + { + "$id": "230", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "231", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "232", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Operations.list.apiVersion", + "readOnly": false + }, + { + "$id": "233", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "27" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Operations.list.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "67" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/providers/Azure.ResourceManager.OperationTemplates/operations", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Operations.list", + "decorators": [] + }, + "parameters": [ + { + "$id": "234", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "27" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Operations.list.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "69" + }, + "resultSegments": [ + "value" + ] + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Operations.list", + "pagingMetadata": { + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + }, + "pageSizeParameterSegments": [] + } + } + ], + "parameters": [ + { + "$id": "235", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "236", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "237", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.endpoint" + }, + { + "$ref": "221" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Operations", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "217" + } + }, + { + "$id": "238", + "kind": "client", + "name": "CheckNameAvailability", + "namespace": "Azure.ResourceManager.OperationTemplates", + "methods": [ + { + "$id": "239", + "kind": "basic", + "name": "checkGlobal", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Implements global CheckNameAvailability operations", + "operation": { + "$id": "240", + "name": "checkGlobal", + "resourceName": "CheckNameAvailability", + "doc": "Implements global CheckNameAvailability operations", + "accessibility": "public", + "parameters": [ + { + "$id": "241", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "242", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "243", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.apiVersion", + "readOnly": false + }, + { + "$id": "244", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "245", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "246", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.subscriptionId" + }, + { + "$id": "247", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "29" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.contentType" + }, + { + "$id": "248", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "31" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.accept" + }, + { + "$id": "249", + "kind": "body", + "name": "body", + "serializedName": "body", + "doc": "The CheckAvailability request", + "type": { + "$ref": "108" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.body" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "113" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/checkNameAvailability", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal", + "decorators": [] + }, + "parameters": [ + { + "$id": "250", + "kind": "method", + "name": "body", + "serializedName": "body", + "doc": "The CheckAvailability request", + "type": { + "$ref": "108" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.body", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "251", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "29" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "252", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "31" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "113" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal" + }, + { + "$id": "253", + "kind": "basic", + "name": "checkLocal", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Implements local CheckNameAvailability operations", + "operation": { + "$id": "254", + "name": "checkLocal", + "resourceName": "CheckNameAvailability", + "doc": "Implements local CheckNameAvailability operations", + "accessibility": "public", + "parameters": [ + { + "$id": "255", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "256", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "257", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.apiVersion", + "readOnly": false + }, + { + "$id": "258", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "259", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "260", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.subscriptionId" + }, + { + "$id": "261", + "kind": "path", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "262", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "263", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.location" + }, + { + "$id": "264", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "33" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.contentType" + }, + { + "$id": "265", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "35" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.accept" + }, + { + "$id": "266", + "kind": "body", + "name": "body", + "serializedName": "body", + "doc": "The CheckAvailability request", + "type": { + "$ref": "108" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.body" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "113" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/locations/{location}/checkNameAvailability", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal", + "decorators": [] + }, + "parameters": [ + { + "$id": "267", + "kind": "method", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "268", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "269", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.location", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "270", + "kind": "method", + "name": "body", + "serializedName": "body", + "doc": "The CheckAvailability request", + "type": { + "$ref": "108" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.body", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "271", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "33" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "272", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "35" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "113" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkLocal" + } + ], + "parameters": [ + { + "$id": "273", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "274", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "275", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.endpoint" + }, + { + "$id": "276", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "277", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "278", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability.checkGlobal.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$ref": "224" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.CheckNameAvailability", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "217" + } + }, + { + "$id": "279", + "kind": "client", + "name": "Lro", + "namespace": "Azure.ResourceManager.OperationTemplates", + "methods": [ + { + "$id": "280", + "kind": "lro", + "name": "createOrReplace", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Create a Order", + "operation": { + "$id": "281", + "name": "createOrReplace", + "resourceName": "Order", + "doc": "Create a Order", + "accessibility": "public", + "parameters": [ + { + "$id": "282", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "283", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "284", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.apiVersion", + "readOnly": false + }, + { + "$id": "285", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "286", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "287", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.subscriptionId" + }, + { + "$id": "288", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "289", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.resourceGroupName" + }, + { + "$id": "290", + "kind": "path", + "name": "orderName", + "serializedName": "orderName", + "doc": "The name of the Order", + "type": { + "$id": "291", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.orderName" + }, + { + "$id": "292", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "37" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.contentType" + }, + { + "$id": "293", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "39" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.accept" + }, + { + "$id": "294", + "kind": "body", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "119" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.resource" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "119" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 201 + ], + "bodyType": { + "$ref": "119" + }, + "headers": [ + { + "name": "azureAsyncOperation", + "nameInResponse": "Azure-AsyncOperation", + "doc": "A link to the status monitor", + "type": { + "$id": "295", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "296", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceCreateOrUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "297", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "298", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "299", + "kind": "method", + "name": "orderName", + "serializedName": "orderName", + "doc": "The name of the Order", + "type": { + "$id": "300", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.orderName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "301", + "kind": "method", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "119" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.resource", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "302", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "41" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "303", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "43" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "119" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace", + "lroMetadata": { + "finalStateVia": 0, + "finalResponse": { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "119" + } + } + } + }, + { + "$id": "304", + "kind": "lro", + "name": "export", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "A long-running resource action.", + "operation": { + "$id": "305", + "name": "export", + "resourceName": "Lro", + "doc": "A long-running resource action.", + "accessibility": "public", + "parameters": [ + { + "$id": "306", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "307", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "308", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.apiVersion", + "readOnly": false + }, + { + "$id": "309", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "310", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "311", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.subscriptionId" + }, + { + "$id": "312", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "313", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.resourceGroupName" + }, + { + "$id": "314", + "kind": "path", + "name": "orderName", + "serializedName": "orderName", + "doc": "The name of the Order", + "type": { + "$id": "315", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.orderName" + }, + { + "$id": "316", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "45" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.contentType" + }, + { + "$id": "317", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "47" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.accept" + }, + { + "$id": "318", + "kind": "body", + "name": "body", + "serializedName": "body", + "doc": "The content of the action request", + "type": { + "$ref": "179" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.body" + } + ], + "responses": [ + { + "statusCodes": [ + 202 + ], + "headers": [ + { + "name": "azureAsyncOperation", + "nameInResponse": "Azure-AsyncOperation", + "doc": "A link to the status monitor", + "type": { + "$id": "319", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "320", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + } + }, + { + "name": "location", + "nameInResponse": "Location", + "doc": "The Location header contains the URL where the status of the long running operation can be checked.", + "type": { + "$id": "321", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "322", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false + }, + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "182" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}/export", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceAction", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "323", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "324", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "325", + "kind": "method", + "name": "orderName", + "serializedName": "orderName", + "doc": "The name of the Order", + "type": { + "$id": "326", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.orderName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "327", + "kind": "method", + "name": "body", + "serializedName": "body", + "doc": "The content of the action request", + "type": { + "$ref": "179" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.body", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "328", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "49" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "329", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "51" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "182" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.export", + "lroMetadata": { + "finalStateVia": 1, + "finalResponse": { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "182" + } + } + } + }, + { + "$id": "330", + "kind": "lro", + "name": "delete", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Delete a Order", + "operation": { + "$id": "331", + "name": "delete", + "resourceName": "Order", + "doc": "Delete a Order", + "accessibility": "public", + "parameters": [ + { + "$id": "332", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "333", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "334", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.delete.apiVersion", + "readOnly": false + }, + { + "$id": "335", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "336", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "337", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.delete.subscriptionId" + }, + { + "$id": "338", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "339", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.delete.resourceGroupName" + }, + { + "$id": "340", + "kind": "path", + "name": "orderName", + "serializedName": "orderName", + "doc": "The name of the Order", + "type": { + "$id": "341", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.delete.orderName" + } + ], + "responses": [ + { + "statusCodes": [ + 202 + ], + "headers": [ + { + "name": "location", + "nameInResponse": "Location", + "doc": "The Location header contains the URL where the status of the long running operation can be checked.", + "type": { + "$id": "342", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "343", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false + }, + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "DELETE", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.delete", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceDelete", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "344", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "345", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.delete.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "346", + "kind": "method", + "name": "orderName", + "serializedName": "orderName", + "doc": "The name of the Order", + "type": { + "$id": "347", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.delete.orderName", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.delete", + "lroMetadata": { + "finalStateVia": 1, + "finalResponse": { + "statusCodes": [ + 204 + ] + } + } + } + ], + "parameters": [ + { + "$id": "348", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "349", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "350", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.endpoint" + }, + { + "$id": "351", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "352", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "353", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "354", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "355", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "356", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro.createOrReplace.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.Lro", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "217" + } + }, + { + "$id": "357", + "kind": "client", + "name": "OptionalBody", + "namespace": "Azure.ResourceManager.OperationTemplates", + "methods": [ + { + "$id": "358", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Get a Widget", + "operation": { + "$id": "359", + "name": "get", + "resourceName": "Widget", + "doc": "Get a Widget", + "accessibility": "public", + "parameters": [ + { + "$id": "360", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "361", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "362", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.apiVersion", + "readOnly": false + }, + { + "$id": "363", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "364", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "365", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.subscriptionId" + }, + { + "$id": "366", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "367", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.resourceGroupName" + }, + { + "$id": "368", + "kind": "path", + "name": "widgetName", + "serializedName": "widgetName", + "doc": "The name of the Widget", + "type": { + "$id": "369", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.widgetName" + }, + { + "$id": "370", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "53" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "185" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceRead", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "371", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "372", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "373", + "kind": "method", + "name": "widgetName", + "serializedName": "widgetName", + "doc": "The name of the Widget", + "type": { + "$id": "374", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.widgetName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "375", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "53" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "185" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get" + }, + { + "$id": "376", + "kind": "basic", + "name": "patch", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Update a Widget", + "operation": { + "$id": "377", + "name": "patch", + "resourceName": "Widget", + "doc": "Update a Widget", + "accessibility": "public", + "parameters": [ + { + "$id": "378", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "379", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "380", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.apiVersion", + "readOnly": false + }, + { + "$id": "381", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "382", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "383", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.subscriptionId" + }, + { + "$id": "384", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "385", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.resourceGroupName" + }, + { + "$id": "386", + "kind": "path", + "name": "widgetName", + "serializedName": "widgetName", + "doc": "The name of the Widget", + "type": { + "$id": "387", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.widgetName" + }, + { + "$id": "388", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "55" + }, + "isApiVersion": false, + "optional": true, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.contentType" + }, + { + "$id": "389", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "57" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.accept" + }, + { + "$id": "390", + "kind": "body", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "185" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": true, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.properties" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "185" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PATCH", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "391", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "392", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "393", + "kind": "method", + "name": "widgetName", + "serializedName": "widgetName", + "doc": "The name of the Widget", + "type": { + "$id": "394", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.widgetName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "395", + "kind": "method", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "185" + }, + "location": "Body", + "isApiVersion": false, + "optional": true, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.properties", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "396", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "55" + }, + "location": "Header", + "isApiVersion": false, + "optional": true, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "397", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "57" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "185" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.patch" + }, + { + "$id": "398", + "kind": "basic", + "name": "post", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "A synchronous resource action.", + "operation": { + "$id": "399", + "name": "post", + "resourceName": "OptionalBody", + "doc": "A synchronous resource action.", + "accessibility": "public", + "parameters": [ + { + "$id": "400", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "401", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "402", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.apiVersion", + "readOnly": false + }, + { + "$id": "403", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "404", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "405", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.subscriptionId" + }, + { + "$id": "406", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "407", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.resourceGroupName" + }, + { + "$id": "408", + "kind": "path", + "name": "widgetName", + "serializedName": "widgetName", + "doc": "The name of the Widget", + "type": { + "$id": "409", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.widgetName" + }, + { + "$id": "410", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "59" + }, + "isApiVersion": false, + "optional": true, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.contentType" + }, + { + "$id": "411", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "61" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.accept" + }, + { + "$id": "412", + "kind": "body", + "name": "body", + "serializedName": "body", + "doc": "The content of the action request", + "type": { + "$ref": "199" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": true, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.body" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "204" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/widgets/{widgetName}/post", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceAction", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "413", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "414", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "415", + "kind": "method", + "name": "widgetName", + "serializedName": "widgetName", + "doc": "The name of the Widget", + "type": { + "$id": "416", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.widgetName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "417", + "kind": "method", + "name": "body", + "serializedName": "body", + "doc": "The content of the action request", + "type": { + "$ref": "199" + }, + "location": "Body", + "isApiVersion": false, + "optional": true, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.body", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "418", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "59" + }, + "location": "Header", + "isApiVersion": false, + "optional": true, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "419", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "61" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "204" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.post" + }, + { + "$id": "420", + "kind": "basic", + "name": "providerPost", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "operation": { + "$id": "421", + "name": "providerPost", + "resourceName": "OptionalBody", + "accessibility": "public", + "parameters": [ + { + "$id": "422", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "423", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "424", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost.apiVersion", + "readOnly": false + }, + { + "$id": "425", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "426", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "427", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost.subscriptionId" + }, + { + "$id": "428", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "63" + }, + "isApiVersion": false, + "optional": true, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost.contentType" + }, + { + "$id": "429", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "65" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost.accept" + }, + { + "$id": "430", + "kind": "body", + "name": "body", + "serializedName": "body", + "doc": "The request body", + "type": { + "$ref": "207" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": true, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost.body" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "212" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/providerPost", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost", + "decorators": [] + }, + "parameters": [ + { + "$id": "431", + "kind": "method", + "name": "body", + "serializedName": "body", + "doc": "The request body", + "type": { + "$ref": "207" + }, + "location": "Body", + "isApiVersion": false, + "optional": true, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost.body", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "432", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "63" + }, + "location": "Header", + "isApiVersion": false, + "optional": true, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "433", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "65" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "212" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.providerPost" + } + ], + "parameters": [ + { + "$id": "434", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "435", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "436", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.endpoint" + }, + { + "$id": "437", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "438", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "439", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "440", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "441", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "442", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody.get.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.OperationTemplates.OptionalBody", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "217" + } + } + ] + } + ], + "auth": { + "oAuth2": { + "flows": [ + { + "scopes": [ + "user_impersonation" + ], + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize" + } + ] + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/Azure.ResourceManager.Resources.sln b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/Azure.ResourceManager.Resources.sln new file mode 100644 index 000000000000..c1737949be22 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/Azure.ResourceManager.Resources.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Resources", "src\Azure.ResourceManager.Resources.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/Configuration.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/Configuration.json new file mode 100644 index 000000000000..17ac5bde1635 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/Configuration.json @@ -0,0 +1,11 @@ +{ + "package-name": "Azure.ResourceManager.Resources", + "model-namespace": true, + "license": { + "name": "MIT License", + "company": "Microsoft Corporation", + "link": "https://mit-license.org", + "header": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.", + "description": "Copyright (c) Microsoft Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the “Software”), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE." + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Azure.ResourceManager.Resources.csproj b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Azure.ResourceManager.Resources.csproj new file mode 100644 index 000000000000..6e3ee954fce8 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Azure.ResourceManager.Resources.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.Resources client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.Resources + 1.0.0-beta.1 + Azure.ResourceManager.Resources + true + + diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ArmResourcesModelFactory.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ArmResourcesModelFactory.cs new file mode 100644 index 000000000000..6d0f20a54676 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ArmResourcesModelFactory.cs @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ArmResourcesModelFactory + { + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static TopLevelTrackedResourceData TopLevelTrackedResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, TopLevelTrackedResourceProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new TopLevelTrackedResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Top Level Arm Resource Properties. + /// The status of the last operation. + /// The description of the resource. + /// A new instance for mocking. + public static TopLevelTrackedResourceProperties TopLevelTrackedResourceProperties(ProvisioningState? provisioningState = default, string description = default) + { + return new TopLevelTrackedResourceProperties(provisioningState, description, additionalBinaryDataProperties: null); + } + + /// The details of a user notification. + /// The notification message. + /// If true, the notification is urgent. + /// A new instance for mocking. + public static NotificationDetails NotificationDetails(string message = default, bool urgent = default) + { + return new NotificationDetails(message, urgent, additionalBinaryDataProperties: null); + } + + /// Nested child of Top Level Tracked Resource. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static NestedProxyResourceData NestedProxyResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, NestedProxyResourceProperties properties = default) + { + return new NestedProxyResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// Nested Proxy Resource Properties. + /// Provisioning State of the nested child Resource. + /// Nested resource description. + /// A new instance for mocking. + public static NestedProxyResourceProperties NestedProxyResourceProperties(ProvisioningState? provisioningState = default, string description = default) + { + return new NestedProxyResourceProperties(provisioningState, description, additionalBinaryDataProperties: null); + } + + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static SingletonTrackedResourceData SingletonTrackedResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, SingletonTrackedResourceProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new SingletonTrackedResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Singleton Arm Resource Properties. + /// The status of the last operation. + /// The description of the resource. + /// A new instance for mocking. + public static SingletonTrackedResourceProperties SingletonTrackedResourceProperties(ProvisioningState? provisioningState = default, string description = default) + { + return new SingletonTrackedResourceProperties(provisioningState, description, additionalBinaryDataProperties: null); + } + + /// Concrete extension resource types can be created by aliasing this type using a specific property type. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ExtensionsResourceData ExtensionsResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, ExtensionsResourceProperties properties = default) + { + return new ExtensionsResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// ExtensionsResource properties. + /// The description of the resource. + /// The status of the last operation. + /// A new instance for mocking. + public static ExtensionsResourceProperties ExtensionsResourceProperties(string description = default, ProvisioningState? provisioningState = default) + { + return new ExtensionsResourceProperties(description, provisioningState, additionalBinaryDataProperties: null); + } + + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static LocationResourceData LocationResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, LocationResourceProperties properties = default) + { + return new LocationResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// Location resource properties. + /// The description of the resource. + /// The status of the last operation. + /// A new instance for mocking. + public static LocationResourceProperties LocationResourceProperties(string description = default, ProvisioningState? provisioningState = default) + { + return new LocationResourceProperties(description, provisioningState, additionalBinaryDataProperties: null); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/ExtensionsResourcesGetByScopeAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/ExtensionsResourcesGetByScopeAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..11648547f505 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/ExtensionsResourcesGetByScopeAsyncCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class ExtensionsResourcesGetByScopeAsyncCollectionResultOfT : AsyncPageable + { + private readonly ExtensionsResources _client; + private readonly string _resourceUri; + private readonly RequestContext _context; + + /// Initializes a new instance of ExtensionsResourcesGetByScopeAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ExtensionsResources client used to send requests. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ExtensionsResourcesGetByScopeAsyncCollectionResultOfT(ExtensionsResources client, string resourceUri, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _resourceUri = resourceUri; + _context = context; + } + + /// Gets the pages of ExtensionsResourcesGetByScopeAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ExtensionsResourcesGetByScopeAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + ExtensionsResourceListResult result = ExtensionsResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByScopeRequest(nextLink, _resourceUri, _context) : _client.CreateGetByScopeRequest(_resourceUri, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ExtensionsResourceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/ExtensionsResourcesGetByScopeCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/ExtensionsResourcesGetByScopeCollectionResultOfT.cs new file mode 100644 index 000000000000..f13a67a2283a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/ExtensionsResourcesGetByScopeCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class ExtensionsResourcesGetByScopeCollectionResultOfT : Pageable + { + private readonly ExtensionsResources _client; + private readonly string _resourceUri; + private readonly RequestContext _context; + + /// Initializes a new instance of ExtensionsResourcesGetByScopeCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ExtensionsResources client used to send requests. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ExtensionsResourcesGetByScopeCollectionResultOfT(ExtensionsResources client, string resourceUri, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _resourceUri = resourceUri; + _context = context; + } + + /// Gets the pages of ExtensionsResourcesGetByScopeCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ExtensionsResourcesGetByScopeCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + ExtensionsResourceListResult result = ExtensionsResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByScopeRequest(nextLink, _resourceUri, _context) : _client.CreateGetByScopeRequest(_resourceUri, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ExtensionsResourceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/LocationResourcesGetByLocationAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/LocationResourcesGetByLocationAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..5966a51823ac --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/LocationResourcesGetByLocationAsyncCollectionResultOfT.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class LocationResourcesGetByLocationAsyncCollectionResultOfT : AsyncPageable + { + private readonly LocationResources _client; + private readonly Guid _subscriptionId; + private readonly AzureLocation _location; + private readonly RequestContext _context; + + /// Initializes a new instance of LocationResourcesGetByLocationAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LocationResources client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the Azure region. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public LocationResourcesGetByLocationAsyncCollectionResultOfT(LocationResources client, Guid subscriptionId, AzureLocation location, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _location = location; + _context = context; + } + + /// Gets the pages of LocationResourcesGetByLocationAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LocationResourcesGetByLocationAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + LocationResourceListResult result = LocationResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByLocationRequest(nextLink, _subscriptionId, _location, _context) : _client.CreateGetByLocationRequest(_subscriptionId, _location, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LocationResourceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/LocationResourcesGetByLocationCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/LocationResourcesGetByLocationCollectionResultOfT.cs new file mode 100644 index 000000000000..97222f0a2801 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/LocationResourcesGetByLocationCollectionResultOfT.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class LocationResourcesGetByLocationCollectionResultOfT : Pageable + { + private readonly LocationResources _client; + private readonly Guid _subscriptionId; + private readonly AzureLocation _location; + private readonly RequestContext _context; + + /// Initializes a new instance of LocationResourcesGetByLocationCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The LocationResources client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the Azure region. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public LocationResourcesGetByLocationCollectionResultOfT(LocationResources client, Guid subscriptionId, AzureLocation location, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _location = location; + _context = context; + } + + /// Gets the pages of LocationResourcesGetByLocationCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of LocationResourcesGetByLocationCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + LocationResourceListResult result = LocationResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByLocationRequest(nextLink, _subscriptionId, _location, _context) : _client.CreateGetByLocationRequest(_subscriptionId, _location, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("LocationResourceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/NestedGetByTopLevelTrackedResourceAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/NestedGetByTopLevelTrackedResourceAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..eb40c00ffb76 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/NestedGetByTopLevelTrackedResourceAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class NestedGetByTopLevelTrackedResourceAsyncCollectionResultOfT : AsyncPageable + { + private readonly Nested _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _topLevelTrackedResourceName; + private readonly RequestContext _context; + + /// Initializes a new instance of NestedGetByTopLevelTrackedResourceAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Nested client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// arm resource name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public NestedGetByTopLevelTrackedResourceAsyncCollectionResultOfT(Nested client, Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _topLevelTrackedResourceName = topLevelTrackedResourceName; + _context = context; + } + + /// Gets the pages of NestedGetByTopLevelTrackedResourceAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of NestedGetByTopLevelTrackedResourceAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + NestedProxyResourceListResult result = NestedProxyResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByTopLevelTrackedResourceRequest(nextLink, _subscriptionId, _resourceGroupName, _topLevelTrackedResourceName, _context) : _client.CreateGetByTopLevelTrackedResourceRequest(_subscriptionId, _resourceGroupName, _topLevelTrackedResourceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("NestedProxyResourceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/NestedGetByTopLevelTrackedResourceCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/NestedGetByTopLevelTrackedResourceCollectionResultOfT.cs new file mode 100644 index 000000000000..5af8ac5b1da7 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/NestedGetByTopLevelTrackedResourceCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class NestedGetByTopLevelTrackedResourceCollectionResultOfT : Pageable + { + private readonly Nested _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _topLevelTrackedResourceName; + private readonly RequestContext _context; + + /// Initializes a new instance of NestedGetByTopLevelTrackedResourceCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Nested client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// arm resource name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public NestedGetByTopLevelTrackedResourceCollectionResultOfT(Nested client, Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _topLevelTrackedResourceName = topLevelTrackedResourceName; + _context = context; + } + + /// Gets the pages of NestedGetByTopLevelTrackedResourceCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of NestedGetByTopLevelTrackedResourceCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + NestedProxyResourceListResult result = NestedProxyResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByTopLevelTrackedResourceRequest(nextLink, _subscriptionId, _resourceGroupName, _topLevelTrackedResourceName, _context) : _client.CreateGetByTopLevelTrackedResourceRequest(_subscriptionId, _resourceGroupName, _topLevelTrackedResourceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("NestedProxyResourceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetByResourceGroupAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..8ad437d21181 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetByResourceGroupAsyncCollectionResultOfT.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class TopLevelGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly TopLevel _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of TopLevelGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TopLevel client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public TopLevelGetByResourceGroupAsyncCollectionResultOfT(TopLevel client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of TopLevelGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TopLevelGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + TopLevelTrackedResourceListResult result = TopLevelTrackedResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetByResourceGroupCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..67b3c7d4c5c5 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetByResourceGroupCollectionResultOfT.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class TopLevelGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly TopLevel _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of TopLevelGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TopLevel client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public TopLevelGetByResourceGroupCollectionResultOfT(TopLevel client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of TopLevelGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TopLevelGetByResourceGroupCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + TopLevelTrackedResourceListResult result = TopLevelTrackedResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetBySubscriptionAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..dab3a4db9c29 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetBySubscriptionAsyncCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class TopLevelGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly TopLevel _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of TopLevelGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TopLevel client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public TopLevelGetBySubscriptionAsyncCollectionResultOfT(TopLevel client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of TopLevelGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TopLevelGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + TopLevelTrackedResourceListResult result = TopLevelTrackedResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableResourcesSubscriptionResource.GetTopLevelTrackedResources"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetBySubscriptionCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..175eee8a0cf0 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/CollectionResults/TopLevelGetBySubscriptionCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class TopLevelGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly TopLevel _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of TopLevelGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TopLevel client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public TopLevelGetBySubscriptionCollectionResultOfT(TopLevel client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of TopLevelGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TopLevelGetBySubscriptionCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + TopLevelTrackedResourceListResult result = TopLevelTrackedResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableResourcesSubscriptionResource.GetTopLevelTrackedResources"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/MockableResourcesArmClient.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/MockableResourcesArmClient.cs new file mode 100644 index 000000000000..2487e77ef550 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/MockableResourcesArmClient.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Mocking +{ + /// A class to add extension methods to . + public partial class MockableResourcesArmClient : ArmResource + { + /// Initializes a new instance of MockableResourcesArmClient for mocking. + protected MockableResourcesArmClient() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableResourcesArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual TopLevelTrackedResource GetTopLevelTrackedResource(ResourceIdentifier id) + { + TopLevelTrackedResource.ValidateResourceId(id); + return new TopLevelTrackedResource(Client, id); + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NestedProxyResource GetNestedProxyResource(ResourceIdentifier id) + { + NestedProxyResource.ValidateResourceId(id); + return new NestedProxyResource(Client, id); + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual SingletonTrackedResource GetSingletonTrackedResource(ResourceIdentifier id) + { + SingletonTrackedResource.ValidateResourceId(id); + return new SingletonTrackedResource(Client, id); + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ExtensionsResource GetExtensionsResource(ResourceIdentifier id) + { + ExtensionsResource.ValidateResourceId(id); + return new ExtensionsResource(Client, id); + } + + /// Gets a collection of objects within the specified scope. + /// The scope of the resource collection to get. + /// Returns a collection of objects. + public virtual ExtensionsResourceCollection GetExtensionsResources(ResourceIdentifier scope) + { + return new ExtensionsResourceCollection(Client, scope); + } + + /// Get a ExtensionsResource. + /// The scope of the resource collection to get. + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetExtensionsResource(ResourceIdentifier scope, string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + + return GetExtensionsResources(scope).Get(extensionsResourceName, cancellationToken); + } + + /// Get a ExtensionsResource. + /// The scope of the resource collection to get. + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetExtensionsResourceAsync(ResourceIdentifier scope, string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + + return await GetExtensionsResources(scope).GetAsync(extensionsResourceName, cancellationToken).ConfigureAwait(false); + } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual LocationResource GetLocationResource(ResourceIdentifier id) + { + LocationResource.ValidateResourceId(id); + return new LocationResource(Client, id); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/MockableResourcesResourceGroupResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/MockableResourcesResourceGroupResource.cs new file mode 100644 index 000000000000..947a0e3c7854 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/MockableResourcesResourceGroupResource.cs @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Mocking +{ + /// A class to add extension methods to . + public partial class MockableResourcesResourceGroupResource : ArmResource + { + /// Initializes a new instance of MockableResourcesResourceGroupResource for mocking. + protected MockableResourcesResourceGroupResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableResourcesResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets a collection of TopLevelTrackedResources in the . + /// An object representing collection of TopLevelTrackedResources and their operations over a TopLevelTrackedResource. + public virtual TopLevelTrackedResourceCollection GetTopLevelTrackedResources() + { + return GetCachedClient(client => new TopLevelTrackedResourceCollection(client, Id)); + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTopLevelTrackedResourceAsync(string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + + return await GetTopLevelTrackedResources().GetAsync(topLevelTrackedResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTopLevelTrackedResource(string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + + return GetTopLevelTrackedResources().Get(topLevelTrackedResourceName, cancellationToken); + } + + /// + /// Get a SingletonTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default. + /// + /// + /// Operation Id. + /// Singleton_GetByResourceGroup. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// Returns a object. + public virtual SingletonTrackedResource GetSingletonTrackedResource() + { + return new SingletonTrackedResource(Client, Id.AppendProviderResource("Azure.ResourceManager.Resources", "singletonTrackedResources", "default")); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/MockableResourcesSubscriptionResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/MockableResourcesSubscriptionResource.cs new file mode 100644 index 000000000000..6f293bf90450 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/MockableResourcesSubscriptionResource.cs @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Mocking +{ + /// A class to add extension methods to . + public partial class MockableResourcesSubscriptionResource : ArmResource + { + private ClientDiagnostics _topLevelClientDiagnostics; + private TopLevel _topLevelRestClient; + + /// Initializes a new instance of MockableResourcesSubscriptionResource for mocking. + protected MockableResourcesSubscriptionResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableResourcesSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics TopLevelClientDiagnostics => _topLevelClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Resources.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private TopLevel TopLevelRestClient => _topLevelRestClient ??= new TopLevel(TopLevelClientDiagnostics, Pipeline, Endpoint, "2023-12-01-preview"); + + /// Gets a collection of LocationResources in the . + /// The location for the resource. + /// An object representing collection of LocationResources and their operations over a LocationResource. + public virtual LocationResourceCollection GetLocationResources(AzureLocation location) + { + return GetCachedClient(client => new LocationResourceCollection(client, Id, location)); + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The location for the resource. + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetLocationResourceAsync(AzureLocation location, string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + + return await GetLocationResources(location).GetAsync(locationResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The location for the resource. + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetLocationResource(AzureLocation location, string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + + return GetLocationResources(location).Get(locationResourceName, cancellationToken); + } + + /// + /// List TopLevelTrackedResource resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources. + /// + /// + /// Operation Id. + /// TopLevel_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetTopLevelTrackedResourcesAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new TopLevelGetBySubscriptionAsyncCollectionResultOfT(TopLevelRestClient, Guid.Parse(Id.SubscriptionId), context), data => new TopLevelTrackedResource(Client, data)); + } + + /// + /// List TopLevelTrackedResource resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources. + /// + /// + /// Operation Id. + /// TopLevel_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetTopLevelTrackedResources(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new TopLevelGetBySubscriptionCollectionResultOfT(TopLevelRestClient, Guid.Parse(Id.SubscriptionId), context), data => new TopLevelTrackedResource(Client, data)); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/ResourcesExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/ResourcesExtensions.cs new file mode 100644 index 000000000000..78feee841d56 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Extensions/ResourcesExtensions.cs @@ -0,0 +1,353 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources.Mocking; + +namespace Azure.ResourceManager.Resources +{ + /// A class to add extension methods to Azure.ResourceManager.Resources. + public static partial class ResourcesExtensions + { + /// + private static MockableResourcesArmClient GetMockableResourcesArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableResourcesArmClient(client0, ResourceIdentifier.Root)); + } + + /// + private static MockableResourcesResourceGroupResource GetMockableResourcesResourceGroupResource(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient(client => new MockableResourcesResourceGroupResource(client, resourceGroupResource.Id)); + } + + /// + private static MockableResourcesSubscriptionResource GetMockableResourcesSubscriptionResource(SubscriptionResource subscriptionResource) + { + return subscriptionResource.GetCachedClient(client => new MockableResourcesSubscriptionResource(client, subscriptionResource.Id)); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static TopLevelTrackedResource GetTopLevelTrackedResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableResourcesArmClient(client).GetTopLevelTrackedResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NestedProxyResource GetNestedProxyResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableResourcesArmClient(client).GetNestedProxyResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static SingletonTrackedResource GetSingletonTrackedResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableResourcesArmClient(client).GetSingletonTrackedResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ExtensionsResource GetExtensionsResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableResourcesArmClient(client).GetExtensionsResource(id); + } + + /// + /// Gets a collection of objects within the specified scope. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The scope of the resource collection to get. + /// is null. + /// Returns a collection of objects. + public static ExtensionsResourceCollection GetExtensionsResources(this ArmClient client, ResourceIdentifier scope) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableResourcesArmClient(client).GetExtensionsResources(scope); + } + + /// + /// Get a ExtensionsResource + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The scope of the resource collection to get. + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetExtensionsResource(this ArmClient client, ResourceIdentifier scope, string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableResourcesArmClient(client).GetExtensionsResource(scope, extensionsResourceName, cancellationToken); + } + + /// + /// Get a ExtensionsResource + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The scope of the resource collection to get. + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetExtensionsResourceAsync(this ArmClient client, ResourceIdentifier scope, string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return await GetMockableResourcesArmClient(client).GetExtensionsResourceAsync(scope, extensionsResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static LocationResource GetLocationResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableResourcesArmClient(client).GetLocationResource(id); + } + + /// + /// Gets a collection of TopLevelTrackedResources in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of TopLevelTrackedResources and their operations over a TopLevelTrackedResource. + public static TopLevelTrackedResourceCollection GetTopLevelTrackedResources(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableResourcesResourceGroupResource(resourceGroupResource).GetTopLevelTrackedResources(); + } + + /// + /// Get a TopLevelTrackedResource + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetTopLevelTrackedResourceAsync(this ResourceGroupResource resourceGroupResource, string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableResourcesResourceGroupResource(resourceGroupResource).GetTopLevelTrackedResourceAsync(topLevelTrackedResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a TopLevelTrackedResource + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetTopLevelTrackedResource(this ResourceGroupResource resourceGroupResource, string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableResourcesResourceGroupResource(resourceGroupResource).GetTopLevelTrackedResource(topLevelTrackedResourceName, cancellationToken); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it in the . + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// Returns a object. + public static SingletonTrackedResource GetSingletonTrackedResource(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableResourcesResourceGroupResource(resourceGroupResource).GetSingletonTrackedResource(); + } + + /// + /// Gets a collection of LocationResources in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The location for the resource. + /// is null. + /// An object representing collection of LocationResources and their operations over a LocationResource. + public static LocationResourceCollection GetLocationResources(this SubscriptionResource subscriptionResource, AzureLocation location) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableResourcesSubscriptionResource(subscriptionResource).GetLocationResources(location); + } + + /// + /// Get a LocationResource + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The location for the resource. + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetLocationResourceAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableResourcesSubscriptionResource(subscriptionResource).GetLocationResourceAsync(location, locationResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a LocationResource + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The location for the resource. + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetLocationResource(this SubscriptionResource subscriptionResource, AzureLocation location, string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableResourcesSubscriptionResource(subscriptionResource).GetLocationResource(location, locationResourceName, cancellationToken); + } + + /// + /// List TopLevelTrackedResource resources by subscription ID + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetTopLevelTrackedResourcesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableResourcesSubscriptionResource(subscriptionResource).GetTopLevelTrackedResourcesAsync(cancellationToken); + } + + /// + /// List TopLevelTrackedResource resources by subscription ID + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetTopLevelTrackedResources(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableResourcesSubscriptionResource(subscriptionResource).GetTopLevelTrackedResources(cancellationToken); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResource.Serialization.cs new file mode 100644 index 000000000000..6af227ea0dd5 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Resources +{ + /// + public partial class ExtensionsResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ExtensionsResourceData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + ExtensionsResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerResourcesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + ExtensionsResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerResourcesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResource.cs new file mode 100644 index 000000000000..420baf1c2e1b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResource.cs @@ -0,0 +1,394 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + /// A class representing a ExtensionsResource along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetExtensionsResources method. + /// + public partial class ExtensionsResource : ArmResource + { + private readonly ClientDiagnostics _extensionsResourcesClientDiagnostics; + private readonly ExtensionsResources _extensionsResourcesRestClient; + private readonly ExtensionsResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Azure.ResourceManager.Resources/extensionsResources"; + + /// Initializes a new instance of ExtensionsResource for mocking. + protected ExtensionsResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ExtensionsResource(ArmClient client, ExtensionsResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ExtensionsResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string extensionsResourceApiVersion); + _extensionsResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", ResourceType.Namespace, Diagnostics); + _extensionsResourcesRestClient = new ExtensionsResources(_extensionsResourcesClientDiagnostics, Pipeline, Endpoint, extensionsResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual ExtensionsResourceData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The resourceUri. + /// The extensionsResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string resourceUri, string extensionsResourceName) + { + string resourceId = $"{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ExtensionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ExtensionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(ExtensionsResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateUpdateRequest(Id.Parent, Id.Name, ExtensionsResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ExtensionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(ExtensionsResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateUpdateRequest(Id.Parent, Id.Name, ExtensionsResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ExtensionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateDeleteRequest(Id.Parent, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ResourcesArmOperation operation = new ResourcesArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateDeleteRequest(Id.Parent, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ResourcesArmOperation operation = new ResourcesArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResourceCollection.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResourceCollection.cs new file mode 100644 index 000000000000..6e4659f7dee9 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResourceCollection.cs @@ -0,0 +1,567 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetExtensionsResources method from an instance of . + /// + public partial class ExtensionsResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _extensionsResourcesClientDiagnostics; + private readonly ExtensionsResources _extensionsResourcesRestClient; + + /// Initializes a new instance of ExtensionsResourceCollection for mocking. + protected ExtensionsResourceCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ExtensionsResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ExtensionsResource.ResourceType, out string extensionsResourceApiVersion); + _extensionsResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", ExtensionsResource.ResourceType.Namespace, Diagnostics); + _extensionsResourcesRestClient = new ExtensionsResources(_extensionsResourcesClientDiagnostics, Pipeline, Endpoint, extensionsResourceApiVersion ?? "2023-12-01-preview"); + } + + /// + /// Create a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the ExtensionsResource. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string extensionsResourceName, ExtensionsResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateCreateOrUpdateRequest(Id, extensionsResourceName, ExtensionsResourceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ResourcesArmOperation operation = new ResourcesArmOperation( + new ExtensionsResourceOperationSource(Client), + _extensionsResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the ExtensionsResource. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string extensionsResourceName, ExtensionsResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateCreateOrUpdateRequest(Id, extensionsResourceName, ExtensionsResourceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ResourcesArmOperation operation = new ResourcesArmOperation( + new ExtensionsResourceOperationSource(Client), + _extensionsResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateGetRequest(Id, extensionsResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ExtensionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateGetRequest(Id, extensionsResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ExtensionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List ExtensionsResource resources by parent + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources. + /// + /// + /// Operation Id. + /// ExtensionsResources_ListByScope. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ExtensionsResourcesGetByScopeAsyncCollectionResultOfT(_extensionsResourcesRestClient, Id, context), data => new ExtensionsResource(Client, data)); + } + + /// + /// List ExtensionsResource resources by parent + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources. + /// + /// + /// Operation Id. + /// ExtensionsResources_ListByScope. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ExtensionsResourcesGetByScopeCollectionResultOfT(_extensionsResourcesRestClient, Id, context), data => new ExtensionsResource(Client, data)); + } + + /// + /// Get a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateGetRequest(Id, extensionsResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ExtensionsResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateGetRequest(Id, extensionsResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ExtensionsResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateGetRequest(Id, extensionsResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ExtensionsResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ExtensionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ExtensionsResource + /// + /// + /// Request Path. + /// /{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}. + /// + /// + /// Operation Id. + /// ExtensionsResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the ExtensionsResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string extensionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(extensionsResourceName, nameof(extensionsResourceName)); + + using DiagnosticScope scope = _extensionsResourcesClientDiagnostics.CreateScope("ExtensionsResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _extensionsResourcesRestClient.CreateGetRequest(Id, extensionsResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ExtensionsResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ExtensionsResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ExtensionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.Serialization.cs new file mode 100644 index 000000000000..09ad5a5480f3 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.Serialization.cs @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Concrete extension resource types can be created by aliasing this type using a specific property type. + public partial class ExtensionsResourceData : ResourceData, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExtensionsResourceData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ExtensionsResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ExtensionsResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExtensionsResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExtensionsResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ExtensionsResourceData DeserializeExtensionsResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ExtensionsResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerResourcesContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ExtensionsResourceProperties.DeserializeExtensionsResourceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ExtensionsResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(ExtensionsResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ExtensionsResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ExtensionsResourceData)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeExtensionsResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExtensionsResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ExtensionsResourceData extensionsResourceData) + { + if (extensionsResourceData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(extensionsResourceData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static ExtensionsResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeExtensionsResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.cs new file mode 100644 index 000000000000..156ca4821d95 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Concrete extension resource types can be created by aliasing this type using a specific property type. + public partial class ExtensionsResourceData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ExtensionsResourceData() + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// The resource-specific properties for this resource. + internal ExtensionsResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, ExtensionsResourceProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public ExtensionsResourceProperties Properties { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/Argument.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..f0ac363ddbf6 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/Argument.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Resources +{ + internal static partial class Argument + { + /// The value. + /// The name. + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/AsyncPageableWrapper.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..f4693df5f04f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/AsyncPageableWrapper.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; + +namespace Azure.ResourceManager.Resources +{ + internal partial class AsyncPageableWrapper : AsyncPageable + { + /// The source async pageable value of type AsyncPageable<T>. + private AsyncPageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the AsyncPageableWrapper class. + /// The source async pageable value of type AsyncPageable<T>. + /// The converter function from T to U. + public AsyncPageableWrapper(AsyncPageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from AsyncPageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + await foreach (Page page in _source.AsPages(continuationToken, pageSizeHint).ConfigureAwait(false)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ChangeTrackingDictionary.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..8a9fbeebe6bf --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Resources +{ + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerDictionary == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + /// Gets the Keys. + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + /// Gets the Values. + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + /// Gets or sets the value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + /// Gets the Keys. + IEnumerable IReadOnlyDictionary.Keys => Keys; + + /// Gets the Values. + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + /// The item to search for. + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + /// The array to copy. + /// The index. + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + /// The item to remove. + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + /// The key. + /// The value to add. + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + /// The key to search for. + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + /// The key. + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + /// The key to search for. + /// The value. + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ChangeTrackingList.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..1b58bf7d01a4 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Resources +{ + internal partial class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + /// The inner list. + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + /// The inner list. + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerList == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureList().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + /// Gets or sets the value associated with the specified key. + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + /// The item. + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + /// The array to copy to. + /// The array index. + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + /// The item. + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + /// The item. + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + /// The inner list. + /// The item. + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + /// The inner list. + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ClientPipelineExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..f8652447f118 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Resources +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenMemberAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..3ef2e4e5f774 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Resources +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenSerializationAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..d82788f67779 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Resources +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenSuppressAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..8e55b367e6ff --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Resources +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenTypeAttribute.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..3f7a2cb4249f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Resources +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ErrorResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..a705977577ba --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.ResourceManager.Resources +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ModelSerializationExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..dd2207d5d029 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; + +namespace Azure.ResourceManager.Resources +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + Dictionary dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + List list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/Optional.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..fecbccc19113 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.Resources +{ + internal static partial class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(string value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/PageableWrapper.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..2ebef38eaae6 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/PageableWrapper.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.ResourceManager.Resources +{ + internal partial class PageableWrapper : Pageable + { + /// The source pageable value of type Pageable<T>. + private Pageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the PageableWrapper class. + /// The source pageable value of type Pageable<T>. + /// The converter function from T to U. + public PageableWrapper(Pageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from Pageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + foreach (Page page in _source.AsPages(continuationToken, pageSizeHint)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..27ba308e15aa --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Resources +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/RequestContextExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..e6ef9f42190b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.Resources +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/SerializationFormat.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..5a4ed2ebf55e --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Resources +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/TypeFormatters.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..d3ee88a62c4e --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.Resources +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/Utf8JsonRequestContent.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..283af32df99e --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.Resources +{ + internal partial class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + /// Gets the JsonWriter. + public Utf8JsonWriter JsonWriter { get; } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + /// The stream containing the data to be written. + /// The cancellation token to use. + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + /// + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResource.Serialization.cs new file mode 100644 index 000000000000..d14ffde4a7b4 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Resources +{ + /// + public partial class LocationResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new LocationResourceData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + LocationResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerResourcesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + LocationResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerResourcesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResource.cs new file mode 100644 index 000000000000..a10416af4f7b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResource.cs @@ -0,0 +1,395 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + /// A class representing a LocationResource along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetLocationResources method. + /// + public partial class LocationResource : ArmResource + { + private readonly ClientDiagnostics _locationResourcesClientDiagnostics; + private readonly LocationResources _locationResourcesRestClient; + private readonly LocationResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Azure.ResourceManager.Resources/locations/locationResources"; + + /// Initializes a new instance of LocationResource for mocking. + protected LocationResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal LocationResource(ArmClient client, LocationResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal LocationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string locationResourceApiVersion); + _locationResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", ResourceType.Namespace, Diagnostics); + _locationResourcesRestClient = new LocationResources(_locationResourcesClientDiagnostics, Pipeline, Endpoint, locationResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual LocationResourceData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The location. + /// The locationResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, AzureLocation location, string locationResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(LocationResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(LocationResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(LocationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.Parent.Name, Id.Name, LocationResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(LocationResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(LocationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.Parent.Name, Id.Name, LocationResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(LocationResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ResourcesArmOperation operation = new ResourcesArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ResourcesArmOperation operation = new ResourcesArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResourceCollection.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResourceCollection.cs new file mode 100644 index 000000000000..0ce1a9d8976a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResourceCollection.cs @@ -0,0 +1,577 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetLocationResources method from an instance of . + /// + public partial class LocationResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _locationResourcesClientDiagnostics; + private readonly LocationResources _locationResourcesRestClient; + /// The location. + private readonly AzureLocation _location; + + /// Initializes a new instance of LocationResourceCollection for mocking. + protected LocationResourceCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + /// The location for the resource. + internal LocationResourceCollection(ArmClient client, ResourceIdentifier id, AzureLocation location) : base(client, id) + { + TryGetApiVersion(LocationResource.ResourceType, out string locationResourceApiVersion); + _location = location; + _locationResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", LocationResource.ResourceType.Namespace, Diagnostics); + _locationResourcesRestClient = new LocationResources(_locationResourcesClientDiagnostics, Pipeline, Endpoint, locationResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != SubscriptionResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, SubscriptionResource.ResourceType), id); + } + } + + /// + /// Create a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the LocationResource. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string locationResourceName, LocationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), _location, locationResourceName, LocationResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(LocationResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ResourcesArmOperation operation = new ResourcesArmOperation(Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the LocationResource. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string locationResourceName, LocationResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), _location, locationResourceName, LocationResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(LocationResourceData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + ResourcesArmOperation operation = new ResourcesArmOperation(Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), _location, locationResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(LocationResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), _location, locationResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(LocationResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List LocationResource resources by SubscriptionLocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources. + /// + /// + /// Operation Id. + /// LocationResources_ListByLocation. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new LocationResourcesGetByLocationAsyncCollectionResultOfT(_locationResourcesRestClient, Guid.Parse(Id.SubscriptionId), _location, context), data => new LocationResource(Client, data)); + } + + /// + /// List LocationResource resources by SubscriptionLocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources. + /// + /// + /// Operation Id. + /// LocationResources_ListByLocation. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new LocationResourcesGetByLocationCollectionResultOfT(_locationResourcesRestClient, Guid.Parse(Id.SubscriptionId), _location, context), data => new LocationResource(Client, data)); + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), _location, locationResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(LocationResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((LocationResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), _location, locationResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(LocationResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((LocationResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), _location, locationResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(LocationResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((LocationResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a LocationResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}. + /// + /// + /// Operation Id. + /// LocationResources_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The name of the LocationResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string locationResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationResourceName, nameof(locationResourceName)); + + using DiagnosticScope scope = _locationResourcesClientDiagnostics.CreateScope("LocationResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _locationResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), _location, locationResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(LocationResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((LocationResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new LocationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResourceData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResourceData.Serialization.cs new file mode 100644 index 000000000000..6b4392d13590 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResourceData.Serialization.cs @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + public partial class LocationResourceData : ResourceData, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocationResourceData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + LocationResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (LocationResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocationResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocationResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LocationResourceData DeserializeLocationResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + LocationResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerResourcesContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = LocationResourceProperties.DeserializeLocationResourceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new LocationResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(LocationResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + LocationResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (LocationResourceData)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeLocationResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocationResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(LocationResourceData locationResourceData) + { + if (locationResourceData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(locationResourceData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static LocationResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLocationResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResourceData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResourceData.cs new file mode 100644 index 000000000000..2425b4d567b3 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LocationResourceData.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + public partial class LocationResourceData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public LocationResourceData() + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// The resource-specific properties for this resource. + internal LocationResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, LocationResourceProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public LocationResourceProperties Properties { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/ExtensionsResourceOperationSource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/ExtensionsResourceOperationSource.cs new file mode 100644 index 000000000000..1792d7e633c4 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/ExtensionsResourceOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + internal partial class ExtensionsResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal ExtensionsResourceOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + ExtensionsResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + ExtensionsResourceData data = ExtensionsResourceData.DeserializeExtensionsResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ExtensionsResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + ExtensionsResourceData data = ExtensionsResourceData.DeserializeExtensionsResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ExtensionsResource(_client, data); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/NestedProxyResourceOperationSource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/NestedProxyResourceOperationSource.cs new file mode 100644 index 000000000000..c236bf85aba8 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/NestedProxyResourceOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + internal partial class NestedProxyResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal NestedProxyResourceOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + NestedProxyResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + NestedProxyResourceData data = NestedProxyResourceData.DeserializeNestedProxyResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new NestedProxyResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + NestedProxyResourceData data = NestedProxyResourceData.DeserializeNestedProxyResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new NestedProxyResource(_client, data); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperation.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperation.cs new file mode 100644 index 000000000000..f90cf3064cff --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperation.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + internal partial class ResourcesArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of ResourcesArmOperation for mocking. + protected ResourcesArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal ResourcesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal ResourcesArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "ResourcesArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperationOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperationOfT.cs new file mode 100644 index 000000000000..456a20abf221 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperationOfT.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + internal partial class ResourcesArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of ResourcesArmOperation for mocking. + protected ResourcesArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal ResourcesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal ResourcesArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "ResourcesArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the Value. + public override T Value => _operation.Value; + + /// Gets the HasValue. + public override bool HasValue => _operation.HasValue; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/SingletonTrackedResourceOperationSource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/SingletonTrackedResourceOperationSource.cs new file mode 100644 index 000000000000..cd81de6b4b0d --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/SingletonTrackedResourceOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + internal partial class SingletonTrackedResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal SingletonTrackedResourceOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + SingletonTrackedResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + SingletonTrackedResourceData data = SingletonTrackedResourceData.DeserializeSingletonTrackedResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new SingletonTrackedResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + SingletonTrackedResourceData data = SingletonTrackedResourceData.DeserializeSingletonTrackedResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new SingletonTrackedResource(_client, data); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/TopLevelTrackedResourceOperationSource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/TopLevelTrackedResourceOperationSource.cs new file mode 100644 index 000000000000..4966216492d9 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/LongRunningOperation/TopLevelTrackedResourceOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + internal partial class TopLevelTrackedResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal TopLevelTrackedResourceOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + TopLevelTrackedResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + TopLevelTrackedResourceData data = TopLevelTrackedResourceData.DeserializeTopLevelTrackedResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new TopLevelTrackedResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + TopLevelTrackedResourceData data = TopLevelTrackedResourceData.DeserializeTopLevelTrackedResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new TopLevelTrackedResource(_client, data); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/AzureResourceManagerResourcesContext.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/AzureResourceManagerResourcesContext.cs new file mode 100644 index 000000000000..febc383c234b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/AzureResourceManagerResourcesContext.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(ExtensionsResource))] + [ModelReaderWriterBuildable(typeof(ExtensionsResourceData))] + [ModelReaderWriterBuildable(typeof(ExtensionsResourceListResult))] + [ModelReaderWriterBuildable(typeof(ExtensionsResourceProperties))] + [ModelReaderWriterBuildable(typeof(LocationResource))] + [ModelReaderWriterBuildable(typeof(LocationResourceData))] + [ModelReaderWriterBuildable(typeof(LocationResourceListResult))] + [ModelReaderWriterBuildable(typeof(LocationResourceProperties))] + [ModelReaderWriterBuildable(typeof(NestedProxyResource))] + [ModelReaderWriterBuildable(typeof(NestedProxyResourceData))] + [ModelReaderWriterBuildable(typeof(NestedProxyResourceListResult))] + [ModelReaderWriterBuildable(typeof(NestedProxyResourceProperties))] + [ModelReaderWriterBuildable(typeof(NotificationDetails))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(SingletonTrackedResource))] + [ModelReaderWriterBuildable(typeof(SingletonTrackedResourceData))] + [ModelReaderWriterBuildable(typeof(SingletonTrackedResourceProperties))] + [ModelReaderWriterBuildable(typeof(SystemData))] + [ModelReaderWriterBuildable(typeof(TopLevelTrackedResource))] + [ModelReaderWriterBuildable(typeof(TopLevelTrackedResourceData))] + [ModelReaderWriterBuildable(typeof(TopLevelTrackedResourceListResult))] + [ModelReaderWriterBuildable(typeof(TopLevelTrackedResourceProperties))] + public partial class AzureResourceManagerResourcesContext : ModelReaderWriterContext + { + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceListResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceListResult.Serialization.cs new file mode 100644 index 000000000000..852b243ae9c1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceListResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The response of a ExtensionsResource list operation. + internal partial class ExtensionsResourceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ExtensionsResourceListResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExtensionsResourceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (ExtensionsResourceData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ExtensionsResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ExtensionsResourceListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExtensionsResourceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExtensionsResourceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ExtensionsResourceListResult DeserializeExtensionsResourceListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ExtensionsResourceData.DeserializeExtensionsResourceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ExtensionsResourceListResult(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(ExtensionsResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ExtensionsResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ExtensionsResourceListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeExtensionsResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExtensionsResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ExtensionsResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeExtensionsResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceListResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceListResult.cs new file mode 100644 index 000000000000..1189a5e7e4e9 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceListResult.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The response of a ExtensionsResource list operation. + internal partial class ExtensionsResourceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The ExtensionsResource items on this page. + internal ExtensionsResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The ExtensionsResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal ExtensionsResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ExtensionsResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceProperties.Serialization.cs new file mode 100644 index 000000000000..df0c3afdb65d --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceProperties.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// ExtensionsResource properties. + public partial class ExtensionsResourceProperties : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExtensionsResourceProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ExtensionsResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ExtensionsResourceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExtensionsResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExtensionsResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ExtensionsResourceProperties DeserializeExtensionsResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ExtensionsResourceProperties(description, provisioningState, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(ExtensionsResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ExtensionsResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ExtensionsResourceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeExtensionsResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExtensionsResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceProperties.cs new file mode 100644 index 000000000000..8bdeb29daff4 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ExtensionsResourceProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Resources.Models +{ + /// ExtensionsResource properties. + public partial class ExtensionsResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ExtensionsResourceProperties() + { + } + + /// Initializes a new instance of . + /// The description of the resource. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal ExtensionsResourceProperties(string description, ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + Description = description; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The description of the resource. + public string Description { get; set; } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceListResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceListResult.Serialization.cs new file mode 100644 index 000000000000..cae1f984c277 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceListResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The response of a LocationResource list operation. + internal partial class LocationResourceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal LocationResourceListResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocationResourceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (LocationResourceData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + LocationResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LocationResourceListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocationResourceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocationResourceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LocationResourceListResult DeserializeLocationResourceListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(LocationResourceData.DeserializeLocationResourceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new LocationResourceListResult(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(LocationResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + LocationResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LocationResourceListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeLocationResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocationResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static LocationResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLocationResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceListResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceListResult.cs new file mode 100644 index 000000000000..799ea25f2381 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceListResult.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The response of a LocationResource list operation. + internal partial class LocationResourceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The LocationResource items on this page. + internal LocationResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The LocationResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal LocationResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The LocationResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceProperties.Serialization.cs new file mode 100644 index 000000000000..43e5060f66df --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceProperties.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Location resource properties. + public partial class LocationResourceProperties : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocationResourceProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + LocationResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LocationResourceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocationResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocationResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LocationResourceProperties DeserializeLocationResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new LocationResourceProperties(description, provisioningState, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(LocationResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + LocationResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LocationResourceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeLocationResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocationResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceProperties.cs new file mode 100644 index 000000000000..e9236aba0598 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/LocationResourceProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Location resource properties. + public partial class LocationResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public LocationResourceProperties() + { + } + + /// Initializes a new instance of . + /// The description of the resource. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal LocationResourceProperties(string description, ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + Description = description; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The description of the resource. + public string Description { get; set; } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceListResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceListResult.Serialization.cs new file mode 100644 index 000000000000..c275a82c25c6 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceListResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The response of a NestedProxyResource list operation. + internal partial class NestedProxyResourceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal NestedProxyResourceListResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NestedProxyResourceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (NestedProxyResourceData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + NestedProxyResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual NestedProxyResourceListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NestedProxyResourceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNestedProxyResourceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NestedProxyResourceListResult DeserializeNestedProxyResourceListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(NestedProxyResourceData.DeserializeNestedProxyResourceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new NestedProxyResourceListResult(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(NestedProxyResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + NestedProxyResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual NestedProxyResourceListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeNestedProxyResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NestedProxyResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static NestedProxyResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNestedProxyResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceListResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceListResult.cs new file mode 100644 index 000000000000..6546b9332d70 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceListResult.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The response of a NestedProxyResource list operation. + internal partial class NestedProxyResourceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The NestedProxyResource items on this page. + internal NestedProxyResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The NestedProxyResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal NestedProxyResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The NestedProxyResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceProperties.Serialization.cs new file mode 100644 index 000000000000..14d90eba4cac --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceProperties.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Nested Proxy Resource Properties. + public partial class NestedProxyResourceProperties : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NestedProxyResourceProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + NestedProxyResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual NestedProxyResourceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NestedProxyResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNestedProxyResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NestedProxyResourceProperties DeserializeNestedProxyResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + string description = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new NestedProxyResourceProperties(provisioningState, description, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(NestedProxyResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + NestedProxyResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual NestedProxyResourceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeNestedProxyResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NestedProxyResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceProperties.cs new file mode 100644 index 000000000000..b252dd153882 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NestedProxyResourceProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Nested Proxy Resource Properties. + public partial class NestedProxyResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public NestedProxyResourceProperties() + { + } + + /// Initializes a new instance of . + /// Provisioning State of the nested child Resource. + /// Nested resource description. + /// Keeps track of any properties unknown to the library. + internal NestedProxyResourceProperties(ProvisioningState? provisioningState, string description, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + Description = description; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Provisioning State of the nested child Resource. + public ProvisioningState? ProvisioningState { get; } + + /// Nested resource description. + public string Description { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NotificationDetails.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NotificationDetails.Serialization.cs new file mode 100644 index 000000000000..0ae404064cb5 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NotificationDetails.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The details of a user notification. + public partial class NotificationDetails : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal NotificationDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationDetails)} does not support writing '{format}' format."); + } + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + writer.WritePropertyName("urgent"u8); + writer.WriteBooleanValue(Urgent); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + NotificationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual NotificationDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NotificationDetails DeserializeNotificationDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string message = default; + bool urgent = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("message"u8)) + { + message = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("urgent"u8)) + { + urgent = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new NotificationDetails(message, urgent, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(NotificationDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + NotificationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual NotificationDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeNotificationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(NotificationDetails notificationDetails) + { + if (notificationDetails == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(notificationDetails, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NotificationDetails.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NotificationDetails.cs new file mode 100644 index 000000000000..9bc5c68449ae --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/NotificationDetails.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The details of a user notification. + public partial class NotificationDetails + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The notification message. + /// If true, the notification is urgent. + /// is null. + public NotificationDetails(string message, bool urgent) + { + Argument.AssertNotNull(message, nameof(message)); + + Message = message; + Urgent = urgent; + } + + /// Initializes a new instance of . + /// The notification message. + /// If true, the notification is urgent. + /// Keeps track of any properties unknown to the library. + internal NotificationDetails(string message, bool urgent, IDictionary additionalBinaryDataProperties) + { + Message = message; + Urgent = urgent; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The notification message. + public string Message { get; } + + /// If true, the notification is urgent. + public bool Urgent { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ProvisioningState.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..6e6e44525c98 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// + public readonly partial struct ProvisioningState : IEquatable + { + private readonly string _value; + /// Resource has been created. + private const string SucceededValue = "Succeeded"; + /// Resource creation failed. + private const string FailedValue = "Failed"; + /// Resource creation was canceled. + private const string CanceledValue = "Canceled"; + private const string ProvisioningValue = "Provisioning"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string AcceptedValue = "Accepted"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ProvisioningState(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Resource has been created. + public static ProvisioningState Succeeded { get; } = new ProvisioningState(SucceededValue); + + /// Resource creation failed. + public static ProvisioningState Failed { get; } = new ProvisioningState(FailedValue); + + /// Resource creation was canceled. + public static ProvisioningState Canceled { get; } = new ProvisioningState(CanceledValue); + + /// Gets the Provisioning. + public static ProvisioningState Provisioning { get; } = new ProvisioningState(ProvisioningValue); + + /// Gets the Updating. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + + /// Gets the Deleting. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + + /// Gets the Accepted. + public static ProvisioningState Accepted { get; } = new ProvisioningState(AcceptedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ProvisioningState left, ProvisioningState right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ProvisioningState left, ProvisioningState right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ProvisioningState(string value) => new ProvisioningState(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ProvisioningState?(string value) => value == null ? null : new ProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProvisioningState other && Equals(other); + + /// + public bool Equals(ProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/SingletonTrackedResourceProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/SingletonTrackedResourceProperties.Serialization.cs new file mode 100644 index 000000000000..21f86c538bef --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/SingletonTrackedResourceProperties.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Singleton Arm Resource Properties. + public partial class SingletonTrackedResourceProperties : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SingletonTrackedResourceProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SingletonTrackedResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SingletonTrackedResourceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SingletonTrackedResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSingletonTrackedResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SingletonTrackedResourceProperties DeserializeSingletonTrackedResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + string description = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SingletonTrackedResourceProperties(provisioningState, description, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(SingletonTrackedResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SingletonTrackedResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SingletonTrackedResourceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSingletonTrackedResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SingletonTrackedResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/SingletonTrackedResourceProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/SingletonTrackedResourceProperties.cs new file mode 100644 index 000000000000..001e0bb07831 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/SingletonTrackedResourceProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Singleton Arm Resource Properties. + public partial class SingletonTrackedResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SingletonTrackedResourceProperties() + { + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// The description of the resource. + /// Keeps track of any properties unknown to the library. + internal SingletonTrackedResourceProperties(ProvisioningState? provisioningState, string description, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + Description = description; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// The description of the resource. + public string Description { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceListResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceListResult.Serialization.cs new file mode 100644 index 000000000000..faf063ffe966 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceListResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The response of a TopLevelTrackedResource list operation. + internal partial class TopLevelTrackedResourceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TopLevelTrackedResourceListResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TopLevelTrackedResourceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (TopLevelTrackedResourceData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TopLevelTrackedResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TopLevelTrackedResourceListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TopLevelTrackedResourceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTopLevelTrackedResourceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TopLevelTrackedResourceListResult DeserializeTopLevelTrackedResourceListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TopLevelTrackedResourceData.DeserializeTopLevelTrackedResourceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TopLevelTrackedResourceListResult(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(TopLevelTrackedResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + TopLevelTrackedResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TopLevelTrackedResourceListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTopLevelTrackedResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TopLevelTrackedResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TopLevelTrackedResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTopLevelTrackedResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceListResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceListResult.cs new file mode 100644 index 000000000000..606280a5de61 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceListResult.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// The response of a TopLevelTrackedResource list operation. + internal partial class TopLevelTrackedResourceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The TopLevelTrackedResource items on this page. + internal TopLevelTrackedResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The TopLevelTrackedResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal TopLevelTrackedResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The TopLevelTrackedResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceProperties.Serialization.cs new file mode 100644 index 000000000000..13216b6e3f1f --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceProperties.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Top Level Arm Resource Properties. + public partial class TopLevelTrackedResourceProperties : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TopLevelTrackedResourceProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TopLevelTrackedResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TopLevelTrackedResourceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TopLevelTrackedResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTopLevelTrackedResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TopLevelTrackedResourceProperties DeserializeTopLevelTrackedResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + string description = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TopLevelTrackedResourceProperties(provisioningState, description, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(TopLevelTrackedResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + TopLevelTrackedResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TopLevelTrackedResourceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTopLevelTrackedResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TopLevelTrackedResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceProperties.cs new file mode 100644 index 000000000000..4a3eb4e7ce98 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/Models/TopLevelTrackedResourceProperties.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Top Level Arm Resource Properties. + public partial class TopLevelTrackedResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TopLevelTrackedResourceProperties() + { + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// The description of the resource. + /// Keeps track of any properties unknown to the library. + internal TopLevelTrackedResourceProperties(ProvisioningState? provisioningState, string description, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + Description = description; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// The description of the resource. + public string Description { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResource.Serialization.cs new file mode 100644 index 000000000000..aaaba9a58ada --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Resources +{ + /// + public partial class NestedProxyResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new NestedProxyResourceData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + NestedProxyResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerResourcesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + NestedProxyResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerResourcesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResource.cs new file mode 100644 index 000000000000..a44f4426716a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResource.cs @@ -0,0 +1,406 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + /// A class representing a NestedProxyResource along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetNestedProxyResources method. + /// + public partial class NestedProxyResource : ArmResource + { + private readonly ClientDiagnostics _nestedClientDiagnostics; + private readonly Nested _nestedRestClient; + private readonly NestedProxyResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Azure.ResourceManager.Resources/topLevelTrackedResources/nestedProxyResources"; + + /// Initializes a new instance of NestedProxyResource for mocking. + protected NestedProxyResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NestedProxyResource(ArmClient client, NestedProxyResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal NestedProxyResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string nestedProxyResourceApiVersion); + _nestedClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", ResourceType.Namespace, Diagnostics); + _nestedRestClient = new Nested(_nestedClientDiagnostics, Pipeline, Endpoint, nestedProxyResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual NestedProxyResourceData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The topLevelTrackedResourceName. + /// The nextedProxyResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, string nextedProxyResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(NestedProxyResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new NestedProxyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(NestedProxyResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new NestedProxyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, NestedProxyResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, NestedProxyResourceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ResourcesArmOperation operation = new ResourcesArmOperation( + new NestedProxyResourceOperationSource(Client), + _nestedClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, NestedProxyResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, NestedProxyResourceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ResourcesArmOperation operation = new ResourcesArmOperation( + new NestedProxyResourceOperationSource(Client), + _nestedClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ResourcesArmOperation operation = new ResourcesArmOperation(_nestedClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + ResourcesArmOperation operation = new ResourcesArmOperation(_nestedClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResourceCollection.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResourceCollection.cs new file mode 100644 index 000000000000..e6cbbf3f293a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResourceCollection.cs @@ -0,0 +1,579 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetNestedProxyResources method from an instance of . + /// + public partial class NestedProxyResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _nestedClientDiagnostics; + private readonly Nested _nestedRestClient; + + /// Initializes a new instance of NestedProxyResourceCollection for mocking. + protected NestedProxyResourceCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal NestedProxyResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(NestedProxyResource.ResourceType, out string nestedProxyResourceApiVersion); + _nestedClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", NestedProxyResource.ResourceType.Namespace, Diagnostics); + _nestedRestClient = new Nested(_nestedClientDiagnostics, Pipeline, Endpoint, nestedProxyResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != TopLevelTrackedResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, TopLevelTrackedResource.ResourceType), id); + } + } + + /// + /// Create a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_CreateOrReplace. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of the nested resource. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string nextedProxyResourceName, NestedProxyResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateCreateOrReplaceRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nextedProxyResourceName, NestedProxyResourceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ResourcesArmOperation operation = new ResourcesArmOperation( + new NestedProxyResourceOperationSource(Client), + _nestedClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_CreateOrReplace. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of the nested resource. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string nextedProxyResourceName, NestedProxyResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateCreateOrReplaceRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nextedProxyResourceName, NestedProxyResourceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ResourcesArmOperation operation = new ResourcesArmOperation( + new NestedProxyResourceOperationSource(Client), + _nestedClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// Name of the nested resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string nextedProxyResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nextedProxyResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(NestedProxyResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new NestedProxyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// Name of the nested resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string nextedProxyResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nextedProxyResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(NestedProxyResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new NestedProxyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List NestedProxyResource resources by TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources. + /// + /// + /// Operation Id. + /// Nested_ListByTopLevelTrackedResource. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new NestedGetByTopLevelTrackedResourceAsyncCollectionResultOfT(_nestedRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new NestedProxyResource(Client, data)); + } + + /// + /// List NestedProxyResource resources by TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources. + /// + /// + /// Operation Id. + /// Nested_ListByTopLevelTrackedResource. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new NestedGetByTopLevelTrackedResourceCollectionResultOfT(_nestedRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new NestedProxyResource(Client, data)); + } + + /// + /// Get a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// Name of the nested resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string nextedProxyResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nextedProxyResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(NestedProxyResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((NestedProxyResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// Name of the nested resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string nextedProxyResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nextedProxyResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(NestedProxyResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((NestedProxyResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// Name of the nested resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string nextedProxyResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nextedProxyResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(NestedProxyResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((NestedProxyResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new NestedProxyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a NestedProxyResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}. + /// + /// + /// Operation Id. + /// Nested_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// Name of the nested resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string nextedProxyResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + + using DiagnosticScope scope = _nestedClientDiagnostics.CreateScope("NestedProxyResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nestedRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nextedProxyResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(NestedProxyResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((NestedProxyResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new NestedProxyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.Serialization.cs new file mode 100644 index 000000000000..322911a49cf1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.Serialization.cs @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Nested child of Top Level Tracked Resource. + public partial class NestedProxyResourceData : ResourceData, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NestedProxyResourceData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + NestedProxyResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (NestedProxyResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NestedProxyResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNestedProxyResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NestedProxyResourceData DeserializeNestedProxyResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + NestedProxyResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerResourcesContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = NestedProxyResourceProperties.DeserializeNestedProxyResourceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new NestedProxyResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(NestedProxyResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + NestedProxyResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (NestedProxyResourceData)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeNestedProxyResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NestedProxyResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(NestedProxyResourceData nestedProxyResourceData) + { + if (nestedProxyResourceData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(nestedProxyResourceData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static NestedProxyResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNestedProxyResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.cs new file mode 100644 index 000000000000..67ddd610c952 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Nested child of Top Level Tracked Resource. + public partial class NestedProxyResourceData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public NestedProxyResourceData() + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// The resource-specific properties for this resource. + internal NestedProxyResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, NestedProxyResourceProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public NestedProxyResourceProperties Properties { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ProviderConstants.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..ed6ad51f8f1a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/ProviderConstants.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Resources +{ + internal static partial class ProviderConstants + { + /// Gets the DefaultProviderNamespace. + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/ExtensionsResourcesRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/ExtensionsResourcesRestOperations.cs new file mode 100644 index 000000000000..edacdd283044 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/ExtensionsResourcesRestOperations.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Resources +{ + internal partial class ExtensionsResources + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ExtensionsResources for mocking. + protected ExtensionsResources() + { + } + + /// Initializes a new instance of ExtensionsResources. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal ExtensionsResources(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(string resourceUri, string extensionsResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/extensionsResources/", false); + uri.AppendPath(extensionsResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceUri, string extensionsResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/extensionsResources/", false); + uri.AppendPath(extensionsResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(string resourceUri, string extensionsResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/extensionsResources/", false); + uri.AppendPath(extensionsResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(string resourceUri, string extensionsResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/extensionsResources/", false); + uri.AppendPath(extensionsResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetByScopeRequest(string resourceUri, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/extensionsResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByScopeRequest(Uri nextPage, string resourceUri, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/LocationResourcesRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/LocationResourcesRestOperations.cs new file mode 100644 index 000000000000..a6f455ef149b --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/LocationResourcesRestOperations.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Resources +{ + internal partial class LocationResources + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of LocationResources for mocking. + protected LocationResources() + { + } + + /// Initializes a new instance of LocationResources. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal LocationResources(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, AzureLocation location, string locationResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/locations/", false); + uri.AppendPath(location.ToString(), true); + uri.AppendPath("/locationResources/", false); + uri.AppendPath(locationResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, AzureLocation location, string locationResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/locations/", false); + uri.AppendPath(location.ToString(), true); + uri.AppendPath("/locationResources/", false); + uri.AppendPath(locationResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, AzureLocation location, string locationResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/locations/", false); + uri.AppendPath(location.ToString(), true); + uri.AppendPath("/locationResources/", false); + uri.AppendPath(locationResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, AzureLocation location, string locationResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/locations/", false); + uri.AppendPath(location.ToString(), true); + uri.AppendPath("/locationResources/", false); + uri.AppendPath(locationResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetByLocationRequest(Guid subscriptionId, AzureLocation location, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/locations/", false); + uri.AppendPath(location.ToString(), true); + uri.AppendPath("/locationResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByLocationRequest(Uri nextPage, Guid subscriptionId, AzureLocation location, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/NestedRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/NestedRestOperations.cs new file mode 100644 index 000000000000..bf6f86bb4fb9 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/NestedRestOperations.cs @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Resources +{ + internal partial class Nested + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Nested for mocking. + protected Nested() + { + } + + /// Initializes a new instance of Nested. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Nested(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, string nextedProxyResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendPath("/nestedProxyResources/", false); + uri.AppendPath(nextedProxyResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrReplaceRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, string nextedProxyResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendPath("/nestedProxyResources/", false); + uri.AppendPath(nextedProxyResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, string nextedProxyResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendPath("/nestedProxyResources/", false); + uri.AppendPath(nextedProxyResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, string nextedProxyResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendPath("/nestedProxyResources/", false); + uri.AppendPath(nextedProxyResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetByTopLevelTrackedResourceRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendPath("/nestedProxyResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByTopLevelTrackedResourceRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/SingletonRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/SingletonRestOperations.cs new file mode 100644 index 000000000000..b5f92a2f3183 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/SingletonRestOperations.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Resources +{ + internal partial class Singleton + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Singleton for mocking. + protected Singleton() + { + } + + /// Initializes a new instance of Singleton. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Singleton(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetByResourceGroupRequest(Guid subscriptionId, string resourceGroupName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string resourceGroupName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetByResourceGroupRequest(Guid subscriptionId, string resourceGroupName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/singletonTrackedResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/TopLevelRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/TopLevelRestOperations.cs new file mode 100644 index 000000000000..19e08b6d3d3a --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/RestOperations/TopLevelRestOperations.cs @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Resources +{ + internal partial class TopLevel + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of TopLevel for mocking. + protected TopLevel() + { + } + + /// Initializes a new instance of TopLevel. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal TopLevel(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrReplaceRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetByResourceGroupRequest(Guid subscriptionId, string resourceGroupName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetBySubscriptionRequest(Guid subscriptionId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetBySubscriptionRequest(Uri nextPage, Guid subscriptionId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateActionSyncRequest(Guid subscriptionId, string resourceGroupName, string topLevelTrackedResourceName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/", false); + uri.AppendPath(topLevelTrackedResourceName, true); + uri.AppendPath("/actionSync", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Content = content; + return message; + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResource.Serialization.cs new file mode 100644 index 000000000000..cfd7e50e9f68 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Resources +{ + /// + public partial class SingletonTrackedResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new SingletonTrackedResourceData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + SingletonTrackedResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerResourcesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + SingletonTrackedResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerResourcesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResource.cs new file mode 100644 index 000000000000..ec948acbc63d --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResource.cs @@ -0,0 +1,410 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + /// A class representing a SingletonTrackedResource along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetSingletonTrackedResource method. + /// + public partial class SingletonTrackedResource : ArmResource + { + private readonly ClientDiagnostics _singletonClientDiagnostics; + private readonly Singleton _singletonRestClient; + private readonly SingletonTrackedResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Azure.ResourceManager.Resources/singletonTrackedResources"; + + /// Initializes a new instance of SingletonTrackedResource for mocking. + protected SingletonTrackedResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal SingletonTrackedResource(ArmClient client, SingletonTrackedResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal SingletonTrackedResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string singletonTrackedResourceApiVersion); + _singletonClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", ResourceType.Namespace, Diagnostics); + _singletonRestClient = new Singleton(_singletonClientDiagnostics, Pipeline, Endpoint, singletonTrackedResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual SingletonTrackedResourceData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get a SingletonTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default. + /// + /// + /// Operation Id. + /// Singleton_GetByResourceGroup. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _singletonClientDiagnostics.CreateScope("SingletonTrackedResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _singletonRestClient.CreateGetByResourceGroupRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SingletonTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SingletonTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a SingletonTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default. + /// + /// + /// Operation Id. + /// Singleton_GetByResourceGroup. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _singletonClientDiagnostics.CreateScope("SingletonTrackedResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _singletonRestClient.CreateGetByResourceGroupRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SingletonTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SingletonTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a SingletonTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default. + /// + /// + /// Operation Id. + /// Singleton_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, SingletonTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _singletonClientDiagnostics.CreateScope("SingletonTrackedResource.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _singletonRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, SingletonTrackedResourceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ResourcesArmOperation operation = new ResourcesArmOperation( + new SingletonTrackedResourceOperationSource(Client), + _singletonClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a SingletonTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default. + /// + /// + /// Operation Id. + /// Singleton_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, SingletonTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _singletonClientDiagnostics.CreateScope("SingletonTrackedResource.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _singletonRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, SingletonTrackedResourceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ResourcesArmOperation operation = new ResourcesArmOperation( + new SingletonTrackedResourceOperationSource(Client), + _singletonClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a SingletonTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default. + /// + /// + /// Operation Id. + /// Singleton_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(SingletonTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _singletonClientDiagnostics.CreateScope("SingletonTrackedResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _singletonRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, SingletonTrackedResourceData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SingletonTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SingletonTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a SingletonTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default. + /// + /// + /// Operation Id. + /// Singleton_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(SingletonTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _singletonClientDiagnostics.CreateScope("SingletonTrackedResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _singletonRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, SingletonTrackedResourceData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SingletonTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SingletonTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.Serialization.cs new file mode 100644 index 000000000000..f18a7cec645e --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.Serialization.cs @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class SingletonTrackedResourceData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SingletonTrackedResourceData() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SingletonTrackedResourceData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SingletonTrackedResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SingletonTrackedResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SingletonTrackedResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSingletonTrackedResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SingletonTrackedResourceData DeserializeSingletonTrackedResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + SingletonTrackedResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerResourcesContext.Default); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = SingletonTrackedResourceProperties.DeserializeSingletonTrackedResourceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SingletonTrackedResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(SingletonTrackedResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SingletonTrackedResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SingletonTrackedResourceData)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSingletonTrackedResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SingletonTrackedResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(SingletonTrackedResourceData singletonTrackedResourceData) + { + if (singletonTrackedResourceData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(singletonTrackedResourceData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static SingletonTrackedResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSingletonTrackedResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.cs new file mode 100644 index 000000000000..730133cdcee6 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class SingletonTrackedResourceData : TrackedResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The geo-location where the resource lives. + public SingletonTrackedResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + internal SingletonTrackedResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, SingletonTrackedResourceProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public SingletonTrackedResourceProperties Properties { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResource.Serialization.cs new file mode 100644 index 000000000000..32dc44c989e1 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Resources +{ + /// + public partial class TopLevelTrackedResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TopLevelTrackedResourceData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + TopLevelTrackedResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerResourcesContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + TopLevelTrackedResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerResourcesContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResource.cs new file mode 100644 index 000000000000..cf91b82cf130 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResource.cs @@ -0,0 +1,808 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// + /// A class representing a TopLevelTrackedResource along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetTopLevelTrackedResources method. + /// + public partial class TopLevelTrackedResource : ArmResource + { + private readonly ClientDiagnostics _topLevelClientDiagnostics; + private readonly TopLevel _topLevelRestClient; + private readonly TopLevelTrackedResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Azure.ResourceManager.Resources/topLevelTrackedResources"; + + /// Initializes a new instance of TopLevelTrackedResource for mocking. + protected TopLevelTrackedResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal TopLevelTrackedResource(ArmClient client, TopLevelTrackedResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal TopLevelTrackedResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string topLevelTrackedResourceApiVersion); + _topLevelClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", ResourceType.Namespace, Diagnostics); + _topLevelRestClient = new TopLevel(_topLevelClientDiagnostics, Pipeline, Endpoint, topLevelTrackedResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual TopLevelTrackedResourceData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The topLevelTrackedResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string topLevelTrackedResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, TopLevelTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, TopLevelTrackedResourceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ResourcesArmOperation operation = new ResourcesArmOperation( + new TopLevelTrackedResourceOperationSource(Client), + _topLevelClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Update. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, TopLevelTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, TopLevelTrackedResourceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ResourcesArmOperation operation = new ResourcesArmOperation( + new TopLevelTrackedResourceOperationSource(Client), + _topLevelClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ResourcesArmOperation operation = new ResourcesArmOperation(_topLevelClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Delete. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + ResourcesArmOperation operation = new ResourcesArmOperation(_topLevelClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// A synchronous resource action that returns no content. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/actionSync. + /// + /// + /// Operation Id. + /// TopLevel_ActionSync. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task ActionSyncAsync(NotificationDetails details, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(details, nameof(details)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.ActionSync"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateActionSyncRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, NotificationDetails.ToRequestContent(details), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// A synchronous resource action that returns no content. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/actionSync. + /// + /// + /// Operation Id. + /// TopLevel_ActionSync. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual Response ActionSync(NotificationDetails details, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(details, nameof(details)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.ActionSync"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateActionSyncRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, NotificationDetails.ToRequestContent(details), context); + Response response = Pipeline.ProcessMessage(message, context); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TopLevelTrackedResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TopLevelTrackedResourceData patch = new TopLevelTrackedResourceData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Add a tag to the current resource. + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TopLevelTrackedResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + TopLevelTrackedResourceData patch = new TopLevelTrackedResourceData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TopLevelTrackedResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TopLevelTrackedResourceData patch = new TopLevelTrackedResourceData(); + patch.Tags.ReplaceWith(tags); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TopLevelTrackedResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + TopLevelTrackedResourceData patch = new TopLevelTrackedResourceData(); + patch.Tags.ReplaceWith(tags); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) + { + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TopLevelTrackedResourceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TopLevelTrackedResourceData patch = new TopLevelTrackedResourceData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Removes a tag by key from the resource. + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken)) + { + Response originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + else + { + TopLevelTrackedResourceData current = Get(cancellationToken: cancellationToken).Value.Data; + TopLevelTrackedResourceData patch = new TopLevelTrackedResourceData(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a collection of NestedProxyResources in the . + /// An object representing collection of NestedProxyResources and their operations over a NestedProxyResource. + public virtual NestedProxyResourceCollection GetNestedProxyResources() + { + return GetCachedClient(client => new NestedProxyResourceCollection(client, Id)); + } + + /// Get a NestedProxyResource. + /// Name of the nested resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNestedProxyResourceAsync(string nextedProxyResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + + return await GetNestedProxyResources().GetAsync(nextedProxyResourceName, cancellationToken).ConfigureAwait(false); + } + + /// Get a NestedProxyResource. + /// Name of the nested resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNestedProxyResource(string nextedProxyResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nextedProxyResourceName, nameof(nextedProxyResourceName)); + + return GetNestedProxyResources().Get(nextedProxyResourceName, cancellationToken); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceCollection.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceCollection.cs new file mode 100644 index 000000000000..d3e12269c070 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceCollection.cs @@ -0,0 +1,579 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Resources +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetTopLevelTrackedResources method from an instance of . + /// + public partial class TopLevelTrackedResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _topLevelClientDiagnostics; + private readonly TopLevel _topLevelRestClient; + + /// Initializes a new instance of TopLevelTrackedResourceCollection for mocking. + protected TopLevelTrackedResourceCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal TopLevelTrackedResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(TopLevelTrackedResource.ResourceType, out string topLevelTrackedResourceApiVersion); + _topLevelClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", TopLevelTrackedResource.ResourceType.Namespace, Diagnostics); + _topLevelRestClient = new TopLevel(_topLevelClientDiagnostics, Pipeline, Endpoint, topLevelTrackedResourceApiVersion ?? "2023-12-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Create a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_CreateOrReplace. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// arm resource name for path. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string topLevelTrackedResourceName, TopLevelTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateCreateOrReplaceRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, topLevelTrackedResourceName, TopLevelTrackedResourceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ResourcesArmOperation operation = new ResourcesArmOperation( + new TopLevelTrackedResourceOperationSource(Client), + _topLevelClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_CreateOrReplace. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// arm resource name for path. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string topLevelTrackedResourceName, TopLevelTrackedResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateCreateOrReplaceRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, topLevelTrackedResourceName, TopLevelTrackedResourceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ResourcesArmOperation operation = new ResourcesArmOperation( + new TopLevelTrackedResourceOperationSource(Client), + _topLevelClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, topLevelTrackedResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, topLevelTrackedResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List TopLevelTrackedResource resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources. + /// + /// + /// Operation Id. + /// TopLevel_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new TopLevelGetByResourceGroupAsyncCollectionResultOfT(_topLevelRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new TopLevelTrackedResource(Client, data)); + } + + /// + /// List TopLevelTrackedResource resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources. + /// + /// + /// Operation Id. + /// TopLevel_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new TopLevelGetByResourceGroupCollectionResultOfT(_topLevelRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new TopLevelTrackedResource(Client, data)); + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, topLevelTrackedResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TopLevelTrackedResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, topLevelTrackedResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TopLevelTrackedResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, topLevelTrackedResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TopLevelTrackedResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TopLevelTrackedResource + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}. + /// + /// + /// Operation Id. + /// TopLevel_Get. + /// + /// + /// Default Api Version. + /// 2023-12-01-preview. + /// + /// + /// + /// arm resource name for path. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string topLevelTrackedResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(topLevelTrackedResourceName, nameof(topLevelTrackedResourceName)); + + using DiagnosticScope scope = _topLevelClientDiagnostics.CreateScope("TopLevelTrackedResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _topLevelRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, topLevelTrackedResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TopLevelTrackedResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TopLevelTrackedResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TopLevelTrackedResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.Serialization.cs new file mode 100644 index 000000000000..1d6a85cd01f2 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.Serialization.cs @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class TopLevelTrackedResourceData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TopLevelTrackedResourceData() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TopLevelTrackedResourceData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TopLevelTrackedResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TopLevelTrackedResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TopLevelTrackedResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTopLevelTrackedResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TopLevelTrackedResourceData DeserializeTopLevelTrackedResourceData(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType resourceType = default; + SystemData systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + TopLevelTrackedResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerResourcesContext.Default); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = TopLevelTrackedResourceProperties.DeserializeTopLevelTrackedResourceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TopLevelTrackedResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerResourcesContext.Default); + default: + throw new FormatException($"The model {nameof(TopLevelTrackedResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + TopLevelTrackedResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TopLevelTrackedResourceData)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTopLevelTrackedResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TopLevelTrackedResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TopLevelTrackedResourceData topLevelTrackedResourceData) + { + if (topLevelTrackedResourceData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(topLevelTrackedResourceData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static TopLevelTrackedResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTopLevelTrackedResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.cs new file mode 100644 index 000000000000..73d7986ec1df --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class TopLevelTrackedResourceData : TrackedResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The geo-location where the resource lives. + public TopLevelTrackedResourceData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + internal TopLevelTrackedResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, TopLevelTrackedResourceProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public TopLevelTrackedResourceProperties Properties { get; set; } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/tspCodeModel.json b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/tspCodeModel.json new file mode 100644 index 000000000000..e11a93fa0c87 --- /dev/null +++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/resources/tspCodeModel.json @@ -0,0 +1,11051 @@ +{ + "name": "Azure.ResourceManager.Resources", + "apiVersions": [ + "2023-12-01-preview" + ], + "enums": [ + { + "$id": "1", + "kind": "enum", + "name": "ProvisioningState", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ProvisioningState", + "valueType": { + "$id": "2", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "3", + "kind": "enumvalue", + "name": "Succeeded", + "value": "Succeeded", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Resource has been created.", + "decorators": [] + }, + { + "$id": "4", + "kind": "enumvalue", + "name": "Failed", + "value": "Failed", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Resource creation failed.", + "decorators": [] + }, + { + "$id": "5", + "kind": "enumvalue", + "name": "Canceled", + "value": "Canceled", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "doc": "Resource creation was canceled.", + "decorators": [] + }, + { + "$id": "6", + "kind": "enumvalue", + "name": "Provisioning", + "value": "Provisioning", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "decorators": [] + }, + { + "$id": "7", + "kind": "enumvalue", + "name": "Updating", + "value": "Updating", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "decorators": [] + }, + { + "$id": "8", + "kind": "enumvalue", + "name": "Deleting", + "value": "Deleting", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "decorators": [] + }, + { + "$id": "9", + "kind": "enumvalue", + "name": "Accepted", + "value": "Accepted", + "valueType": { + "$ref": "2" + }, + "enumType": { + "$ref": "1" + }, + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.Resources", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json,LroInitial,LroFinalEnvelope", + "decorators": [] + }, + { + "$id": "10", + "kind": "enum", + "name": "createdByType", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.createdByType", + "valueType": { + "$id": "11", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "12", + "kind": "enumvalue", + "name": "User", + "value": "User", + "valueType": { + "$ref": "11" + }, + "enumType": { + "$ref": "10" + }, + "doc": "The entity was created by a user.", + "decorators": [] + }, + { + "$id": "13", + "kind": "enumvalue", + "name": "Application", + "value": "Application", + "valueType": { + "$ref": "11" + }, + "enumType": { + "$ref": "10" + }, + "doc": "The entity was created by an application.", + "decorators": [] + }, + { + "$id": "14", + "kind": "enumvalue", + "name": "ManagedIdentity", + "value": "ManagedIdentity", + "valueType": { + "$ref": "11" + }, + "enumType": { + "$ref": "10" + }, + "doc": "The entity was created by a managed identity.", + "decorators": [] + }, + { + "$id": "15", + "kind": "enumvalue", + "name": "Key", + "value": "Key", + "valueType": { + "$ref": "11" + }, + "enumType": { + "$ref": "10" + }, + "doc": "The entity was created by a key.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "The kind of entity that created the resource.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json,LroInitial,LroFinalEnvelope", + "decorators": [] + }, + { + "$id": "16", + "kind": "enum", + "name": "ResourceProvisioningState", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceProvisioningState", + "valueType": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "18", + "kind": "enumvalue", + "name": "Succeeded", + "value": "Succeeded", + "valueType": { + "$ref": "17" + }, + "enumType": { + "$ref": "16" + }, + "doc": "Resource has been created.", + "decorators": [] + }, + { + "$id": "19", + "kind": "enumvalue", + "name": "Failed", + "value": "Failed", + "valueType": { + "$ref": "17" + }, + "enumType": { + "$ref": "16" + }, + "doc": "Resource creation failed.", + "decorators": [] + }, + { + "$id": "20", + "kind": "enumvalue", + "name": "Canceled", + "value": "Canceled", + "valueType": { + "$ref": "17" + }, + "enumType": { + "$ref": "16" + }, + "doc": "Resource creation was canceled.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager", + "doc": "The provisioning state of a resource type.", + "isFixed": false, + "isFlags": false, + "usage": "LroPolling", + "decorators": [] + }, + { + "$id": "21", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Versions", + "valueType": { + "$id": "22", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "23", + "kind": "enumvalue", + "name": "v2023_12_01_preview", + "value": "2023-12-01-preview", + "valueType": { + "$ref": "22" + }, + "enumType": { + "$ref": "21" + }, + "doc": "Preview API version 2023-12-01-preview.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.Resources", + "doc": "Azure API versions.", + "isFixed": true, + "isFlags": false, + "usage": "ApiVersionEnum", + "decorators": [] + } + ], + "constants": [ + { + "$id": "24", + "kind": "constant", + "name": "getContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "25", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "26", + "kind": "constant", + "name": "createOrReplaceContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "27", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "28", + "kind": "constant", + "name": "createOrReplaceContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "29", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "30", + "kind": "constant", + "name": "createOrReplaceContentType2", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "31", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "32", + "kind": "constant", + "name": "createOrReplaceContentType3", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "33", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "34", + "kind": "constant", + "name": "updateContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "35", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "36", + "kind": "constant", + "name": "updateContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "37", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "38", + "kind": "constant", + "name": "updateContentType2", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "39", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "40", + "kind": "constant", + "name": "updateContentType3", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "41", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "42", + "kind": "constant", + "name": "listByResourceGroupContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "43", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "44", + "kind": "constant", + "name": "listBySubscriptionContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "45", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "46", + "kind": "constant", + "name": "actionSyncContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "47", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "48", + "kind": "constant", + "name": "getContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "49", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "50", + "kind": "constant", + "name": "createOrReplaceContentType4", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "51", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "52", + "kind": "constant", + "name": "createOrReplaceContentType5", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "53", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "54", + "kind": "constant", + "name": "createOrReplaceContentType6", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "55", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "56", + "kind": "constant", + "name": "createOrReplaceContentType7", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "57", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "58", + "kind": "constant", + "name": "updateContentType4", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "59", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "60", + "kind": "constant", + "name": "updateContentType5", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "61", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "62", + "kind": "constant", + "name": "updateContentType6", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "63", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "64", + "kind": "constant", + "name": "updateContentType7", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "65", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "66", + "kind": "constant", + "name": "listByTopLevelTrackedResourceContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "67", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "68", + "kind": "constant", + "name": "getByResourceGroupContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "69", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "70", + "kind": "constant", + "name": "createOrUpdateContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "71", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "72", + "kind": "constant", + "name": "createOrUpdateContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "73", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "74", + "kind": "constant", + "name": "createOrUpdateContentType2", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "75", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "76", + "kind": "constant", + "name": "createOrUpdateContentType3", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "77", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "78", + "kind": "constant", + "name": "updateContentType8", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "79", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "80", + "kind": "constant", + "name": "updateContentType9", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "81", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "82", + "kind": "constant", + "name": "listByResourceGroupContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "83", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "84", + "kind": "constant", + "name": "getContentType2", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "85", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "86", + "kind": "constant", + "name": "createOrUpdateContentType4", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "87", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "88", + "kind": "constant", + "name": "createOrUpdateContentType5", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "89", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "90", + "kind": "constant", + "name": "createOrUpdateContentType6", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "91", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "92", + "kind": "constant", + "name": "createOrUpdateContentType7", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "93", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "94", + "kind": "constant", + "name": "updateContentType10", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "95", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "96", + "kind": "constant", + "name": "updateContentType11", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "97", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "98", + "kind": "constant", + "name": "listByScopeContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "99", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "100", + "kind": "constant", + "name": "getContentType3", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "101", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "102", + "kind": "constant", + "name": "createOrUpdateContentType8", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "103", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "104", + "kind": "constant", + "name": "createOrUpdateContentType9", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "105", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "106", + "kind": "constant", + "name": "updateContentType12", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "107", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "108", + "kind": "constant", + "name": "updateContentType13", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "109", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "110", + "kind": "constant", + "name": "listByLocationContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "111", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + } + ], + "models": [ + { + "$id": "112", + "kind": "model", + "name": "TopLevelTrackedResource", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevelTrackedResource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.Private.@armResourceInternal", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@resourceSchema", + "arguments": { + "resourceIdPattern": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "resourceType": "Azure.ResourceManager.Resources/topLevelTrackedResources", + "methods": [ + { + "$id": "113", + "methodId": "Azure.ResourceManager.Resources.TopLevel.get", + "kind": "Get", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" + }, + { + "$id": "114", + "methodId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace", + "kind": "Create", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" + }, + { + "$id": "115", + "methodId": "Azure.ResourceManager.Resources.TopLevel.update", + "kind": "Update", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" + }, + { + "$id": "116", + "methodId": "Azure.ResourceManager.Resources.TopLevel.delete", + "kind": "Delete", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" + }, + { + "$id": "117", + "methodId": "Azure.ResourceManager.Resources.TopLevel.listByResourceGroup", + "kind": "List", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources", + "operationScope": "ResourceGroup" + }, + { + "$id": "118", + "methodId": "Azure.ResourceManager.Resources.TopLevel.listBySubscription", + "kind": "List", + "operationPath": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources", + "operationScope": "Subscription" + }, + { + "$id": "119", + "methodId": "Azure.ResourceManager.Resources.TopLevel.actionSync", + "kind": "Action", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/actionSync", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" + } + ], + "resourceScope": "ResourceGroup", + "resourceName": "TopLevelTrackedResource" + } + } + ], + "baseModel": { + "$id": "120", + "kind": "model", + "name": "TrackedResource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'", + "summary": "Tracked Resource", + "decorators": [], + "baseModel": { + "$id": "121", + "kind": "model", + "name": "Resource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Common fields that are returned in the response for all Azure Resource Manager resources", + "summary": "Resource", + "decorators": [], + "properties": [ + { + "$id": "122", + "kind": "property", + "name": "id", + "serializedName": "id", + "doc": "Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}", + "type": { + "$id": "123", + "kind": "string", + "name": "armResourceIdentifier", + "crossLanguageDefinitionId": "Azure.Core.armResourceIdentifier", + "baseType": { + "$id": "124", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.id", + "serializationOptions": { + "json": { + "name": "id" + } + }, + "isHttpMetadata": false + }, + { + "$id": "125", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the resource", + "type": { + "$id": "126", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "127", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or \"Microsoft.Storage/storageAccounts\"", + "type": { + "$id": "128", + "kind": "string", + "name": "armResourceType", + "crossLanguageDefinitionId": "Azure.Core.armResourceType", + "baseType": { + "$id": "129", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + }, + { + "$id": "130", + "kind": "property", + "name": "systemData", + "serializedName": "systemData", + "doc": "Azure Resource Manager metadata containing createdBy and modifiedBy information.", + "type": { + "$id": "131", + "kind": "model", + "name": "SystemData", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData", + "usage": "Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Metadata pertaining to creation and last modification of the resource.", + "decorators": [], + "properties": [ + { + "$id": "132", + "kind": "property", + "name": "createdBy", + "serializedName": "createdBy", + "doc": "The identity that created the resource.", + "type": { + "$id": "133", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdBy", + "serializationOptions": { + "json": { + "name": "createdBy" + } + }, + "isHttpMetadata": false + }, + { + "$id": "134", + "kind": "property", + "name": "createdByType", + "serializedName": "createdByType", + "doc": "The type of identity that created the resource.", + "type": { + "$ref": "10" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdByType", + "serializationOptions": { + "json": { + "name": "createdByType" + } + }, + "isHttpMetadata": false + }, + { + "$id": "135", + "kind": "property", + "name": "createdAt", + "serializedName": "createdAt", + "doc": "The timestamp of resource creation (UTC).", + "type": { + "$id": "136", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "137", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdAt", + "serializationOptions": { + "json": { + "name": "createdAt" + } + }, + "isHttpMetadata": false + }, + { + "$id": "138", + "kind": "property", + "name": "lastModifiedBy", + "serializedName": "lastModifiedBy", + "doc": "The identity that last modified the resource.", + "type": { + "$id": "139", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedBy", + "serializationOptions": { + "json": { + "name": "lastModifiedBy" + } + }, + "isHttpMetadata": false + }, + { + "$id": "140", + "kind": "property", + "name": "lastModifiedByType", + "serializedName": "lastModifiedByType", + "doc": "The type of identity that last modified the resource.", + "type": { + "$ref": "10" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedByType", + "serializationOptions": { + "json": { + "name": "lastModifiedByType" + } + }, + "isHttpMetadata": false + }, + { + "$id": "141", + "kind": "property", + "name": "lastModifiedAt", + "serializedName": "lastModifiedAt", + "doc": "The timestamp of resource last modification (UTC)", + "type": { + "$id": "142", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "143", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedAt", + "serializationOptions": { + "json": { + "name": "lastModifiedAt" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.systemData", + "serializationOptions": { + "json": { + "name": "systemData" + } + }, + "isHttpMetadata": false + } + ] + }, + "properties": [ + { + "$id": "144", + "kind": "property", + "name": "tags", + "serializedName": "tags", + "doc": "Resource tags.", + "type": { + "$id": "145", + "kind": "dict", + "keyType": { + "$id": "146", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "valueType": { + "$id": "147", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource.tags", + "serializationOptions": { + "json": { + "name": "tags" + } + }, + "isHttpMetadata": false + }, + { + "$id": "148", + "kind": "property", + "name": "location", + "serializedName": "location", + "doc": "The geo-location where the resource lives", + "type": { + "$id": "149", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "150", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource.location", + "serializationOptions": { + "json": { + "name": "location" + } + }, + "isHttpMetadata": false + } + ] + }, + "properties": [ + { + "$id": "151", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "152", + "kind": "model", + "name": "TopLevelTrackedResourceProperties", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevelTrackedResourceProperties", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Top Level Arm Resource Properties.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "153", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The status of the last operation.", + "type": { + "$ref": "1" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevelTrackedResourceProperties.provisioningState", + "serializationOptions": { + "json": { + "name": "provisioningState" + } + }, + "isHttpMetadata": false + }, + { + "$id": "154", + "kind": "property", + "name": "description", + "serializedName": "description", + "doc": "The description of the resource.", + "type": { + "$id": "155", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevelTrackedResourceProperties.description", + "serializationOptions": { + "json": { + "name": "description" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevelTrackedResource.properties", + "serializationOptions": { + "json": { + "name": "properties" + } + }, + "isHttpMetadata": false + }, + { + "$id": "156", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "arm resource name for path", + "type": { + "$id": "157", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevelTrackedResource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": true + } + ] + }, + { + "$ref": "152" + }, + { + "$ref": "120" + }, + { + "$ref": "121" + }, + { + "$ref": "131" + }, + { + "$id": "158", + "kind": "model", + "name": "ErrorResponse", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "usage": "Json,Exception", + "doc": "Common error response for all Azure Resource Manager APIs to return error details for failed operations.", + "summary": "Error response", + "decorators": [], + "properties": [ + { + "$id": "159", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "The error object.", + "type": { + "$id": "160", + "kind": "model", + "name": "ErrorDetail", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "usage": "Json,Exception,LroPolling", + "doc": "The error detail.", + "decorators": [], + "properties": [ + { + "$id": "161", + "kind": "property", + "name": "code", + "serializedName": "code", + "doc": "The error code.", + "type": { + "$id": "162", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.code", + "serializationOptions": { + "json": { + "name": "code" + } + }, + "isHttpMetadata": false + }, + { + "$id": "163", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "The error message.", + "type": { + "$id": "164", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.message", + "serializationOptions": { + "json": { + "name": "message" + } + }, + "isHttpMetadata": false + }, + { + "$id": "165", + "kind": "property", + "name": "target", + "serializedName": "target", + "doc": "The error target.", + "type": { + "$id": "166", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.target", + "serializationOptions": { + "json": { + "name": "target" + } + }, + "isHttpMetadata": false + }, + { + "$id": "167", + "kind": "property", + "name": "details", + "serializedName": "details", + "doc": "The error details.", + "type": { + "$id": "168", + "kind": "array", + "name": "ArrayErrorDetail", + "valueType": { + "$ref": "160" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.details", + "serializationOptions": { + "json": { + "name": "details" + } + }, + "isHttpMetadata": false + }, + { + "$id": "169", + "kind": "property", + "name": "additionalInfo", + "serializedName": "additionalInfo", + "doc": "The error additional info.", + "type": { + "$id": "170", + "kind": "array", + "name": "ArrayErrorAdditionalInfo", + "valueType": { + "$id": "171", + "kind": "model", + "name": "ErrorAdditionalInfo", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "usage": "Json,Exception,LroPolling", + "doc": "The resource management error additional info.", + "decorators": [], + "properties": [ + { + "$id": "172", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The additional info type.", + "type": { + "$id": "173", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.type", + "serializationOptions": { + "json": { + "name": "type" + } + }, + "isHttpMetadata": false + }, + { + "$id": "174", + "kind": "property", + "name": "info", + "serializedName": "info", + "doc": "The additional info.", + "type": { + "$id": "175", + "kind": "unknown", + "name": "unknown", + "crossLanguageDefinitionId": "", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info", + "serializationOptions": { + "json": { + "name": "info" + } + }, + "isHttpMetadata": false + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.additionalInfo", + "serializationOptions": { + "json": { + "name": "additionalInfo" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse.error", + "serializationOptions": { + "json": { + "name": "error" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$ref": "160" + }, + { + "$ref": "171" + }, + { + "$id": "176", + "kind": "model", + "name": "ArmOperationStatusResourceProvisioningState", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus", + "usage": "LroPolling", + "doc": "Standard Azure Resource Manager operation status response", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "177", + "kind": "property", + "name": "status", + "serializedName": "status", + "doc": "The operation status", + "type": { + "$ref": "16" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.status", + "serializationOptions": { + "json": { + "name": "status" + } + }, + "isHttpMetadata": false + }, + { + "$id": "178", + "kind": "property", + "name": "id", + "serializedName": "id", + "doc": "The unique identifier for the operationStatus resource", + "type": { + "$id": "179", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.id", + "serializationOptions": { + "json": { + "name": "id" + } + }, + "isHttpMetadata": true + }, + { + "$id": "180", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the operationStatus resource", + "type": { + "$id": "181", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": false + }, + { + "$id": "182", + "kind": "property", + "name": "startTime", + "serializedName": "startTime", + "doc": "Operation start time", + "type": { + "$id": "183", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "184", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.startTime", + "serializationOptions": { + "json": { + "name": "startTime" + } + }, + "isHttpMetadata": false + }, + { + "$id": "185", + "kind": "property", + "name": "endTime", + "serializedName": "endTime", + "doc": "Operation complete time", + "type": { + "$id": "186", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "187", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.endTime", + "serializationOptions": { + "json": { + "name": "endTime" + } + }, + "isHttpMetadata": false + }, + { + "$id": "188", + "kind": "property", + "name": "percentComplete", + "serializedName": "percentComplete", + "doc": "The progress made toward completing the operation", + "type": { + "$id": "189", + "kind": "float64", + "name": "float64", + "crossLanguageDefinitionId": "TypeSpec.float64", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.percentComplete", + "serializationOptions": { + "json": { + "name": "percentComplete" + } + }, + "isHttpMetadata": false + }, + { + "$id": "190", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "Errors that occurred if the operation ended with Canceled or Failed status", + "type": { + "$ref": "160" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.error", + "serializationOptions": { + "json": { + "name": "error" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "191", + "kind": "model", + "name": "TopLevelTrackedResourceListResult", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult", + "usage": "Output,Json", + "doc": "The response of a TopLevelTrackedResource list operation.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "192", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The TopLevelTrackedResource items on this page", + "type": { + "$id": "193", + "kind": "array", + "name": "ArrayTopLevelTrackedResource", + "valueType": { + "$ref": "112" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.value", + "serializationOptions": { + "json": { + "name": "value" + } + }, + "isHttpMetadata": false + }, + { + "$id": "194", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "195", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "196", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.nextLink", + "serializationOptions": { + "json": { + "name": "nextLink" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "197", + "kind": "model", + "name": "NotificationDetails", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.NotificationDetails", + "usage": "Input,Json", + "doc": "The details of a user notification.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "198", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "The notification message.", + "type": { + "$id": "199", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.NotificationDetails.message", + "serializationOptions": { + "json": { + "name": "message" + } + }, + "isHttpMetadata": false + }, + { + "$id": "200", + "kind": "property", + "name": "urgent", + "serializedName": "urgent", + "doc": "If true, the notification is urgent.", + "type": { + "$id": "201", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.NotificationDetails.urgent", + "serializationOptions": { + "json": { + "name": "urgent" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "202", + "kind": "model", + "name": "NestedProxyResource", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.NestedProxyResource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Nested child of Top Level Tracked Resource.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.Private.@armResourceInternal", + "arguments": {} + }, + { + "name": "TypeSpec.Rest.@parentResource", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@resourceSchema", + "arguments": { + "resourceIdPattern": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}", + "resourceType": "Azure.ResourceManager.Resources/topLevelTrackedResources/nestedProxyResources", + "methods": [ + { + "$id": "203", + "methodId": "Azure.ResourceManager.Resources.Nested.get", + "kind": "Get", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" + }, + { + "$id": "204", + "methodId": "Azure.ResourceManager.Resources.Nested.createOrReplace", + "kind": "Create", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" + }, + { + "$id": "205", + "methodId": "Azure.ResourceManager.Resources.Nested.update", + "kind": "Update", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" + }, + { + "$id": "206", + "methodId": "Azure.ResourceManager.Resources.Nested.delete", + "kind": "Delete", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" + }, + { + "$id": "207", + "methodId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource", + "kind": "List", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" + } + ], + "resourceScope": "ResourceGroup", + "parentResourceId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "resourceName": "NestedProxyResource" + } + } + ], + "baseModel": { + "$id": "208", + "kind": "model", + "name": "ProxyResource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ProxyResource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location", + "summary": "Proxy Resource", + "decorators": [], + "baseModel": { + "$ref": "121" + }, + "properties": [] + }, + "properties": [ + { + "$id": "209", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "210", + "kind": "model", + "name": "NestedProxyResourceProperties", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.NestedProxyResourceProperties", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Nested Proxy Resource Properties.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "211", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "Provisioning State of the nested child Resource", + "type": { + "$ref": "1" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.NestedProxyResourceProperties.provisioningState", + "serializationOptions": { + "json": { + "name": "provisioningState" + } + }, + "isHttpMetadata": false + }, + { + "$id": "212", + "kind": "property", + "name": "description", + "serializedName": "description", + "doc": "Nested resource description.", + "type": { + "$id": "213", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.NestedProxyResourceProperties.description", + "serializationOptions": { + "json": { + "name": "description" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.NestedProxyResource.properties", + "serializationOptions": { + "json": { + "name": "properties" + } + }, + "isHttpMetadata": false + }, + { + "$id": "214", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "Name of the nested resource.", + "type": { + "$id": "215", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.NestedProxyResource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": true + } + ] + }, + { + "$ref": "210" + }, + { + "$ref": "208" + }, + { + "$id": "216", + "kind": "model", + "name": "NestedProxyResourceListResult", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult", + "usage": "Output,Json", + "doc": "The response of a NestedProxyResource list operation.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "217", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The NestedProxyResource items on this page", + "type": { + "$id": "218", + "kind": "array", + "name": "ArrayNestedProxyResource", + "valueType": { + "$ref": "202" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.value", + "serializationOptions": { + "json": { + "name": "value" + } + }, + "isHttpMetadata": false + }, + { + "$id": "219", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "220", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "221", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.nextLink", + "serializationOptions": { + "json": { + "name": "nextLink" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "222", + "kind": "model", + "name": "SingletonTrackedResource", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.SingletonTrackedResource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.Private.@armResourceInternal", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.@singleton", + "arguments": { + "keyValue": "default" + } + }, + { + "name": "Azure.ClientGenerator.Core.@resourceSchema", + "arguments": { + "resourceIdPattern": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", + "resourceType": "Azure.ResourceManager.Resources/singletonTrackedResources", + "methods": [ + { + "$id": "223", + "methodId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup", + "kind": "Get", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default" + }, + { + "$id": "224", + "methodId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate", + "kind": "Create", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default" + }, + { + "$id": "225", + "methodId": "Azure.ResourceManager.Resources.Singleton.update", + "kind": "Update", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", + "operationScope": "ResourceGroup", + "resourceScope": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default" + }, + { + "$id": "226", + "methodId": "Azure.ResourceManager.Resources.Singleton.listByResourceGroup", + "kind": "List", + "operationPath": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources", + "operationScope": "ResourceGroup" + } + ], + "resourceScope": "ResourceGroup", + "singletonResourceName": "default", + "resourceName": "SingletonTrackedResource" + } + } + ], + "baseModel": { + "$ref": "120" + }, + "properties": [ + { + "$id": "227", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "228", + "kind": "model", + "name": "SingletonTrackedResourceProperties", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.SingletonTrackedResourceProperties", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Singleton Arm Resource Properties.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "229", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The status of the last operation.", + "type": { + "$ref": "1" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.SingletonTrackedResourceProperties.provisioningState", + "serializationOptions": { + "json": { + "name": "provisioningState" + } + }, + "isHttpMetadata": false + }, + { + "$id": "230", + "kind": "property", + "name": "description", + "serializedName": "description", + "doc": "The description of the resource.", + "type": { + "$id": "231", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.SingletonTrackedResourceProperties.description", + "serializationOptions": { + "json": { + "name": "description" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.SingletonTrackedResource.properties", + "serializationOptions": { + "json": { + "name": "properties" + } + }, + "isHttpMetadata": false + }, + { + "$id": "232", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the SingletonTrackedResource", + "type": { + "$id": "233", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.SingletonTrackedResource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": true + } + ] + }, + { + "$ref": "228" + }, + { + "$id": "234", + "kind": "model", + "name": "SingletonTrackedResourceListResult", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult", + "usage": "Output,Json", + "doc": "The response of a SingletonTrackedResource list operation.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "235", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The SingletonTrackedResource items on this page", + "type": { + "$id": "236", + "kind": "array", + "name": "ArraySingletonTrackedResource", + "valueType": { + "$ref": "222" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.value", + "serializationOptions": { + "json": { + "name": "value" + } + }, + "isHttpMetadata": false + }, + { + "$id": "237", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "238", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "239", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.nextLink", + "serializationOptions": { + "json": { + "name": "nextLink" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "240", + "kind": "model", + "name": "ExtensionsResource", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "Concrete extension resource types can be created by aliasing this type using a specific property type.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.Private.@armResourceInternal", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@resourceSchema", + "arguments": { + "resourceIdPattern": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}", + "resourceType": "Azure.ResourceManager.Resources/extensionsResources", + "methods": [ + { + "$id": "241", + "methodId": "Azure.ResourceManager.Resources.ExtensionsResources.get", + "kind": "Get", + "operationPath": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}", + "operationScope": "Extension", + "resourceScope": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}" + }, + { + "$id": "242", + "methodId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate", + "kind": "Create", + "operationPath": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}", + "operationScope": "Extension", + "resourceScope": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}" + }, + { + "$id": "243", + "methodId": "Azure.ResourceManager.Resources.ExtensionsResources.update", + "kind": "Update", + "operationPath": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}", + "operationScope": "Extension", + "resourceScope": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}" + }, + { + "$id": "244", + "methodId": "Azure.ResourceManager.Resources.ExtensionsResources.delete", + "kind": "Delete", + "operationPath": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}", + "operationScope": "Extension", + "resourceScope": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}" + }, + { + "$id": "245", + "methodId": "Azure.ResourceManager.Resources.ExtensionsResources.listByScope", + "kind": "List", + "operationPath": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources", + "operationScope": "Extension" + } + ], + "resourceScope": "Extension", + "resourceName": "ExtensionsResource" + } + } + ], + "baseModel": { + "$id": "246", + "kind": "model", + "name": "ExtensionResource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ExtensionResource", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "The base extension resource.", + "decorators": [], + "baseModel": { + "$ref": "121" + }, + "properties": [] + }, + "properties": [ + { + "$id": "247", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "248", + "kind": "model", + "name": "ExtensionsResourceProperties", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResourceProperties", + "usage": "Input,Output,Json,LroInitial,LroFinalEnvelope", + "doc": "ExtensionsResource properties", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "249", + "kind": "property", + "name": "description", + "serializedName": "description", + "doc": "The description of the resource.", + "type": { + "$id": "250", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResourceProperties.description", + "serializationOptions": { + "json": { + "name": "description" + } + }, + "isHttpMetadata": false + }, + { + "$id": "251", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The status of the last operation.", + "type": { + "$ref": "1" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResourceProperties.provisioningState", + "serializationOptions": { + "json": { + "name": "provisioningState" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResource.properties", + "serializationOptions": { + "json": { + "name": "properties" + } + }, + "isHttpMetadata": false + }, + { + "$id": "252", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the ExtensionsResource", + "type": { + "$id": "253", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": true + } + ] + }, + { + "$ref": "248" + }, + { + "$ref": "246" + }, + { + "$id": "254", + "kind": "model", + "name": "ExtensionsResourceListResult", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult", + "usage": "Output,Json", + "doc": "The response of a ExtensionsResource list operation.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "255", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The ExtensionsResource items on this page", + "type": { + "$id": "256", + "kind": "array", + "name": "ArrayExtensionsResource", + "valueType": { + "$ref": "240" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.value", + "serializationOptions": { + "json": { + "name": "value" + } + }, + "isHttpMetadata": false + }, + { + "$id": "257", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "258", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "259", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.nextLink", + "serializationOptions": { + "json": { + "name": "nextLink" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "260", + "kind": "model", + "name": "LocationResource", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResource", + "usage": "Input,Output,Json", + "doc": "Concrete proxy resource types can be created by aliasing this type using a specific property type.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ResourceManager.Private.@armResourceInternal", + "arguments": {} + }, + { + "name": "TypeSpec.Rest.@parentResource", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@resourceSchema", + "arguments": { + "resourceIdPattern": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}", + "resourceType": "Azure.ResourceManager.Resources/locations/locationResources", + "methods": [ + { + "$id": "261", + "methodId": "Azure.ResourceManager.Resources.LocationResources.get", + "kind": "Get", + "operationPath": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}", + "operationScope": "Subscription", + "resourceScope": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" + }, + { + "$id": "262", + "methodId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate", + "kind": "Create", + "operationPath": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}", + "operationScope": "Subscription", + "resourceScope": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" + }, + { + "$id": "263", + "methodId": "Azure.ResourceManager.Resources.LocationResources.update", + "kind": "Update", + "operationPath": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}", + "operationScope": "Subscription", + "resourceScope": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" + }, + { + "$id": "264", + "methodId": "Azure.ResourceManager.Resources.LocationResources.delete", + "kind": "Delete", + "operationPath": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}", + "operationScope": "Subscription", + "resourceScope": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" + }, + { + "$id": "265", + "methodId": "Azure.ResourceManager.Resources.LocationResources.listByLocation", + "kind": "List", + "operationPath": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources", + "operationScope": "Subscription" + } + ], + "resourceScope": "Subscription", + "resourceName": "LocationResource" + } + } + ], + "baseModel": { + "$ref": "208" + }, + "properties": [ + { + "$id": "266", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "267", + "kind": "model", + "name": "LocationResourceProperties", + "namespace": "Azure.ResourceManager.Resources", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResourceProperties", + "usage": "Input,Output,Json", + "doc": "Location resource properties", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "268", + "kind": "property", + "name": "description", + "serializedName": "description", + "doc": "The description of the resource.", + "type": { + "$id": "269", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResourceProperties.description", + "serializationOptions": { + "json": { + "name": "description" + } + }, + "isHttpMetadata": false + }, + { + "$id": "270", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The status of the last operation.", + "type": { + "$ref": "1" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResourceProperties.provisioningState", + "serializationOptions": { + "json": { + "name": "provisioningState" + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResource.properties", + "serializationOptions": { + "json": { + "name": "properties" + } + }, + "isHttpMetadata": false + }, + { + "$id": "271", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the LocationResource", + "type": { + "$id": "272", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResource.name", + "serializationOptions": { + "json": { + "name": "name" + } + }, + "isHttpMetadata": true + } + ] + }, + { + "$ref": "267" + }, + { + "$id": "273", + "kind": "model", + "name": "LocationResourceListResult", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult", + "usage": "Output,Json", + "doc": "The response of a LocationResource list operation.", + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + } + ], + "properties": [ + { + "$id": "274", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The LocationResource items on this page", + "type": { + "$id": "275", + "kind": "array", + "name": "ArrayLocationResource", + "valueType": { + "$ref": "260" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.value", + "serializationOptions": { + "json": { + "name": "value" + } + }, + "isHttpMetadata": false + }, + { + "$id": "276", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "277", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "278", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.nextLink", + "serializationOptions": { + "json": { + "name": "nextLink" + } + }, + "isHttpMetadata": false + } + ] + } + ], + "clients": [ + { + "$id": "279", + "kind": "client", + "name": "ResourcesClient", + "namespace": "Azure.ResourceManager.Resources", + "doc": "Arm Resource Provider management API.", + "methods": [], + "parameters": [ + { + "$id": "280", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "281", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "282", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.endpoint" + }, + { + "$id": "283", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "284", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "285", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "286", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "287", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "288", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 1, + "decorators": [ + { + "name": "Azure.ResourceManager.@armProviderNamespace", + "arguments": {} + }, + { + "name": "Azure.ClientGenerator.Core.@nonResourceMethodSchema", + "arguments": { + "nonResourceMethods": [] + } + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources", + "apiVersions": [ + "2023-12-01-preview" + ], + "children": [ + { + "$id": "289", + "kind": "client", + "name": "TopLevel", + "namespace": "Azure.ResourceManager.Resources", + "methods": [ + { + "$id": "290", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Get a TopLevelTrackedResource", + "operation": { + "$id": "291", + "name": "get", + "resourceName": "TopLevelTrackedResource", + "doc": "Get a TopLevelTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "292", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "293", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "294", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.apiVersion", + "readOnly": false + }, + { + "$id": "295", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "296", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "297", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.subscriptionId" + }, + { + "$id": "298", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "299", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.resourceGroupName" + }, + { + "$id": "300", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "301", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.topLevelTrackedResourceName" + }, + { + "$id": "302", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "24" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "112" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceRead", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "303", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "304", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "305", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "306", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "307", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "24" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "112" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.get" + }, + { + "$id": "308", + "kind": "lro", + "name": "createOrReplace", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Create a TopLevelTrackedResource", + "operation": { + "$id": "309", + "name": "createOrReplace", + "resourceName": "TopLevelTrackedResource", + "doc": "Create a TopLevelTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "310", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "311", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "312", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.apiVersion", + "readOnly": false + }, + { + "$id": "313", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "314", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "315", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.subscriptionId" + }, + { + "$id": "316", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "317", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.resourceGroupName" + }, + { + "$id": "318", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "319", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.topLevelTrackedResourceName" + }, + { + "$id": "320", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "26" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.contentType" + }, + { + "$id": "321", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "28" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.accept" + }, + { + "$id": "322", + "kind": "body", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "112" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.resource" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "112" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 201 + ], + "bodyType": { + "$ref": "112" + }, + "headers": [ + { + "name": "azureAsyncOperation", + "nameInResponse": "Azure-AsyncOperation", + "doc": "A link to the status monitor", + "type": { + "$id": "323", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "324", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceCreateOrUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "325", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "326", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "327", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "328", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "329", + "kind": "method", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "112" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.resource", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "330", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "30" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "331", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "32" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "112" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.createOrReplace", + "lroMetadata": { + "finalStateVia": 0, + "finalResponse": { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "112" + } + } + } + }, + { + "$id": "332", + "kind": "lro", + "name": "update", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Update a TopLevelTrackedResource", + "operation": { + "$id": "333", + "name": "update", + "resourceName": "TopLevelTrackedResource", + "doc": "Update a TopLevelTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "334", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "335", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "336", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.apiVersion", + "readOnly": false + }, + { + "$id": "337", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "338", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "339", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.subscriptionId" + }, + { + "$id": "340", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "341", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.resourceGroupName" + }, + { + "$id": "342", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "343", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.topLevelTrackedResourceName" + }, + { + "$id": "344", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "34" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.contentType" + }, + { + "$id": "345", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "36" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.accept" + }, + { + "$id": "346", + "kind": "body", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "112" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.properties" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "112" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 202 + ], + "headers": [ + { + "name": "location", + "nameInResponse": "Location", + "doc": "The Location header contains the URL where the status of the long running operation can be checked.", + "type": { + "$id": "347", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "348", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false + } + ], + "httpMethod": "PATCH", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "349", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "350", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "351", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "352", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "353", + "kind": "method", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "112" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.properties", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "354", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "38" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "355", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "40" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "112" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.update", + "lroMetadata": { + "finalStateVia": 1, + "finalResponse": { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "112" + } + } + } + }, + { + "$id": "356", + "kind": "lro", + "name": "delete", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Delete a TopLevelTrackedResource", + "operation": { + "$id": "357", + "name": "delete", + "resourceName": "TopLevelTrackedResource", + "doc": "Delete a TopLevelTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "358", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "359", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "360", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.delete.apiVersion", + "readOnly": false + }, + { + "$id": "361", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "362", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "363", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.delete.subscriptionId" + }, + { + "$id": "364", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "365", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.delete.resourceGroupName" + }, + { + "$id": "366", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "367", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.delete.topLevelTrackedResourceName" + } + ], + "responses": [ + { + "statusCodes": [ + 202 + ], + "headers": [ + { + "name": "location", + "nameInResponse": "Location", + "doc": "The Location header contains the URL where the status of the long running operation can be checked.", + "type": { + "$id": "368", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "369", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false + }, + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "DELETE", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.delete", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceDelete", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "370", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "371", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.delete.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "372", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "373", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.delete.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.delete", + "lroMetadata": { + "finalStateVia": 1, + "finalResponse": { + "statusCodes": [ + 204 + ] + } + } + }, + { + "$id": "374", + "kind": "paging", + "name": "listByResourceGroup", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "List TopLevelTrackedResource resources by resource group", + "operation": { + "$id": "375", + "name": "listByResourceGroup", + "resourceName": "TopLevelTrackedResource", + "doc": "List TopLevelTrackedResource resources by resource group", + "accessibility": "public", + "parameters": [ + { + "$id": "376", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "377", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "378", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listByResourceGroup.apiVersion", + "readOnly": false + }, + { + "$id": "379", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "380", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "381", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listByResourceGroup.subscriptionId" + }, + { + "$id": "382", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "383", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listByResourceGroup.resourceGroupName" + }, + { + "$id": "384", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "42" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listByResourceGroup.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "191" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listByResourceGroup", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceList", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "385", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "386", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listByResourceGroup.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "387", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "42" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listByResourceGroup.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "193" + }, + "resultSegments": [ + "value" + ] + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listByResourceGroup", + "pagingMetadata": { + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + }, + "pageSizeParameterSegments": [] + } + }, + { + "$id": "388", + "kind": "paging", + "name": "listBySubscription", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "List TopLevelTrackedResource resources by subscription ID", + "operation": { + "$id": "389", + "name": "listBySubscription", + "resourceName": "TopLevelTrackedResource", + "doc": "List TopLevelTrackedResource resources by subscription ID", + "accessibility": "public", + "parameters": [ + { + "$id": "390", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "391", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "392", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listBySubscription.apiVersion", + "readOnly": false + }, + { + "$id": "393", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "394", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "395", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listBySubscription.subscriptionId" + }, + { + "$id": "396", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "44" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listBySubscription.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "191" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listBySubscription", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceList", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "397", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "44" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listBySubscription.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "193" + }, + "resultSegments": [ + "value" + ] + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.listBySubscription", + "pagingMetadata": { + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + }, + "pageSizeParameterSegments": [] + } + }, + { + "$id": "398", + "kind": "basic", + "name": "actionSync", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "A synchronous resource action that returns no content.", + "operation": { + "$id": "399", + "name": "actionSync", + "resourceName": "TopLevel", + "doc": "A synchronous resource action that returns no content.", + "accessibility": "public", + "parameters": [ + { + "$id": "400", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "401", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "402", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.apiVersion", + "readOnly": false + }, + { + "$id": "403", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "404", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "405", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.subscriptionId" + }, + { + "$id": "406", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "407", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.resourceGroupName" + }, + { + "$id": "408", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "409", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.topLevelTrackedResourceName" + }, + { + "$id": "410", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "46" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.contentType" + }, + { + "$id": "411", + "kind": "body", + "name": "body", + "serializedName": "body", + "doc": "The content of the action request", + "type": { + "$ref": "197" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.body" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/actionSync", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceAction", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "412", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "413", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "414", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "415", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "416", + "kind": "method", + "name": "body", + "serializedName": "body", + "doc": "The content of the action request", + "type": { + "$ref": "197" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.body", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "417", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "46" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel.actionSync" + } + ], + "parameters": [ + { + "$id": "418", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "419", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "420", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.endpoint" + }, + { + "$ref": "283" + }, + { + "$ref": "286" + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.TopLevel", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "279" + } + }, + { + "$id": "421", + "kind": "client", + "name": "Nested", + "namespace": "Azure.ResourceManager.Resources", + "methods": [ + { + "$id": "422", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Get a NestedProxyResource", + "operation": { + "$id": "423", + "name": "get", + "resourceName": "NestedProxyResource", + "doc": "Get a NestedProxyResource", + "accessibility": "public", + "parameters": [ + { + "$id": "424", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "425", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "426", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.apiVersion", + "readOnly": false + }, + { + "$id": "427", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "428", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "429", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.subscriptionId" + }, + { + "$id": "430", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "431", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.resourceGroupName" + }, + { + "$id": "432", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "433", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.topLevelTrackedResourceName" + }, + { + "$id": "434", + "kind": "path", + "name": "nextedProxyResourceName", + "serializedName": "nextedProxyResourceName", + "doc": "Name of the nested resource.", + "type": { + "$id": "435", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.nextedProxyResourceName" + }, + { + "$id": "436", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "48" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "202" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceRead", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "437", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "438", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "439", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "440", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "441", + "kind": "method", + "name": "nextedProxyResourceName", + "serializedName": "nextedProxyResourceName", + "doc": "Name of the nested resource.", + "type": { + "$id": "442", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.nextedProxyResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "443", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "48" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "202" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get" + }, + { + "$id": "444", + "kind": "lro", + "name": "createOrReplace", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Create a NestedProxyResource", + "operation": { + "$id": "445", + "name": "createOrReplace", + "resourceName": "NestedProxyResource", + "doc": "Create a NestedProxyResource", + "accessibility": "public", + "parameters": [ + { + "$id": "446", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "447", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "448", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.apiVersion", + "readOnly": false + }, + { + "$id": "449", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "450", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "451", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.subscriptionId" + }, + { + "$id": "452", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "453", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.resourceGroupName" + }, + { + "$id": "454", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "455", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.topLevelTrackedResourceName" + }, + { + "$id": "456", + "kind": "path", + "name": "nextedProxyResourceName", + "serializedName": "nextedProxyResourceName", + "doc": "Name of the nested resource.", + "type": { + "$id": "457", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.nextedProxyResourceName" + }, + { + "$id": "458", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "50" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.contentType" + }, + { + "$id": "459", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "52" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.accept" + }, + { + "$id": "460", + "kind": "body", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "202" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.resource" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "202" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 201 + ], + "bodyType": { + "$ref": "202" + }, + "headers": [ + { + "name": "azureAsyncOperation", + "nameInResponse": "Azure-AsyncOperation", + "doc": "A link to the status monitor", + "type": { + "$id": "461", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "462", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceCreateOrUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "463", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "464", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "465", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "466", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "467", + "kind": "method", + "name": "nextedProxyResourceName", + "serializedName": "nextedProxyResourceName", + "doc": "Name of the nested resource.", + "type": { + "$id": "468", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.nextedProxyResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "469", + "kind": "method", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "202" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.resource", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "470", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "54" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "471", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "56" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "202" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.createOrReplace", + "lroMetadata": { + "finalStateVia": 0, + "finalResponse": { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "202" + } + } + } + }, + { + "$id": "472", + "kind": "lro", + "name": "update", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Update a NestedProxyResource", + "operation": { + "$id": "473", + "name": "update", + "resourceName": "NestedProxyResource", + "doc": "Update a NestedProxyResource", + "accessibility": "public", + "parameters": [ + { + "$id": "474", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "475", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "476", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.apiVersion", + "readOnly": false + }, + { + "$id": "477", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "478", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "479", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.subscriptionId" + }, + { + "$id": "480", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "481", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.resourceGroupName" + }, + { + "$id": "482", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "483", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.topLevelTrackedResourceName" + }, + { + "$id": "484", + "kind": "path", + "name": "nextedProxyResourceName", + "serializedName": "nextedProxyResourceName", + "doc": "Name of the nested resource.", + "type": { + "$id": "485", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.nextedProxyResourceName" + }, + { + "$id": "486", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "58" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.contentType" + }, + { + "$id": "487", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "60" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.accept" + }, + { + "$id": "488", + "kind": "body", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "202" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.properties" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "202" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 202 + ], + "headers": [ + { + "name": "location", + "nameInResponse": "Location", + "doc": "The Location header contains the URL where the status of the long running operation can be checked.", + "type": { + "$id": "489", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "490", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false + } + ], + "httpMethod": "PATCH", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "491", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "492", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "493", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "494", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "495", + "kind": "method", + "name": "nextedProxyResourceName", + "serializedName": "nextedProxyResourceName", + "doc": "Name of the nested resource.", + "type": { + "$id": "496", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.nextedProxyResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "497", + "kind": "method", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "202" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.properties", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "498", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "62" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "499", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "64" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "202" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.update", + "lroMetadata": { + "finalStateVia": 1, + "finalResponse": { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "202" + } + } + } + }, + { + "$id": "500", + "kind": "lro", + "name": "delete", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Delete a NestedProxyResource", + "operation": { + "$id": "501", + "name": "delete", + "resourceName": "NestedProxyResource", + "doc": "Delete a NestedProxyResource", + "accessibility": "public", + "parameters": [ + { + "$id": "502", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "503", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "504", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete.apiVersion", + "readOnly": false + }, + { + "$id": "505", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "506", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "507", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete.subscriptionId" + }, + { + "$id": "508", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "509", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete.resourceGroupName" + }, + { + "$id": "510", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "511", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete.topLevelTrackedResourceName" + }, + { + "$id": "512", + "kind": "path", + "name": "nextedProxyResourceName", + "serializedName": "nextedProxyResourceName", + "doc": "Name of the nested resource.", + "type": { + "$id": "513", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete.nextedProxyResourceName" + } + ], + "responses": [ + { + "statusCodes": [ + 202 + ], + "headers": [ + { + "name": "location", + "nameInResponse": "Location", + "doc": "The Location header contains the URL where the status of the long running operation can be checked.", + "type": { + "$id": "514", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "515", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false + }, + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "DELETE", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceDelete", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "516", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "517", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "518", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "519", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "520", + "kind": "method", + "name": "nextedProxyResourceName", + "serializedName": "nextedProxyResourceName", + "doc": "Name of the nested resource.", + "type": { + "$id": "521", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete.nextedProxyResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.delete", + "lroMetadata": { + "finalStateVia": 1, + "finalResponse": { + "statusCodes": [ + 204 + ] + } + } + }, + { + "$id": "522", + "kind": "paging", + "name": "listByTopLevelTrackedResource", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "List NestedProxyResource resources by TopLevelTrackedResource", + "operation": { + "$id": "523", + "name": "listByTopLevelTrackedResource", + "resourceName": "NestedProxyResource", + "doc": "List NestedProxyResource resources by TopLevelTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "524", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "525", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "526", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource.apiVersion", + "readOnly": false + }, + { + "$id": "527", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "528", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "529", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource.subscriptionId" + }, + { + "$id": "530", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "531", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource.resourceGroupName" + }, + { + "$id": "532", + "kind": "path", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "533", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource.topLevelTrackedResourceName" + }, + { + "$id": "534", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "66" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "216" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceList", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "535", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "536", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "537", + "kind": "method", + "name": "topLevelTrackedResourceName", + "serializedName": "topLevelTrackedResourceName", + "doc": "arm resource name for path", + "type": { + "$id": "538", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource.topLevelTrackedResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "539", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "66" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "218" + }, + "resultSegments": [ + "value" + ] + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.listByTopLevelTrackedResource", + "pagingMetadata": { + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + }, + "pageSizeParameterSegments": [] + } + } + ], + "parameters": [ + { + "$id": "540", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "541", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "542", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.endpoint" + }, + { + "$id": "543", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "544", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "545", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "546", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "547", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "548", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested.get.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Nested", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "279" + } + }, + { + "$id": "549", + "kind": "client", + "name": "Singleton", + "namespace": "Azure.ResourceManager.Resources", + "methods": [ + { + "$id": "550", + "kind": "basic", + "name": "getByResourceGroup", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Get a SingletonTrackedResource", + "operation": { + "$id": "551", + "name": "getByResourceGroup", + "resourceName": "SingletonTrackedResource", + "doc": "Get a SingletonTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "552", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "553", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "554", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup.apiVersion", + "readOnly": false + }, + { + "$id": "555", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "556", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "557", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup.subscriptionId" + }, + { + "$id": "558", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "559", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup.resourceGroupName" + }, + { + "$id": "560", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "68" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "222" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceRead", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "561", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "562", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "563", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "68" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "222" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup" + }, + { + "$id": "564", + "kind": "lro", + "name": "createOrUpdate", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Create a SingletonTrackedResource", + "operation": { + "$id": "565", + "name": "createOrUpdate", + "resourceName": "SingletonTrackedResource", + "doc": "Create a SingletonTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "566", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "567", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "568", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.apiVersion", + "readOnly": false + }, + { + "$id": "569", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "570", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "571", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.subscriptionId" + }, + { + "$id": "572", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "573", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.resourceGroupName" + }, + { + "$id": "574", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "70" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.contentType" + }, + { + "$id": "575", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "72" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.accept" + }, + { + "$id": "576", + "kind": "body", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "222" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.resource" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "222" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 201 + ], + "bodyType": { + "$ref": "222" + }, + "headers": [ + { + "name": "azureAsyncOperation", + "nameInResponse": "Azure-AsyncOperation", + "doc": "A link to the status monitor", + "type": { + "$id": "577", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "578", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceCreateOrUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "579", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "580", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "581", + "kind": "method", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "222" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.resource", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "582", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "74" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "583", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "76" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "222" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.createOrUpdate", + "lroMetadata": { + "finalStateVia": 0, + "finalResponse": { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "222" + } + } + } + }, + { + "$id": "584", + "kind": "basic", + "name": "update", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Update a SingletonTrackedResource", + "operation": { + "$id": "585", + "name": "update", + "resourceName": "SingletonTrackedResource", + "doc": "Update a SingletonTrackedResource", + "accessibility": "public", + "parameters": [ + { + "$id": "586", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "587", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "588", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.apiVersion", + "readOnly": false + }, + { + "$id": "589", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "590", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "591", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.subscriptionId" + }, + { + "$id": "592", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "593", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.resourceGroupName" + }, + { + "$id": "594", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "78" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.contentType" + }, + { + "$id": "595", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "80" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.accept" + }, + { + "$id": "596", + "kind": "body", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "222" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.properties" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "222" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PATCH", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "597", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "598", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "599", + "kind": "method", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "222" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.properties", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "600", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "78" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "601", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "80" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "222" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.update" + }, + { + "$id": "602", + "kind": "paging", + "name": "listByResourceGroup", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "List SingletonTrackedResource resources by resource group", + "operation": { + "$id": "603", + "name": "listByResourceGroup", + "resourceName": "SingletonTrackedResource", + "doc": "List SingletonTrackedResource resources by resource group", + "accessibility": "public", + "parameters": [ + { + "$id": "604", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "605", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "606", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.listByResourceGroup.apiVersion", + "readOnly": false + }, + { + "$id": "607", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "608", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "609", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.listByResourceGroup.subscriptionId" + }, + { + "$id": "610", + "kind": "path", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "611", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.listByResourceGroup.resourceGroupName" + }, + { + "$id": "612", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "82" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.listByResourceGroup.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "234" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.listByResourceGroup", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceList", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "613", + "kind": "method", + "name": "resourceGroupName", + "serializedName": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "614", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.listByResourceGroup.resourceGroupName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "615", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "82" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.listByResourceGroup.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "236" + }, + "resultSegments": [ + "value" + ] + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.listByResourceGroup", + "pagingMetadata": { + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + }, + "pageSizeParameterSegments": [] + } + } + ], + "parameters": [ + { + "$id": "616", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "617", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "618", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.endpoint" + }, + { + "$id": "619", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "620", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "621", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "622", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "623", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "624", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton.getByResourceGroup.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.Singleton", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "279" + } + }, + { + "$id": "625", + "kind": "client", + "name": "ExtensionsResources", + "namespace": "Azure.ResourceManager.Resources", + "doc": "The interface of extensions resources,\nit contains 4 kinds of scopes (resource, resource group, subscription and tenant)", + "methods": [ + { + "$id": "626", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Get a ExtensionsResource", + "operation": { + "$id": "627", + "name": "get", + "resourceName": "ExtensionsResource", + "doc": "Get a ExtensionsResource", + "accessibility": "public", + "parameters": [ + { + "$id": "628", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "629", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "630", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get.apiVersion", + "readOnly": false + }, + { + "$id": "631", + "kind": "path", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "632", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": true, + "skipUrlEncoding": true, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get.resourceUri" + }, + { + "$id": "633", + "kind": "path", + "name": "extensionsResourceName", + "serializedName": "extensionsResourceName", + "doc": "The name of the ExtensionsResource", + "type": { + "$id": "634", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get.extensionsResourceName" + }, + { + "$id": "635", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "84" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "240" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceRead", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "636", + "kind": "method", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "637", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get.resourceUri", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "638", + "kind": "method", + "name": "extensionsResourceName", + "serializedName": "extensionsResourceName", + "doc": "The name of the ExtensionsResource", + "type": { + "$id": "639", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get.extensionsResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "640", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "84" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "240" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get" + }, + { + "$id": "641", + "kind": "lro", + "name": "createOrUpdate", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Create a ExtensionsResource", + "operation": { + "$id": "642", + "name": "createOrUpdate", + "resourceName": "ExtensionsResource", + "doc": "Create a ExtensionsResource", + "accessibility": "public", + "parameters": [ + { + "$id": "643", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "644", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "645", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.apiVersion", + "readOnly": false + }, + { + "$id": "646", + "kind": "path", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "647", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": true, + "skipUrlEncoding": true, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.resourceUri" + }, + { + "$id": "648", + "kind": "path", + "name": "extensionsResourceName", + "serializedName": "extensionsResourceName", + "doc": "The name of the ExtensionsResource", + "type": { + "$id": "649", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.extensionsResourceName" + }, + { + "$id": "650", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "86" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.contentType" + }, + { + "$id": "651", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "88" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.accept" + }, + { + "$id": "652", + "kind": "body", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "240" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.resource" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "240" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 201 + ], + "bodyType": { + "$ref": "240" + }, + "headers": [ + { + "name": "azureAsyncOperation", + "nameInResponse": "Azure-AsyncOperation", + "doc": "A link to the status monitor", + "type": { + "$id": "653", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "654", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceCreateOrUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "655", + "kind": "method", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "656", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.resourceUri", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "657", + "kind": "method", + "name": "extensionsResourceName", + "serializedName": "extensionsResourceName", + "doc": "The name of the ExtensionsResource", + "type": { + "$id": "658", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.extensionsResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "659", + "kind": "method", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "240" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.resource", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "660", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "90" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "661", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "92" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "240" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.createOrUpdate", + "lroMetadata": { + "finalStateVia": 0, + "finalResponse": { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "240" + } + } + } + }, + { + "$id": "662", + "kind": "basic", + "name": "update", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Update a ExtensionsResource", + "operation": { + "$id": "663", + "name": "update", + "resourceName": "ExtensionsResource", + "doc": "Update a ExtensionsResource", + "accessibility": "public", + "parameters": [ + { + "$id": "664", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "665", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "666", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.apiVersion", + "readOnly": false + }, + { + "$id": "667", + "kind": "path", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "668", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": true, + "skipUrlEncoding": true, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.resourceUri" + }, + { + "$id": "669", + "kind": "path", + "name": "extensionsResourceName", + "serializedName": "extensionsResourceName", + "doc": "The name of the ExtensionsResource", + "type": { + "$id": "670", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.extensionsResourceName" + }, + { + "$id": "671", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "94" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.contentType" + }, + { + "$id": "672", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "96" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.accept" + }, + { + "$id": "673", + "kind": "body", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "240" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.properties" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "240" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PATCH", + "uri": "{endpoint}", + "path": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "674", + "kind": "method", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "675", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.resourceUri", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "676", + "kind": "method", + "name": "extensionsResourceName", + "serializedName": "extensionsResourceName", + "doc": "The name of the ExtensionsResource", + "type": { + "$id": "677", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.extensionsResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "678", + "kind": "method", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "240" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.properties", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "679", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "94" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "680", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "96" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "240" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.update" + }, + { + "$id": "681", + "kind": "basic", + "name": "delete", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Delete a ExtensionsResource", + "operation": { + "$id": "682", + "name": "delete", + "resourceName": "ExtensionsResource", + "doc": "Delete a ExtensionsResource", + "accessibility": "public", + "parameters": [ + { + "$id": "683", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "684", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "685", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.delete.apiVersion", + "readOnly": false + }, + { + "$id": "686", + "kind": "path", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "687", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": true, + "skipUrlEncoding": true, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.delete.resourceUri" + }, + { + "$id": "688", + "kind": "path", + "name": "extensionsResourceName", + "serializedName": "extensionsResourceName", + "doc": "The name of the ExtensionsResource", + "type": { + "$id": "689", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.delete.extensionsResourceName" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "headers": [], + "isErrorResponse": false + }, + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "DELETE", + "uri": "{endpoint}", + "path": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources/{extensionsResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.delete", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceDelete", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "690", + "kind": "method", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "691", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.delete.resourceUri", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "692", + "kind": "method", + "name": "extensionsResourceName", + "serializedName": "extensionsResourceName", + "doc": "The name of the ExtensionsResource", + "type": { + "$id": "693", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.delete.extensionsResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.delete" + }, + { + "$id": "694", + "kind": "paging", + "name": "listByScope", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "List ExtensionsResource resources by parent", + "operation": { + "$id": "695", + "name": "listByScope", + "resourceName": "ExtensionsResource", + "doc": "List ExtensionsResource resources by parent", + "accessibility": "public", + "parameters": [ + { + "$id": "696", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "697", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "698", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.listByScope.apiVersion", + "readOnly": false + }, + { + "$id": "699", + "kind": "path", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "700", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": true, + "skipUrlEncoding": true, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.listByScope.resourceUri" + }, + { + "$id": "701", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "98" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.listByScope.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "254" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/{resourceUri}/providers/Azure.ResourceManager.Resources/extensionsResources", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.listByScope", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceList", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "702", + "kind": "method", + "name": "resourceUri", + "serializedName": "resourceUri", + "doc": "The fully qualified Azure Resource manager identifier of the resource.", + "type": { + "$id": "703", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.listByScope.resourceUri", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "704", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "98" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.listByScope.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "256" + }, + "resultSegments": [ + "value" + ] + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.listByScope", + "pagingMetadata": { + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + }, + "pageSizeParameterSegments": [] + } + } + ], + "parameters": [ + { + "$id": "705", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "706", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "707", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.endpoint" + }, + { + "$id": "708", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "709", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "710", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources.get.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.ExtensionsResources", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "279" + } + }, + { + "$id": "711", + "kind": "client", + "name": "LocationResources", + "namespace": "Azure.ResourceManager.Resources", + "methods": [ + { + "$id": "712", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Get a LocationResource", + "operation": { + "$id": "713", + "name": "get", + "resourceName": "LocationResource", + "doc": "Get a LocationResource", + "accessibility": "public", + "parameters": [ + { + "$id": "714", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "715", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "716", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.apiVersion", + "readOnly": false + }, + { + "$id": "717", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "718", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "719", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.subscriptionId" + }, + { + "$id": "720", + "kind": "path", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "721", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "722", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.location" + }, + { + "$id": "723", + "kind": "path", + "name": "locationResourceName", + "serializedName": "locationResourceName", + "doc": "The name of the LocationResource", + "type": { + "$id": "724", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.locationResourceName" + }, + { + "$id": "725", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "100" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "260" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceRead", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "726", + "kind": "method", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "727", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "728", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.location", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "729", + "kind": "method", + "name": "locationResourceName", + "serializedName": "locationResourceName", + "doc": "The name of the LocationResource", + "type": { + "$id": "730", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.locationResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "731", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "100" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "260" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get" + }, + { + "$id": "732", + "kind": "basic", + "name": "createOrUpdate", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Create a LocationResource", + "operation": { + "$id": "733", + "name": "createOrUpdate", + "resourceName": "LocationResource", + "doc": "Create a LocationResource", + "accessibility": "public", + "parameters": [ + { + "$id": "734", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "735", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "736", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.apiVersion", + "readOnly": false + }, + { + "$id": "737", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "738", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "739", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.subscriptionId" + }, + { + "$id": "740", + "kind": "path", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "741", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "742", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.location" + }, + { + "$id": "743", + "kind": "path", + "name": "locationResourceName", + "serializedName": "locationResourceName", + "doc": "The name of the LocationResource", + "type": { + "$id": "744", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.locationResourceName" + }, + { + "$id": "745", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "102" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.contentType" + }, + { + "$id": "746", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "104" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.accept" + }, + { + "$id": "747", + "kind": "body", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "260" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.resource" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "260" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "statusCodes": [ + 201 + ], + "bodyType": { + "$ref": "260" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceCreateOrUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "748", + "kind": "method", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "749", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "750", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.location", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "751", + "kind": "method", + "name": "locationResourceName", + "serializedName": "locationResourceName", + "doc": "The name of the LocationResource", + "type": { + "$id": "752", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.locationResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "753", + "kind": "method", + "name": "resource", + "serializedName": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "260" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.resource", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "754", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "102" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "755", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "104" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "260" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.createOrUpdate" + }, + { + "$id": "756", + "kind": "basic", + "name": "update", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Update a LocationResource", + "operation": { + "$id": "757", + "name": "update", + "resourceName": "LocationResource", + "doc": "Update a LocationResource", + "accessibility": "public", + "parameters": [ + { + "$id": "758", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "759", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "760", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.apiVersion", + "readOnly": false + }, + { + "$id": "761", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "762", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "763", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.subscriptionId" + }, + { + "$id": "764", + "kind": "path", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "765", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "766", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.location" + }, + { + "$id": "767", + "kind": "path", + "name": "locationResourceName", + "serializedName": "locationResourceName", + "doc": "The name of the LocationResource", + "type": { + "$id": "768", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.locationResourceName" + }, + { + "$id": "769", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "106" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.contentType" + }, + { + "$id": "770", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "108" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.accept" + }, + { + "$id": "771", + "kind": "body", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "260" + }, + "isApiVersion": false, + "contentTypes": [ + "application/json" + ], + "defaultContentType": "application/json", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.properties" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "260" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PATCH", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceUpdate", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "772", + "kind": "method", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "773", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "774", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.location", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "775", + "kind": "method", + "name": "locationResourceName", + "serializedName": "locationResourceName", + "doc": "The name of the LocationResource", + "type": { + "$id": "776", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.locationResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "777", + "kind": "method", + "name": "properties", + "serializedName": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "260" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.properties", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "778", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$ref": "106" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "779", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "108" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "260" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.update" + }, + { + "$id": "780", + "kind": "basic", + "name": "delete", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "Delete a LocationResource", + "operation": { + "$id": "781", + "name": "delete", + "resourceName": "LocationResource", + "doc": "Delete a LocationResource", + "accessibility": "public", + "parameters": [ + { + "$id": "782", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "783", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "784", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.delete.apiVersion", + "readOnly": false + }, + { + "$id": "785", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "786", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "787", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.delete.subscriptionId" + }, + { + "$id": "788", + "kind": "path", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "789", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "790", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.delete.location" + }, + { + "$id": "791", + "kind": "path", + "name": "locationResourceName", + "serializedName": "locationResourceName", + "doc": "The name of the LocationResource", + "type": { + "$id": "792", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.delete.locationResourceName" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "headers": [], + "isErrorResponse": false + }, + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "DELETE", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.delete", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceDelete", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "793", + "kind": "method", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "794", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "795", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.delete.location", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "796", + "kind": "method", + "name": "locationResourceName", + "serializedName": "locationResourceName", + "doc": "The name of the LocationResource", + "type": { + "$id": "797", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.delete.locationResourceName", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.delete" + }, + { + "$id": "798", + "kind": "paging", + "name": "listByLocation", + "accessibility": "public", + "apiVersions": [ + "2023-12-01-preview" + ], + "doc": "List LocationResource resources by SubscriptionLocationResource", + "operation": { + "$id": "799", + "name": "listByLocation", + "resourceName": "LocationResource", + "doc": "List LocationResource resources by SubscriptionLocationResource", + "accessibility": "public", + "parameters": [ + { + "$id": "800", + "kind": "query", + "name": "apiVersion", + "serializedName": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "801", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "isApiVersion": true, + "explode": false, + "defaultValue": { + "type": { + "$id": "802", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Client", + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.listByLocation.apiVersion", + "readOnly": false + }, + { + "$id": "803", + "kind": "path", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "804", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "805", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Client", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.listByLocation.subscriptionId" + }, + { + "$id": "806", + "kind": "path", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "807", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "808", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "isApiVersion": false, + "explode": false, + "style": "simple", + "allowReserved": false, + "skipUrlEncoding": false, + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.listByLocation.location" + }, + { + "$id": "809", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "110" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.listByLocation.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "273" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.listByLocation", + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceList", + "arguments": {} + } + ] + }, + "parameters": [ + { + "$id": "810", + "kind": "method", + "name": "location", + "serializedName": "location", + "doc": "The name of the Azure region.", + "type": { + "$id": "811", + "kind": "string", + "name": "azureLocation", + "crossLanguageDefinitionId": "Azure.Core.azureLocation", + "baseType": { + "$id": "812", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.listByLocation.location", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "813", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "110" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.listByLocation.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "275" + }, + "resultSegments": [ + "value" + ] + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.listByLocation", + "pagingMetadata": { + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + }, + "pageSizeParameterSegments": [] + } + } + ], + "parameters": [ + { + "$id": "814", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "815", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "816", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.endpoint" + }, + { + "$id": "817", + "kind": "method", + "name": "apiVersion", + "serializedName": "apiVersion", + "doc": "The API version to use for this operation.", + "type": { + "$id": "818", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "", + "isApiVersion": true, + "defaultValue": { + "type": { + "$id": "819", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2023-12-01-preview" + }, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.apiVersion", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "820", + "kind": "method", + "name": "subscriptionId", + "serializedName": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "821", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "822", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources.get.subscriptionId", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "initializedBy": 0, + "decorators": [ + { + "name": "Azure.ResourceManager.@armResourceOperations", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Azure.ResourceManager.Resources.LocationResources", + "apiVersions": [ + "2023-12-01-preview" + ], + "parent": { + "$ref": "279" + } + } + ] + } + ], + "auth": { + "oAuth2": { + "flows": [ + { + "scopes": [ + "user_impersonation" + ], + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize" + } + ] + } + } +} diff --git a/eng/packages/http-client-csharp-mgmt/package-lock.json b/eng/packages/http-client-csharp-mgmt/package-lock.json index 724fa16d0548..9bd745803474 100644 --- a/eng/packages/http-client-csharp-mgmt/package-lock.json +++ b/eng/packages/http-client-csharp-mgmt/package-lock.json @@ -27,6 +27,8 @@ "@typespec/http-specs": "0.1.0-alpha.28", "@typespec/openapi": "1.6.0", "@typespec/rest": "0.76.0", + "@typespec/spec-api": "0.1.0-alpha.10", + "@typespec/spector": "0.1.0-alpha.20", "@typespec/streams": "0.76.0", "@typespec/tspd": "0.73.1", "@typespec/versioning": "0.76.0", diff --git a/eng/packages/http-client-csharp-mgmt/package.json b/eng/packages/http-client-csharp-mgmt/package.json index 2de26e7c92a0..e37c76c59309 100644 --- a/eng/packages/http-client-csharp-mgmt/package.json +++ b/eng/packages/http-client-csharp-mgmt/package.json @@ -55,6 +55,8 @@ "@typespec/http-specs": "0.1.0-alpha.28", "@typespec/openapi": "1.6.0", "@typespec/rest": "0.76.0", + "@typespec/spec-api": "0.1.0-alpha.10", + "@typespec/spector": "0.1.0-alpha.20", "@typespec/streams": "0.76.0", "@typespec/tspd": "0.73.1", "@typespec/versioning": "0.76.0",