diff --git a/sdk/applink/Azure.ResourceManager.AppLink/Azure.ResourceManager.AppLink.sln b/sdk/applink/Azure.ResourceManager.AppLink/Azure.ResourceManager.AppLink.sln new file mode 100644 index 000000000000..d32b95c71c38 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/Azure.ResourceManager.AppLink.sln @@ -0,0 +1,100 @@ + +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.AppLink", "src\Azure.ResourceManager.AppLink.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.AppLink.Tests", "tests\Azure.ResourceManager.AppLink.Tests.csproj", "{A712801B-1FCD-4B0B-9F78-55A8BD49575F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{E2037903-710A-423D-96A8-6AD525786AD9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core", "..\..\core\Azure.Core\src\Azure.Core.csproj", "{69AF8019-10B4-4E78-BFAB-CF3E2E673A70}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.SdkAnalyzers", "..\..\tools\Azure.SdkAnalyzers\src\Azure.SdkAnalyzers.csproj", "{689F9160-B580-4E8F-954C-3435E43A7863}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {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}.Debug|x64.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|x64.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|x86.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|x86.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 + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x64.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x64.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x86.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x86.Build.0 = Release|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Debug|x64.ActiveCfg = Debug|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Debug|x64.Build.0 = Debug|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Debug|x86.ActiveCfg = Debug|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Debug|x86.Build.0 = Debug|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Release|Any CPU.Build.0 = Release|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Release|x64.ActiveCfg = Release|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Release|x64.Build.0 = Release|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Release|x86.ActiveCfg = Release|Any CPU + {A712801B-1FCD-4B0B-9F78-55A8BD49575F}.Release|x86.Build.0 = Release|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Debug|x64.ActiveCfg = Debug|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Debug|x64.Build.0 = Debug|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Debug|x86.ActiveCfg = Debug|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Debug|x86.Build.0 = Debug|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Release|Any CPU.Build.0 = Release|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Release|x64.ActiveCfg = Release|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Release|x64.Build.0 = Release|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Release|x86.ActiveCfg = Release|Any CPU + {E2037903-710A-423D-96A8-6AD525786AD9}.Release|x86.Build.0 = Release|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Debug|x64.ActiveCfg = Debug|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Debug|x64.Build.0 = Debug|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Debug|x86.ActiveCfg = Debug|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Debug|x86.Build.0 = Debug|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Release|Any CPU.Build.0 = Release|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Release|x64.ActiveCfg = Release|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Release|x64.Build.0 = Release|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Release|x86.ActiveCfg = Release|Any CPU + {69AF8019-10B4-4E78-BFAB-CF3E2E673A70}.Release|x86.Build.0 = Release|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Debug|Any CPU.Build.0 = Debug|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Debug|x64.ActiveCfg = Debug|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Debug|x64.Build.0 = Debug|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Debug|x86.ActiveCfg = Debug|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Debug|x86.Build.0 = Debug|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Release|Any CPU.ActiveCfg = Release|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Release|Any CPU.Build.0 = Release|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Release|x64.ActiveCfg = Release|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Release|x64.Build.0 = Release|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Release|x86.ActiveCfg = Release|Any CPU + {689F9160-B580-4E8F-954C-3435E43A7863}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A712801B-1FCD-4B0B-9F78-55A8BD49575F} = {0AB3BF05-4346-4AA6-1389-037BE0695223} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/applink/Azure.ResourceManager.AppLink/CHANGELOG.md b/sdk/applink/Azure.ResourceManager.AppLink/CHANGELOG.md new file mode 100644 index 000000000000..f50dd6a1a0bf --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/CHANGELOG.md @@ -0,0 +1,12 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + diff --git a/sdk/applink/Azure.ResourceManager.AppLink/Directory.Build.props b/sdk/applink/Azure.ResourceManager.AppLink/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/applink/Azure.ResourceManager.AppLink/README.md b/sdk/applink/Azure.ResourceManager.AppLink/README.md new file mode 100644 index 000000000000..67ed612b2273 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure AppLink management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure AppLink management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.AppLink --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://docs.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/applink/Azure.ResourceManager.AppLink/metadata.json b/sdk/applink/Azure.ResourceManager.AppLink/metadata.json new file mode 100644 index 000000000000..38a65558b75c --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/metadata.json @@ -0,0 +1,5 @@ +{ + "apiVersions": { + "Microsoft.AppLink": "2025-08-01-preview" + } +} \ No newline at end of file diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Azure.ResourceManager.AppLink.csproj b/sdk/applink/Azure.ResourceManager.AppLink/src/Azure.ResourceManager.AppLink.csproj new file mode 100644 index 000000000000..c89b3b1b204c --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Azure.ResourceManager.AppLink.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.AppLink client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.AppLink + 1.0.0-beta.1 + Azure.ResourceManager.AppLink + true + + diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkCollection.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkCollection.cs new file mode 100644 index 000000000000..30a9ef53f460 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkCollection.cs @@ -0,0 +1,580 @@ +// 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; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink +{ + /// + /// 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 GetAppLinks method from an instance of . + /// + public partial class AppLinkCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _appLinksClientDiagnostics; + private readonly AppLinks _appLinksRestClient; + + /// Initializes a new instance of AppLinkCollection for mocking. + protected AppLinkCollection() + { + } + + /// 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 AppLinkCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(AppLinkResource.ResourceType, out string appLinkApiVersion); + _appLinksClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", AppLinkResource.ResourceType.Namespace, Diagnostics); + _appLinksRestClient = new AppLinks(_appLinksClientDiagnostics, Pipeline, Endpoint, appLinkApiVersion ?? "2025-08-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), nameof(id)); + } + } + + /// + /// Create an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-08-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 AppLink. + /// 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 appLinkName, AppLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, AppLinkData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkOperationSource(Client), + _appLinksClientDiagnostics, + 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 an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-08-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 AppLink. + /// 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 appLinkName, AppLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, AppLinkData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkOperationSource(Client), + _appLinksClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List AppLink resources by resource group. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks. + /// + /// + /// Operation Id. + /// AppLinks_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2025-08-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 AppLinksGetByResourceGroupAsyncCollectionResultOfT(_appLinksRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new AppLinkResource(Client, data)); + } + + /// + /// List AppLink resources by resource group. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks. + /// + /// + /// Operation Id. + /// AppLinks_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2025-08-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 AppLinksGetByResourceGroupCollectionResultOfT(_appLinksRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new AppLinkResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.Serialization.cs new file mode 100644 index 000000000000..0275eb270f09 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.Serialization.cs @@ -0,0 +1,245 @@ +// 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.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// AppLink resource. + public partial class AppLinkData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkData() + { + } + + /// 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 DeserializeAppLinkData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AppLinkData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AppLinkData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(AppLinkData appLinkData) + { + if (appLinkData == null) + { + return null; + } + return RequestContent.Create(appLinkData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static AppLinkData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAppLinkData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(AppLinkData)} 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.Format == "W" ? ModelSerializationExtensions.WireV3Options : ModelSerializationExtensions.JsonV3Options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AppLinkData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AppLinkData)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(AppLinkData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkData DeserializeAppLinkData(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; + AppLinkProperties properties = default; + ManagedServiceIdentity identity = 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, AzureResourceManagerAppLinkContext.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 = AppLinkProperties.DeserializeAppLinkProperties(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())), options.Format == "W" ? ModelSerializationExtensions.WireV3Options : ModelSerializationExtensions.JsonV3Options, AzureResourceManagerAppLinkContext.Default); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + identity); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.cs new file mode 100644 index 000000000000..f6abfb556d2d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.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.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// AppLink resource. + public partial class AppLinkData : 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 AppLinkData(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 AppLinkData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, AppLinkProperties properties, ManagedServiceIdentity identity) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + Identity = identity; + } + + /// The resource-specific properties for this resource. + internal AppLinkProperties Properties { get; set; } + + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + + /// Provisioning state. + public ProvisioningState? AppLinkProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberCollection.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberCollection.cs new file mode 100644 index 000000000000..95431bf40e10 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberCollection.cs @@ -0,0 +1,583 @@ +// 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.AppLink +{ + /// + /// 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 GetAppLinkMembers method from an instance of . + /// + public partial class AppLinkMemberCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _appLinkMembersClientDiagnostics; + private readonly AppLinkMembers _appLinkMembersRestClient; + private readonly ClientDiagnostics _upgradeHistoriesClientDiagnostics; + private readonly UpgradeHistories _upgradeHistoriesRestClient; + + /// Initializes a new instance of AppLinkMemberCollection for mocking. + protected AppLinkMemberCollection() + { + } + + /// 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 AppLinkMemberCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(AppLinkMemberResource.ResourceType, out string appLinkMemberApiVersion); + _appLinkMembersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", AppLinkMemberResource.ResourceType.Namespace, Diagnostics); + _appLinkMembersRestClient = new AppLinkMembers(_appLinkMembersClientDiagnostics, Pipeline, Endpoint, appLinkMemberApiVersion ?? "2025-08-01-preview"); + _upgradeHistoriesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", AppLinkMemberResource.ResourceType.Namespace, Diagnostics); + _upgradeHistoriesRestClient = new UpgradeHistories(_upgradeHistoriesClientDiagnostics, Pipeline, Endpoint, appLinkMemberApiVersion ?? "2025-08-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != AppLinkResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, AppLinkResource.ResourceType), nameof(id)); + } + } + + /// + /// Create an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-08-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 AppLinkMember. + /// 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 appLinkMemberName, AppLinkMemberData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, AppLinkMemberData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkMemberOperationSource(Client), + _appLinkMembersClientDiagnostics, + 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 an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-08-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 AppLinkMember. + /// 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 appLinkMemberName, AppLinkMemberData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, AppLinkMemberData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkMemberOperationSource(Client), + _appLinkMembersClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List AppLinkMember resources by AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers. + /// + /// + /// Operation Id. + /// AppLinkMembers_ListByAppLink. + /// + /// + /// Default Api Version. + /// 2025-08-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 AppLinkMembersGetByAppLinkAsyncCollectionResultOfT(_appLinkMembersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new AppLinkMemberResource(Client, data)); + } + + /// + /// List AppLinkMember resources by AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers. + /// + /// + /// Operation Id. + /// AppLinkMembers_ListByAppLink. + /// + /// + /// Default Api Version. + /// 2025-08-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 AppLinkMembersGetByAppLinkCollectionResultOfT(_appLinkMembersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new AppLinkMemberResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkMemberData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkMemberData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkMemberData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkMemberData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.Serialization.cs new file mode 100644 index 000000000000..1f3a55cb91eb --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// AppLink Member resource. + public partial class AppLinkMemberData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkMemberData() + { + } + + /// 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 DeserializeAppLinkMemberData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkMemberData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkMemberData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AppLinkMemberData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AppLinkMemberData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(AppLinkMemberData appLinkMemberData) + { + if (appLinkMemberData == null) + { + return null; + } + return RequestContent.Create(appLinkMemberData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static AppLinkMemberData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAppLinkMemberData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(AppLinkMemberData)} 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. + AppLinkMemberData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AppLinkMemberData)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(AppLinkMemberData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkMemberData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkMemberData DeserializeAppLinkMemberData(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; + AppLinkMemberProperties 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, AzureResourceManagerAppLinkContext.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 = AppLinkMemberProperties.DeserializeAppLinkMemberProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkMemberData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.cs new file mode 100644 index 000000000000..f92817cf9033 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.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.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// AppLink Member resource. + public partial class AppLinkMemberData : 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 AppLinkMemberData(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 AppLinkMemberData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, AppLinkMemberProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public AppLinkMemberProperties Properties { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.Serialization.cs new file mode 100644 index 000000000000..f0e3746e263d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.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.AppLink +{ + /// + public partial class AppLinkMemberResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new AppLinkMemberData(); + + /// 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. + AppLinkMemberData 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, AzureResourceManagerAppLinkContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + AppLinkMemberData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerAppLinkContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.cs new file mode 100644 index 000000000000..65797ef29bf5 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.cs @@ -0,0 +1,763 @@ +// 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.AppLink.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink +{ + /// + /// A class representing a AppLinkMember 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 GetAppLinkMembers method. + /// + public partial class AppLinkMemberResource : ArmResource + { + private readonly ClientDiagnostics _appLinkMembersClientDiagnostics; + private readonly AppLinkMembers _appLinkMembersRestClient; + private readonly ClientDiagnostics _upgradeHistoriesClientDiagnostics; + private readonly UpgradeHistories _upgradeHistoriesRestClient; + private readonly AppLinkMemberData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AppLink/appLinks/appLinkMembers"; + + /// Initializes a new instance of AppLinkMemberResource for mocking. + protected AppLinkMemberResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal AppLinkMemberResource(ArmClient client, AppLinkMemberData 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 AppLinkMemberResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string appLinkMemberApiVersion); + _appLinkMembersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", ResourceType.Namespace, Diagnostics); + _appLinkMembersRestClient = new AppLinkMembers(_appLinkMembersClientDiagnostics, Pipeline, Endpoint, appLinkMemberApiVersion ?? "2025-08-01-preview"); + _upgradeHistoriesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", ResourceType.Namespace, Diagnostics); + _upgradeHistoriesRestClient = new UpgradeHistories(_upgradeHistoriesClientDiagnostics, Pipeline, Endpoint, appLinkMemberApiVersion ?? "2025-08-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 AppLinkMemberData 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 appLinkName. + /// The appLinkMemberName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}"; + 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), nameof(id)); + } + } + + /// + /// Get an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.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(AppLinkMemberData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Update. + /// + /// + /// Default Api Version. + /// 2025-08-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, AppLinkMemberData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, AppLinkMemberData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkMemberOperationSource(Client), + _appLinkMembersClientDiagnostics, + 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; + } + } + + /// + /// Update an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Update. + /// + /// + /// Default Api Version. + /// 2025-08-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, AppLinkMemberData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, AppLinkMemberData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkMemberOperationSource(Client), + _appLinkMembersClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Delete. + /// + /// + /// Default Api Version. + /// 2025-08-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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation(_appLinkMembersClientDiagnostics, 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 an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Delete. + /// + /// + /// Default Api Version. + /// 2025-08-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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation(_appLinkMembersClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List UpgradeHistory resources by AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}/upgradeHistories. + /// + /// + /// Operation Id. + /// UpgradeHistories_ListByAppLinkMember. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetByAppLinkMemberAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT( + _upgradeHistoriesRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + Id.Parent.Name, + Id.Name, + context); + } + + /// + /// List UpgradeHistory resources by AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}/upgradeHistories. + /// + /// + /// Operation Id. + /// UpgradeHistories_ListByAppLinkMember. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetByAppLinkMember(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT( + _upgradeHistoriesRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + Id.Parent.Name, + Id.Name, + context); + } + + /// 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.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(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkMemberData patch = new AppLinkMemberData(); + 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkMemberData patch = new AppLinkMemberData(); + 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.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(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkMemberData patch = new AppLinkMemberData(); + 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkMemberData patch = new AppLinkMemberData(); + 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.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(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkMemberData patch = new AppLinkMemberData(); + 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkMemberData patch = new AppLinkMemberData(); + 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; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.Serialization.cs new file mode 100644 index 000000000000..fc2d1b5f3242 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.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.AppLink +{ + /// + public partial class AppLinkResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new AppLinkData(); + + /// 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. + AppLinkData 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, AzureResourceManagerAppLinkContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + AppLinkData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerAppLinkContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.cs new file mode 100644 index 000000000000..c5e73755bca3 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.cs @@ -0,0 +1,714 @@ +// 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.AppLink +{ + /// + /// A class representing a AppLink 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 GetAppLinks method. + /// + public partial class AppLinkResource : ArmResource + { + private readonly ClientDiagnostics _appLinksClientDiagnostics; + private readonly AppLinks _appLinksRestClient; + private readonly AppLinkData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AppLink/appLinks"; + + /// Initializes a new instance of AppLinkResource for mocking. + protected AppLinkResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal AppLinkResource(ArmClient client, AppLinkData 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 AppLinkResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string appLinkApiVersion); + _appLinksClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", ResourceType.Namespace, Diagnostics); + _appLinksRestClient = new AppLinks(_appLinksClientDiagnostics, Pipeline, Endpoint, appLinkApiVersion ?? "2025-08-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 AppLinkData 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 appLinkName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string appLinkName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}"; + 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), nameof(id)); + } + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Update. + /// + /// + /// Default Api Version. + /// 2025-08-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, AppLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, AppLinkData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkOperationSource(Client), + _appLinksClientDiagnostics, + 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; + } + } + + /// + /// Update an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Update. + /// + /// + /// Default Api Version. + /// 2025-08-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, AppLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, AppLinkData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkOperationSource(Client), + _appLinksClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Delete. + /// + /// + /// Default Api Version. + /// 2025-08-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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation(_appLinksClientDiagnostics, 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 an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Delete. + /// + /// + /// Default Api Version. + /// 2025-08-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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation(_appLinksClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkData patch = new AppLinkData(); + 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkData patch = new AppLinkData(); + 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkData patch = new AppLinkData(); + 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkData patch = new AppLinkData(); + 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkData patch = new AppLinkData(); + 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkData patch = new AppLinkData(); + 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 AppLinkMembers in the . + /// An object representing collection of AppLinkMembers and their operations over a AppLinkMemberResource. + public virtual AppLinkMemberCollection GetAppLinkMembers() + { + return GetCachedClient(client => new AppLinkMemberCollection(client, Id)); + } + + /// Get an AppLinkMember. + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAppLinkMemberAsync(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + return await GetAppLinkMembers().GetAsync(appLinkMemberName, cancellationToken).ConfigureAwait(false); + } + + /// Get an AppLinkMember. + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAppLinkMember(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + return GetAppLinkMembers().Get(appLinkMemberName, cancellationToken); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ArmAppLinkModelFactory.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ArmAppLinkModelFactory.cs new file mode 100644 index 000000000000..2b699510e3f2 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ArmAppLinkModelFactory.cs @@ -0,0 +1,176 @@ +// 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.AppLink; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ArmAppLinkModelFactory + { + + /// 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. + /// Provisioning state. + /// The managed service identities assigned to this resource. + /// A new instance for mocking. + public static AppLinkData AppLinkData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, ProvisioningState? appLinkProvisioningState = default, ManagedServiceIdentity identity = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AppLinkData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + appLinkProvisioningState is null ? default : new AppLinkProperties(appLinkProvisioningState, null), + identity); + } + + /// AppLink Member 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static AppLinkMemberData AppLinkMemberData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, AppLinkMemberProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AppLinkMemberData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Cluster type. + /// Resource ID. + /// Upgrade profile. + /// Metrics endpoint URL. + /// Connectivity profile. + /// Provisioning state. + /// A new instance for mocking. + public static AppLinkMemberProperties AppLinkMemberProperties(ClusterType? clusterType = default, ResourceIdentifier metadataResourceId = default, UpgradeProfile upgradeProfile = default, string observabilityMetricsEndpoint = default, ConnectivityProfile connectivityProfile = default, ProvisioningState? provisioningState = default) + { + return new AppLinkMemberProperties( + clusterType, + metadataResourceId is null ? default : new Metadata(metadataResourceId, null), + upgradeProfile, + observabilityMetricsEndpoint is null ? default : new ObservabilityProfile(new MetricsProfile(observabilityMetricsEndpoint, null), null), + connectivityProfile, + provisioningState, + additionalBinaryDataProperties: null); + } + + /// AppLinkMember upgrade history. + /// 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 UpgradeHistory UpgradeHistory(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, UpgradeHistoryProperties properties = default) + { + return new UpgradeHistory( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// AppLinkMember upgrade history properties. + /// Start timestamp. + /// End timestamp. + /// Upgrade initiator. + /// Version upgraded from. + /// Version upgraded to. + /// Provisioning state. + /// A new instance for mocking. + public static UpgradeHistoryProperties UpgradeHistoryProperties(DateTimeOffset startTimestamp = default, DateTimeOffset? endTimestamp = default, string initiatedBy = default, string fromVersion = default, string toVersion = default, ProvisioningState? provisioningState = default) + { + return new UpgradeHistoryProperties( + startTimestamp, + endTimestamp, + initiatedBy, + fromVersion, + toVersion, + provisioningState, + additionalBinaryDataProperties: null); + } + + /// AppLink available version 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 AvailableVersion AvailableVersion(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, AvailableVersionProperties properties = default) + { + return new AvailableVersion( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// Kubernetes version. + /// Release channels. + /// Istio versions. + /// Provisioning state. + /// A new instance for mocking. + public static AvailableVersionProperties AvailableVersionProperties(string kubernetesVersion = default, IEnumerable fullyManagedVersionsReleaseChannels = default, IEnumerable selfManagedVersions = default, ProvisioningState? provisioningState = default) + { + return new AvailableVersionProperties(kubernetesVersion, fullyManagedVersionsReleaseChannels is null ? default : new FullyManagedVersions((fullyManagedVersionsReleaseChannels ?? new ChangeTrackingList()).ToList(), null), selfManagedVersions is null ? default : new SelfManagedVersions((selfManagedVersions ?? new ChangeTrackingList()).ToList(), null), provisioningState, additionalBinaryDataProperties: null); + } + + /// Release channel information. + /// Release channel. + /// Istio version behind release channel. + /// A new instance for mocking. + public static ReleaseChannelInfo ReleaseChannelInfo(string releaseChannel = default, string version = default) + { + return new ReleaseChannelInfo(releaseChannel, version, additionalBinaryDataProperties: null); + } + + /// Version information. + /// Istio version. + /// Available upgrades. + /// A new instance for mocking. + public static VersionInfo VersionInfo(string version = default, IEnumerable upgrades = default) + { + upgrades ??= new ChangeTrackingList(); + + return new VersionInfo(version, upgrades.ToList(), additionalBinaryDataProperties: null); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..28deaa0782a4 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkAsyncCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinkMembersGetByAppLinkAsyncCollectionResultOfT : AsyncPageable + { + private readonly AppLinkMembers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _appLinkName; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinkMembersGetByAppLinkAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinkMembers 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 name of the AppLink. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AppLinkMembersGetByAppLinkAsyncCollectionResultOfT(AppLinkMembers client, Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _appLinkName = appLinkName; + _context = context; + } + + /// Gets the pages of AppLinkMembersGetByAppLinkAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinkMembersGetByAppLinkAsyncCollectionResultOfT 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; + } + AppLinkMemberListResult result = AppLinkMemberListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByAppLinkRequest(nextLink, _subscriptionId, _resourceGroupName, _appLinkName, _context) : _client.CreateGetByAppLinkRequest(_subscriptionId, _resourceGroupName, _appLinkName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AppLinkMemberCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkCollectionResultOfT.cs new file mode 100644 index 000000000000..81d3cb99b1ce --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinkMembersGetByAppLinkCollectionResultOfT : Pageable + { + private readonly AppLinkMembers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _appLinkName; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinkMembersGetByAppLinkCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinkMembers 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 name of the AppLink. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AppLinkMembersGetByAppLinkCollectionResultOfT(AppLinkMembers client, Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _appLinkName = appLinkName; + _context = context; + } + + /// Gets the pages of AppLinkMembersGetByAppLinkCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinkMembersGetByAppLinkCollectionResultOfT 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; + } + AppLinkMemberListResult result = AppLinkMemberListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByAppLinkRequest(nextLink, _subscriptionId, _resourceGroupName, _appLinkName, _context) : _client.CreateGetByAppLinkRequest(_subscriptionId, _resourceGroupName, _appLinkName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AppLinkMemberCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..4dc7bc3018d3 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupAsyncCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinksGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly AppLinks _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinksGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinks 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 AppLinksGetByResourceGroupAsyncCollectionResultOfT(AppLinks client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of AppLinksGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinksGetByResourceGroupAsyncCollectionResultOfT 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; + } + AppLinkListResult result = AppLinkListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("AppLinkCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..4aeb1ec9be89 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinksGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly AppLinks _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinksGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinks 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 AppLinksGetByResourceGroupCollectionResultOfT(AppLinks client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of AppLinksGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinksGetByResourceGroupCollectionResultOfT 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; + } + AppLinkListResult result = AppLinkListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("AppLinkCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..728fc2bb4fe0 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionAsyncCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinksGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly AppLinks _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinksGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinks 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 AppLinksGetBySubscriptionAsyncCollectionResultOfT(AppLinks client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of AppLinksGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinksGetBySubscriptionAsyncCollectionResultOfT 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; + } + AppLinkListResult result = AppLinkListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableAppLinkSubscriptionResource.GetAppLinks"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..2b390ea467f3 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinksGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly AppLinks _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinksGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinks 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 AppLinksGetBySubscriptionCollectionResultOfT(AppLinks client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of AppLinksGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinksGetBySubscriptionCollectionResultOfT 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; + } + AppLinkListResult result = AppLinkListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableAppLinkSubscriptionResource.GetAppLinks"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..a618f5090acc --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationAsyncCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AvailableVersionsGetByLocationAsyncCollectionResultOfT : AsyncPageable + { + private readonly AvailableVersions _client; + private readonly Guid _subscriptionId; + private readonly AzureLocation _location; + private readonly string _kubernetesVersion; + private readonly RequestContext _context; + + /// Initializes a new instance of AvailableVersionsGetByLocationAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AvailableVersions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AvailableVersionsGetByLocationAsyncCollectionResultOfT(AvailableVersions client, Guid subscriptionId, AzureLocation location, string kubernetesVersion, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _location = location; + _kubernetesVersion = kubernetesVersion; + _context = context; + } + + /// Gets the pages of AvailableVersionsGetByLocationAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AvailableVersionsGetByLocationAsyncCollectionResultOfT 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; + } + AvailableVersionListResult result = AvailableVersionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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, _kubernetesVersion, _context) : _client.CreateGetByLocationRequest(_subscriptionId, _location, _kubernetesVersion, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableAppLinkSubscriptionResource.GetByLocation"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationCollectionResultOfT.cs new file mode 100644 index 000000000000..c61434d9916a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AvailableVersionsGetByLocationCollectionResultOfT : Pageable + { + private readonly AvailableVersions _client; + private readonly Guid _subscriptionId; + private readonly AzureLocation _location; + private readonly string _kubernetesVersion; + private readonly RequestContext _context; + + /// Initializes a new instance of AvailableVersionsGetByLocationCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AvailableVersions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AvailableVersionsGetByLocationCollectionResultOfT(AvailableVersions client, Guid subscriptionId, AzureLocation location, string kubernetesVersion, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _location = location; + _kubernetesVersion = kubernetesVersion; + _context = context; + } + + /// Gets the pages of AvailableVersionsGetByLocationCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AvailableVersionsGetByLocationCollectionResultOfT 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; + } + AvailableVersionListResult result = AvailableVersionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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, _kubernetesVersion, _context) : _client.CreateGetByLocationRequest(_subscriptionId, _location, _kubernetesVersion, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableAppLinkSubscriptionResource.GetByLocation"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..f9490c59c316 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT.cs @@ -0,0 +1,87 @@ +// 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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT : AsyncPageable + { + private readonly UpgradeHistories _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _appLinkName; + private readonly string _appLinkMemberName; + private readonly RequestContext _context; + + /// Initializes a new instance of UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The UpgradeHistories 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 name of the AppLink. + /// The name of the AppLinkMember. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT(UpgradeHistories client, Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _appLinkName = appLinkName; + _appLinkMemberName = appLinkMemberName; + _context = context; + } + + /// Gets the pages of UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT 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; + } + UpgradeHistoryListResult result = UpgradeHistoryListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByAppLinkMemberRequest(nextLink, _subscriptionId, _resourceGroupName, _appLinkName, _appLinkMemberName, _context) : _client.CreateGetByAppLinkMemberRequest(_subscriptionId, _resourceGroupName, _appLinkName, _appLinkMemberName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AppLinkMemberResource.GetByAppLinkMember"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT.cs new file mode 100644 index 000000000000..2a3cfa6abdf1 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT.cs @@ -0,0 +1,86 @@ +// 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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT : Pageable + { + private readonly UpgradeHistories _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _appLinkName; + private readonly string _appLinkMemberName; + private readonly RequestContext _context; + + /// Initializes a new instance of UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The UpgradeHistories 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 name of the AppLink. + /// The name of the AppLinkMember. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT(UpgradeHistories client, Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _appLinkName = appLinkName; + _appLinkMemberName = appLinkMemberName; + _context = context; + } + + /// Gets the pages of UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT 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; + } + UpgradeHistoryListResult result = UpgradeHistoryListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByAppLinkMemberRequest(nextLink, _subscriptionId, _resourceGroupName, _appLinkName, _appLinkMemberName, _context) : _client.CreateGetByAppLinkMemberRequest(_subscriptionId, _resourceGroupName, _appLinkName, _appLinkMemberName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AppLinkMemberResource.GetByAppLinkMember"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/AppLinkExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/AppLinkExtensions.cs new file mode 100644 index 000000000000..90d1af79c74e --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/AppLinkExtensions.cs @@ -0,0 +1,208 @@ +// 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.AppLink.Mocking; +using Azure.ResourceManager.AppLink.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink +{ + /// A class to add extension methods to Azure.ResourceManager.AppLink. + public static partial class AppLinkExtensions + { + /// + private static MockableAppLinkArmClient GetMockableAppLinkArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableAppLinkArmClient(client0, ResourceIdentifier.Root)); + } + + /// + private static MockableAppLinkResourceGroupResource GetMockableAppLinkResourceGroupResource(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient(client => new MockableAppLinkResourceGroupResource(client, resourceGroupResource.Id)); + } + + /// + private static MockableAppLinkSubscriptionResource GetMockableAppLinkSubscriptionResource(SubscriptionResource subscriptionResource) + { + return subscriptionResource.GetCachedClient(client => new MockableAppLinkSubscriptionResource(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 AppLinkResource GetAppLinkResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableAppLinkArmClient(client).GetAppLinkResource(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 AppLinkMemberResource GetAppLinkMemberResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableAppLinkArmClient(client).GetAppLinkMemberResource(id); + } + + /// + /// Gets a collection of AppLinks in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of AppLinks and their operations over a AppLinkResource. + public static AppLinkCollection GetAppLinks(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableAppLinkResourceGroupResource(resourceGroupResource).GetAppLinks(); + } + + /// + /// Get an AppLink. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetAppLinkAsync(this ResourceGroupResource resourceGroupResource, string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableAppLinkResourceGroupResource(resourceGroupResource).GetAppLinkAsync(appLinkName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get an AppLink. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetAppLink(this ResourceGroupResource resourceGroupResource, string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableAppLinkResourceGroupResource(resourceGroupResource).GetAppLink(appLinkName, cancellationToken); + } + + /// + /// List AppLink resources by subscription. + /// + /// 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 GetAppLinksAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableAppLinkSubscriptionResource(subscriptionResource).GetAppLinksAsync(cancellationToken); + } + + /// + /// List AppLink resources by subscription. + /// + /// 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 GetAppLinks(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableAppLinkSubscriptionResource(subscriptionResource).GetAppLinks(cancellationToken); + } + + /// + /// List AvailableVersion resources by location. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetByLocationAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string kubernetesVersion = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableAppLinkSubscriptionResource(subscriptionResource).GetByLocationAsync(location, kubernetesVersion, cancellationToken); + } + + /// + /// List AvailableVersion resources by location. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetByLocation(this SubscriptionResource subscriptionResource, AzureLocation location, string kubernetesVersion = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableAppLinkSubscriptionResource(subscriptionResource).GetByLocation(location, kubernetesVersion, cancellationToken); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkArmClient.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkArmClient.cs new file mode 100644 index 000000000000..47d5e9637bb9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkArmClient.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Mocking +{ + /// A class to add extension methods to . + public partial class MockableAppLinkArmClient : ArmResource + { + /// Initializes a new instance of MockableAppLinkArmClient for mocking. + protected MockableAppLinkArmClient() + { + } + + /// 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 MockableAppLinkArmClient(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 AppLinkResource GetAppLinkResource(ResourceIdentifier id) + { + AppLinkResource.ValidateResourceId(id); + return new AppLinkResource(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 AppLinkMemberResource GetAppLinkMemberResource(ResourceIdentifier id) + { + AppLinkMemberResource.ValidateResourceId(id); + return new AppLinkMemberResource(Client, id); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkResourceGroupResource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkResourceGroupResource.cs new file mode 100644 index 000000000000..713babfb64f1 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkResourceGroupResource.cs @@ -0,0 +1,99 @@ +// 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.AppLink; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink.Mocking +{ + /// A class to add extension methods to . + public partial class MockableAppLinkResourceGroupResource : ArmResource + { + /// Initializes a new instance of MockableAppLinkResourceGroupResource for mocking. + protected MockableAppLinkResourceGroupResource() + { + } + + /// 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 MockableAppLinkResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets a collection of AppLinks in the . + /// An object representing collection of AppLinks and their operations over a AppLinkResource. + public virtual AppLinkCollection GetAppLinks() + { + return GetCachedClient(client => new AppLinkCollection(client, Id)); + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAppLinkAsync(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + return await GetAppLinks().GetAsync(appLinkName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAppLink(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + return GetAppLinks().Get(appLinkName, cancellationToken); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkSubscriptionResource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkSubscriptionResource.cs new file mode 100644 index 000000000000..fd79526de546 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkSubscriptionResource.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.AppLink; +using Azure.ResourceManager.AppLink.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink.Mocking +{ + /// A class to add extension methods to . + public partial class MockableAppLinkSubscriptionResource : ArmResource + { + private ClientDiagnostics _appLinksClientDiagnostics; + private AppLinks _appLinksRestClient; + private ClientDiagnostics _availableVersionsClientDiagnostics; + private AvailableVersions _availableVersionsRestClient; + + /// Initializes a new instance of MockableAppLinkSubscriptionResource for mocking. + protected MockableAppLinkSubscriptionResource() + { + } + + /// 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 MockableAppLinkSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics AppLinksClientDiagnostics => _appLinksClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.AppLink.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private AppLinks AppLinksRestClient => _appLinksRestClient ??= new AppLinks(AppLinksClientDiagnostics, Pipeline, Endpoint, "2025-08-01-preview"); + + private ClientDiagnostics AvailableVersionsClientDiagnostics => _availableVersionsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.AppLink.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private AvailableVersions AvailableVersionsRestClient => _availableVersionsRestClient ??= new AvailableVersions(AvailableVersionsClientDiagnostics, Pipeline, Endpoint, "2025-08-01-preview"); + + /// + /// List AppLink resources by subscription. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.AppLink/appLinks. + /// + /// + /// Operation Id. + /// AppLinks_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAppLinksAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new AppLinksGetBySubscriptionAsyncCollectionResultOfT(AppLinksRestClient, Guid.Parse(Id.SubscriptionId), context), data => new AppLinkResource(Client, data)); + } + + /// + /// List AppLink resources by subscription. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.AppLink/appLinks. + /// + /// + /// Operation Id. + /// AppLinks_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAppLinks(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new AppLinksGetBySubscriptionCollectionResultOfT(AppLinksRestClient, Guid.Parse(Id.SubscriptionId), context), data => new AppLinkResource(Client, data)); + } + + /// + /// List AvailableVersion resources by location. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.AppLink/locations/{location}/availableVersions. + /// + /// + /// Operation Id. + /// AvailableVersions_ListByLocation. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetByLocationAsync(AzureLocation location, string kubernetesVersion = default, CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AvailableVersionsGetByLocationAsyncCollectionResultOfT(AvailableVersionsRestClient, Guid.Parse(Id.SubscriptionId), location, kubernetesVersion, context); + } + + /// + /// List AvailableVersion resources by location. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.AppLink/locations/{location}/availableVersions. + /// + /// + /// Operation Id. + /// AvailableVersions_ListByLocation. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetByLocation(AzureLocation location, string kubernetesVersion = default, CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AvailableVersionsGetByLocationCollectionResultOfT(AvailableVersionsRestClient, Guid.Parse(Id.SubscriptionId), location, kubernetesVersion, context); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Argument.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..110bc6be59dc --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Argument.cs @@ -0,0 +1,113 @@ +// 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.AppLink +{ + 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); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + /// The value. + /// The minimum value. + /// The maximum value. + /// The name. + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + /// The value. + /// The name. + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..5b473d8b11fb --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..2e695b0b6648 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ChangeTrackingList.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..b296171c9430 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..58c333251433 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions errorOptions) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (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 errorOptions) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ErrorResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..39cda0022153 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..15e4da7bade9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,272 @@ +// 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.Runtime.InteropServices; +using System.Text.Json; + +namespace Azure.ResourceManager.AppLink +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + /// The wire v3 options for model serialization. + internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); + /// The JSON v3 options for model serialization. + internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); + + 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); + } + + public static BinaryData GetUtf8Bytes(this JsonElement element) + { +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Optional.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..4641b9059bf9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/PageableWrapper.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..6214edd384d9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..0e7c9a73c7f4 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,60 @@ +// 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.AppLink +{ + 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); + } + + public static void UpdateQuery(this RawRequestUriBuilder builder, string name, string value) + { + string currentQuery = builder.Query; + string searchPattern = string.Concat(name, "="); + int paramStartIndex = -1; + if (currentQuery.StartsWith(string.Concat("?", searchPattern))) + { + paramStartIndex = 1; + } + if (paramStartIndex == -1) + { + string prefixedPattern = string.Concat("&", searchPattern); + int prefixedIndex = currentQuery.IndexOf(prefixedPattern); + if (prefixedIndex >= 0) + { + paramStartIndex = prefixedIndex + 1; + } + } + if (paramStartIndex >= 0) + { + int valueStartIndex = paramStartIndex + searchPattern.Length; + int valueEndIndex = currentQuery.IndexOf('&', valueStartIndex); + if (valueEndIndex == -1) + { + valueEndIndex = currentQuery.Length; + } + string beforeParam = currentQuery.Substring(0, valueStartIndex); + string afterParam = currentQuery.Substring(valueEndIndex); + string newQuery = string.Concat(beforeParam, value, afterParam); + builder.Query = newQuery; + } + else + { + builder.AppendQuery(name, value, true); + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RequestContextExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..6f16c3bf1e62 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/SerializationFormat.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..5b1e46d3d47d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/TypeFormatters.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..1b9cb8109ced --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperation.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperation.cs new file mode 100644 index 000000000000..3770e445bdd7 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperation.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.AppLink +{ + internal partial class AppLinkArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of AppLinkArmOperation for mocking. + protected AppLinkArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal AppLinkArmOperation(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 AppLinkArmOperation(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, + "AppLinkArmOperation", + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperationOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperationOfT.cs new file mode 100644 index 000000000000..a550a1c8046e --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperationOfT.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.AppLink +{ + internal partial class AppLinkArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of AppLinkArmOperation for mocking. + protected AppLinkArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal AppLinkArmOperation(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 AppLinkArmOperation(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, + "AppLinkArmOperation", + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkMemberOperationSource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkMemberOperationSource.cs new file mode 100644 index 000000000000..0ba90387735f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkMemberOperationSource.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.AppLink +{ + /// + internal partial class AppLinkMemberOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal AppLinkMemberOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + AppLinkMemberResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + AppLinkMemberData data = AppLinkMemberData.DeserializeAppLinkMemberData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AppLinkMemberResource(_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); + AppLinkMemberData data = AppLinkMemberData.DeserializeAppLinkMemberData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AppLinkMemberResource(_client, data); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkOperationSource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkOperationSource.cs new file mode 100644 index 000000000000..7f0523dc9569 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkOperationSource.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.AppLink +{ + /// + internal partial class AppLinkOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal AppLinkOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + AppLinkResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + AppLinkData data = AppLinkData.DeserializeAppLinkData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AppLinkResource(_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); + AppLinkData data = AppLinkData.DeserializeAppLinkData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AppLinkResource(_client, data); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.Serialization.cs new file mode 100644 index 000000000000..0d21a2a93663 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AppLink list operation. + internal partial class AppLinkListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkListResult 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 DeserializeAppLinkListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AppLinkListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AppLinkListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAppLinkListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(AppLinkListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (AppLinkData 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. + AppLinkListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkListResult 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(AppLinkListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkListResult DeserializeAppLinkListResult(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(AppLinkData.DeserializeAppLinkData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.cs new file mode 100644 index 000000000000..68a84fa2d4dd --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AppLink list operation. + internal partial class AppLinkListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The AppLink items on this page. + internal AppLinkListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The AppLink items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal AppLinkListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The AppLink items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.Serialization.cs new file mode 100644 index 000000000000..2dcbdd836032 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AppLinkMember list operation. + internal partial class AppLinkMemberListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkMemberListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkMemberListResult 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 DeserializeAppLinkMemberListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkMemberListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkMemberListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AppLinkMemberListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AppLinkMemberListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAppLinkMemberListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(AppLinkMemberListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (AppLinkMemberData 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. + AppLinkMemberListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkMemberListResult 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(AppLinkMemberListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkMemberListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkMemberListResult DeserializeAppLinkMemberListResult(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(AppLinkMemberData.DeserializeAppLinkMemberData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkMemberListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.cs new file mode 100644 index 000000000000..d56795a80979 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AppLinkMember list operation. + internal partial class AppLinkMemberListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The AppLinkMember items on this page. + internal AppLinkMemberListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The AppLinkMember items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal AppLinkMemberListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The AppLinkMember items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.Serialization.cs new file mode 100644 index 000000000000..86c4557e7488 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.Serialization.cs @@ -0,0 +1,225 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink Member properties. + public partial class AppLinkMemberProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkMemberProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkMemberProperties 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 DeserializeAppLinkMemberProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkMemberProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkMemberProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AppLinkMemberProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(AppLinkMemberProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ClusterType)) + { + writer.WritePropertyName("clusterType"u8); + writer.WriteStringValue(ClusterType.Value.ToString()); + } + writer.WritePropertyName("metadata"u8); + writer.WriteObjectValue(Metadata, options); + if (Optional.IsDefined(UpgradeProfile)) + { + writer.WritePropertyName("upgradeProfile"u8); + writer.WriteObjectValue(UpgradeProfile, options); + } + if (Optional.IsDefined(ObservabilityProfile)) + { + writer.WritePropertyName("observabilityProfile"u8); + writer.WriteObjectValue(ObservabilityProfile, options); + } + if (Optional.IsDefined(ConnectivityProfile)) + { + writer.WritePropertyName("connectivityProfile"u8); + writer.WriteObjectValue(ConnectivityProfile, options); + } + 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. + AppLinkMemberProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkMemberProperties 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(AppLinkMemberProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkMemberProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkMemberProperties DeserializeAppLinkMemberProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ClusterType? clusterType = default; + Metadata metadata = default; + UpgradeProfile upgradeProfile = default; + ObservabilityProfile observabilityProfile = default; + ConnectivityProfile connectivityProfile = default; + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("clusterType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + clusterType = new ClusterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + metadata = Metadata.DeserializeMetadata(prop.Value, options); + continue; + } + if (prop.NameEquals("upgradeProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + upgradeProfile = UpgradeProfile.DeserializeUpgradeProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("observabilityProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + observabilityProfile = ObservabilityProfile.DeserializeObservabilityProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("connectivityProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectivityProfile = ConnectivityProfile.DeserializeConnectivityProfile(prop.Value, options); + 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 AppLinkMemberProperties( + clusterType, + metadata, + upgradeProfile, + observabilityProfile, + connectivityProfile, + provisioningState, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.cs new file mode 100644 index 000000000000..8d08bfcc1292 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.cs @@ -0,0 +1,90 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink Member properties. + public partial class AppLinkMemberProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Resource ID. + /// is null. + public AppLinkMemberProperties(ResourceIdentifier metadataResourceId) + { + Argument.AssertNotNull(metadataResourceId, nameof(metadataResourceId)); + + Metadata = new Metadata(metadataResourceId); + } + + /// Initializes a new instance of . + /// Cluster type. + /// AppLink Member Metadata. + /// Upgrade profile. + /// Observability profile. + /// Connectivity profile. + /// Provisioning state. + /// Keeps track of any properties unknown to the library. + internal AppLinkMemberProperties(ClusterType? clusterType, Metadata metadata, UpgradeProfile upgradeProfile, ObservabilityProfile observabilityProfile, ConnectivityProfile connectivityProfile, ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + ClusterType = clusterType; + Metadata = metadata; + UpgradeProfile = upgradeProfile; + ObservabilityProfile = observabilityProfile; + ConnectivityProfile = connectivityProfile; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Cluster type. + public ClusterType? ClusterType { get; set; } + + /// AppLink Member Metadata. + internal Metadata Metadata { get; set; } + + /// Upgrade profile. + public UpgradeProfile UpgradeProfile { get; set; } + + /// Observability profile. + internal ObservabilityProfile ObservabilityProfile { get; set; } + + /// Connectivity profile. + public ConnectivityProfile ConnectivityProfile { get; set; } + + /// Provisioning state. + public ProvisioningState? ProvisioningState { get; } + + /// Resource ID. + public ResourceIdentifier MetadataResourceId + { + get + { + return Metadata is null ? default : Metadata.ResourceId; + } + set + { + Metadata = new Metadata(value); + } + } + + /// Metrics endpoint URL. + public string ObservabilityMetricsEndpoint + { + get + { + return ObservabilityProfile is null ? default : ObservabilityProfile.MetricsEndpoint; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.Serialization.cs new file mode 100644 index 000000000000..ab7e6afe958a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.Serialization.cs @@ -0,0 +1,145 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink properties. + internal partial class AppLinkProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkProperties 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 DeserializeAppLinkProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AppLinkProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(AppLinkProperties)} does not support writing '{format}' format."); + } + 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. + AppLinkProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkProperties 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(AppLinkProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkProperties DeserializeAppLinkProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = 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 (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkProperties(provisioningState, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.cs new file mode 100644 index 000000000000..17640122e25a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.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.AppLink.Models +{ + /// AppLink properties. + internal partial class AppLinkProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AppLinkProperties() + { + } + + /// Initializes a new instance of . + /// Provisioning state. + /// Keeps track of any properties unknown to the library. + internal AppLinkProperties(ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Provisioning state. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.Serialization.cs new file mode 100644 index 000000000000..419df320fc68 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.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; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.AppLink; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink available version resource. + public partial class AvailableVersion : ResourceData, IJsonModel + { + /// 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 DeserializeAvailableVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AvailableVersion)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AvailableVersion)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AvailableVersion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AvailableVersion)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(AvailableVersion)} 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. + AvailableVersion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AvailableVersion)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(AvailableVersion)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAvailableVersion(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AvailableVersion DeserializeAvailableVersion(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(); + AvailableVersionProperties 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, AzureResourceManagerAppLinkContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AvailableVersionProperties.DeserializeAvailableVersionProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AvailableVersion( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.cs new file mode 100644 index 000000000000..3245f3fecf4f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.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.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink available version resource. + public partial class AvailableVersion : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal AvailableVersion() + { + } + + /// 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 AvailableVersion(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, AvailableVersionProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public AvailableVersionProperties Properties { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.Serialization.cs new file mode 100644 index 000000000000..a608a3970d2e --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AvailableVersion list operation. + internal partial class AvailableVersionListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AvailableVersionListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AvailableVersionListResult 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 DeserializeAvailableVersionListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AvailableVersionListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AvailableVersionListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AvailableVersionListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AvailableVersionListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAvailableVersionListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(AvailableVersionListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (AvailableVersion 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. + AvailableVersionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AvailableVersionListResult 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(AvailableVersionListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAvailableVersionListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AvailableVersionListResult DeserializeAvailableVersionListResult(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(AvailableVersion.DeserializeAvailableVersion(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AvailableVersionListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.cs new file mode 100644 index 000000000000..8bcb876a7a5d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AvailableVersion list operation. + internal partial class AvailableVersionListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The AvailableVersion items on this page. + internal AvailableVersionListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The AvailableVersion items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal AvailableVersionListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The AvailableVersion items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.Serialization.cs new file mode 100644 index 000000000000..816c2d1016ac --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.Serialization.cs @@ -0,0 +1,174 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink available version properties. + public partial class AvailableVersionProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AvailableVersionProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AvailableVersionProperties 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 DeserializeAvailableVersionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AvailableVersionProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AvailableVersionProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AvailableVersionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(AvailableVersionProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kubernetesVersion"u8); + writer.WriteStringValue(KubernetesVersion); + writer.WritePropertyName("fullyManagedVersions"u8); + writer.WriteObjectValue(FullyManagedVersions, options); + writer.WritePropertyName("selfManagedVersions"u8); + writer.WriteObjectValue(SelfManagedVersions, options); + 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. + AvailableVersionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AvailableVersionProperties 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(AvailableVersionProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAvailableVersionProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AvailableVersionProperties DeserializeAvailableVersionProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string kubernetesVersion = default; + FullyManagedVersions fullyManagedVersions = default; + SelfManagedVersions selfManagedVersions = default; + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kubernetesVersion"u8)) + { + kubernetesVersion = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("fullyManagedVersions"u8)) + { + fullyManagedVersions = FullyManagedVersions.DeserializeFullyManagedVersions(prop.Value, options); + continue; + } + if (prop.NameEquals("selfManagedVersions"u8)) + { + selfManagedVersions = Models.SelfManagedVersions.DeserializeSelfManagedVersions(prop.Value, options); + 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 AvailableVersionProperties(kubernetesVersion, fullyManagedVersions, selfManagedVersions, provisioningState, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.cs new file mode 100644 index 000000000000..d845462ec7df --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink available version properties. + public partial class AvailableVersionProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Kubernetes version. + /// Fully managed versions. + /// Self managed versions. + internal AvailableVersionProperties(string kubernetesVersion, FullyManagedVersions fullyManagedVersions, SelfManagedVersions selfManagedVersions) + { + KubernetesVersion = kubernetesVersion; + FullyManagedVersions = fullyManagedVersions; + SelfManagedVersions = selfManagedVersions; + } + + /// Initializes a new instance of . + /// Kubernetes version. + /// Fully managed versions. + /// Self managed versions. + /// Provisioning state. + /// Keeps track of any properties unknown to the library. + internal AvailableVersionProperties(string kubernetesVersion, FullyManagedVersions fullyManagedVersions, SelfManagedVersions selfManagedVersions, ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + KubernetesVersion = kubernetesVersion; + FullyManagedVersions = fullyManagedVersions; + SelfManagedVersions = selfManagedVersions; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Kubernetes version. + public string KubernetesVersion { get; } + + /// Fully managed versions. + internal FullyManagedVersions FullyManagedVersions { get; } + + /// Self managed versions. + internal SelfManagedVersions SelfManagedVersions { get; } + + /// Provisioning state. + public ProvisioningState? ProvisioningState { get; } + + /// Release channels. + public IList FullyManagedVersionsReleaseChannels + { + get + { + return FullyManagedVersions is null ? default : FullyManagedVersions.ReleaseChannels; + } + } + + /// Istio versions. + public IList SelfManagedVersions + { + get + { + return this.SelfManagedVersions is null ? default : SelfManagedVersions.Versions; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AzureResourceManagerAppLinkContext.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AzureResourceManagerAppLinkContext.cs new file mode 100644 index 000000000000..5bca7a2c0d6d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AzureResourceManagerAppLinkContext.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(AppLinkData))] + [ModelReaderWriterBuildable(typeof(AppLinkListResult))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberData))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberListResult))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberProperties))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberResource))] + [ModelReaderWriterBuildable(typeof(AppLinkProperties))] + [ModelReaderWriterBuildable(typeof(AppLinkResource))] + [ModelReaderWriterBuildable(typeof(AvailableVersion))] + [ModelReaderWriterBuildable(typeof(AvailableVersionListResult))] + [ModelReaderWriterBuildable(typeof(AvailableVersionProperties))] + [ModelReaderWriterBuildable(typeof(ConnectivityProfile))] + [ModelReaderWriterBuildable(typeof(EastWestGatewayProfile))] + [ModelReaderWriterBuildable(typeof(FullyManagedUpgradeProfile))] + [ModelReaderWriterBuildable(typeof(FullyManagedVersions))] + [ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))] + [ModelReaderWriterBuildable(typeof(Metadata))] + [ModelReaderWriterBuildable(typeof(MetricsProfile))] + [ModelReaderWriterBuildable(typeof(ObservabilityProfile))] + [ModelReaderWriterBuildable(typeof(PrivateConnectProfile))] + [ModelReaderWriterBuildable(typeof(ReleaseChannelInfo))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(SelfManagedUpgradeProfile))] + [ModelReaderWriterBuildable(typeof(SelfManagedVersions))] + [ModelReaderWriterBuildable(typeof(SystemData))] + [ModelReaderWriterBuildable(typeof(UpgradeHistory))] + [ModelReaderWriterBuildable(typeof(UpgradeHistoryListResult))] + [ModelReaderWriterBuildable(typeof(UpgradeHistoryProperties))] + [ModelReaderWriterBuildable(typeof(UpgradeProfile))] + [ModelReaderWriterBuildable(typeof(UserAssignedIdentity))] + [ModelReaderWriterBuildable(typeof(VersionInfo))] + public partial class AzureResourceManagerAppLinkContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ClusterType.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ClusterType.cs new file mode 100644 index 000000000000..0cca96bd6ac1 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ClusterType.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember cluster type. + public readonly partial struct ClusterType : IEquatable + { + private readonly string _value; + /// Azure Kubernetes Service. + private const string AKSValue = "AKS"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ClusterType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Azure Kubernetes Service. + public static ClusterType AKS { get; } = new ClusterType(AKSValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ClusterType left, ClusterType 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 !=(ClusterType left, ClusterType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ClusterType(string value) => new ClusterType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ClusterType?(string value) => value == null ? null : new ClusterType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ClusterType other && Equals(other); + + /// + public bool Equals(ClusterType 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.Serialization.cs new file mode 100644 index 000000000000..ee63f2ecfed8 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.Serialization.cs @@ -0,0 +1,160 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember connectivity profile. + public partial class ConnectivityProfile : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ConnectivityProfile 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 DeserializeConnectivityProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectivityProfile)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(ConnectivityProfile)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ConnectivityProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(ConnectivityProfile)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(EastWestGateway)) + { + writer.WritePropertyName("eastWestGateway"u8); + writer.WriteObjectValue(EastWestGateway, options); + } + if (Optional.IsDefined(PrivateConnect)) + { + writer.WritePropertyName("privateConnect"u8); + writer.WriteObjectValue(PrivateConnect, options); + } + 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. + ConnectivityProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ConnectivityProfile 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(ConnectivityProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectivityProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ConnectivityProfile DeserializeConnectivityProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EastWestGatewayProfile eastWestGateway = default; + PrivateConnectProfile privateConnect = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("eastWestGateway"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + eastWestGateway = EastWestGatewayProfile.DeserializeEastWestGatewayProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("privateConnect"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateConnect = PrivateConnectProfile.DeserializePrivateConnectProfile(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ConnectivityProfile(eastWestGateway, privateConnect, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.cs new file mode 100644 index 000000000000..6e24b2386760 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember connectivity profile. + public partial class ConnectivityProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ConnectivityProfile() + { + } + + /// Initializes a new instance of . + /// East-West gateway profile. + /// Private connect profile. + /// Keeps track of any properties unknown to the library. + internal ConnectivityProfile(EastWestGatewayProfile eastWestGateway, PrivateConnectProfile privateConnect, IDictionary additionalBinaryDataProperties) + { + EastWestGateway = eastWestGateway; + PrivateConnect = privateConnect; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// East-West gateway profile. + internal EastWestGatewayProfile EastWestGateway { get; set; } + + /// Private connect profile. + internal PrivateConnectProfile PrivateConnect { get; set; } + + /// East-West gateway visibility. + public EastWestGatewayVisibility? EastWestGatewayVisibility + { + get + { + return EastWestGateway is null ? default : EastWestGateway.Visibility; + } + set + { + EastWestGateway = value.HasValue ? new EastWestGatewayProfile(value.Value) : default; + } + } + + /// Delegated Subnet to AppLink. + public ResourceIdentifier PrivateConnectSubnetResourceId + { + get + { + return PrivateConnect is null ? default : PrivateConnect.SubnetResourceId; + } + set + { + PrivateConnect = new PrivateConnectProfile(value); + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.Serialization.cs new file mode 100644 index 000000000000..60198ec17162 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.Serialization.cs @@ -0,0 +1,143 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember east-west gateway profile. + internal partial class EastWestGatewayProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EastWestGatewayProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EastWestGatewayProfile 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 DeserializeEastWestGatewayProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EastWestGatewayProfile)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(EastWestGatewayProfile)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + EastWestGatewayProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(EastWestGatewayProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("visibility"u8); + writer.WriteStringValue(Visibility.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. + EastWestGatewayProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EastWestGatewayProfile 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(EastWestGatewayProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEastWestGatewayProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EastWestGatewayProfile DeserializeEastWestGatewayProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EastWestGatewayVisibility visibility = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("visibility"u8)) + { + visibility = new EastWestGatewayVisibility(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EastWestGatewayProfile(visibility, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.cs new file mode 100644 index 000000000000..651a45c23597 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.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.AppLink.Models +{ + /// AppLinkMember east-west gateway profile. + internal partial class EastWestGatewayProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// East-West gateway visibility. + public EastWestGatewayProfile(EastWestGatewayVisibility visibility) + { + Visibility = visibility; + } + + /// Initializes a new instance of . + /// East-West gateway visibility. + /// Keeps track of any properties unknown to the library. + internal EastWestGatewayProfile(EastWestGatewayVisibility visibility, IDictionary additionalBinaryDataProperties) + { + Visibility = visibility; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// East-West gateway visibility. + public EastWestGatewayVisibility Visibility { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayVisibility.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayVisibility.cs new file mode 100644 index 000000000000..35f62414685a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayVisibility.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// East-West gateway visibility. + public readonly partial struct EastWestGatewayVisibility : IEquatable + { + private readonly string _value; + /// Use an internal load balancer for the east-west gateway. + private const string InternalValue = "Internal"; + /// Use an external load balancer for the east-west gateway. + private const string ExternalValue = "External"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EastWestGatewayVisibility(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Use an internal load balancer for the east-west gateway. + public static EastWestGatewayVisibility Internal { get; } = new EastWestGatewayVisibility(InternalValue); + + /// Use an external load balancer for the east-west gateway. + public static EastWestGatewayVisibility External { get; } = new EastWestGatewayVisibility(ExternalValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EastWestGatewayVisibility left, EastWestGatewayVisibility 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 !=(EastWestGatewayVisibility left, EastWestGatewayVisibility right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EastWestGatewayVisibility(string value) => new EastWestGatewayVisibility(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EastWestGatewayVisibility?(string value) => value == null ? null : new EastWestGatewayVisibility(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EastWestGatewayVisibility other && Equals(other); + + /// + public bool Equals(EastWestGatewayVisibility 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.Serialization.cs new file mode 100644 index 000000000000..235096ec3c25 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.Serialization.cs @@ -0,0 +1,143 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember fully managed upgrade profile. + internal partial class FullyManagedUpgradeProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal FullyManagedUpgradeProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FullyManagedUpgradeProfile 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 DeserializeFullyManagedUpgradeProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FullyManagedUpgradeProfile)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(FullyManagedUpgradeProfile)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + FullyManagedUpgradeProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(FullyManagedUpgradeProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("releaseChannel"u8); + writer.WriteStringValue(ReleaseChannel.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. + FullyManagedUpgradeProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FullyManagedUpgradeProfile 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(FullyManagedUpgradeProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFullyManagedUpgradeProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FullyManagedUpgradeProfile DeserializeFullyManagedUpgradeProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpgradeReleaseChannel releaseChannel = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("releaseChannel"u8)) + { + releaseChannel = new UpgradeReleaseChannel(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FullyManagedUpgradeProfile(releaseChannel, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.cs new file mode 100644 index 000000000000..199e15c4de50 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.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.AppLink.Models +{ + /// AppLinkMember fully managed upgrade profile. + internal partial class FullyManagedUpgradeProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Release channel. + public FullyManagedUpgradeProfile(UpgradeReleaseChannel releaseChannel) + { + ReleaseChannel = releaseChannel; + } + + /// Initializes a new instance of . + /// Release channel. + /// Keeps track of any properties unknown to the library. + internal FullyManagedUpgradeProfile(UpgradeReleaseChannel releaseChannel, IDictionary additionalBinaryDataProperties) + { + ReleaseChannel = releaseChannel; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Release channel. + public UpgradeReleaseChannel ReleaseChannel { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.Serialization.cs new file mode 100644 index 000000000000..2b0e48068d38 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.Serialization.cs @@ -0,0 +1,153 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Fully managed versions. + internal partial class FullyManagedVersions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal FullyManagedVersions() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FullyManagedVersions 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 DeserializeFullyManagedVersions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FullyManagedVersions)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(FullyManagedVersions)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + FullyManagedVersions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(FullyManagedVersions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("releaseChannels"u8); + writer.WriteStartArray(); + foreach (ReleaseChannelInfo item in ReleaseChannels) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + 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. + FullyManagedVersions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FullyManagedVersions 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(FullyManagedVersions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFullyManagedVersions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FullyManagedVersions DeserializeFullyManagedVersions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList releaseChannels = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("releaseChannels"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ReleaseChannelInfo.DeserializeReleaseChannelInfo(item, options)); + } + releaseChannels = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FullyManagedVersions(releaseChannels, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.cs new file mode 100644 index 000000000000..c90441a9b9be --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Fully managed versions. + internal partial class FullyManagedVersions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Release channels. + internal FullyManagedVersions(IEnumerable releaseChannels) + { + ReleaseChannels = releaseChannels.ToList(); + } + + /// Initializes a new instance of . + /// Release channels. + /// Keeps track of any properties unknown to the library. + internal FullyManagedVersions(IList releaseChannels, IDictionary additionalBinaryDataProperties) + { + ReleaseChannels = releaseChannels; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Release channels. + public IList ReleaseChannels { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.Serialization.cs new file mode 100644 index 000000000000..cd41b1cff662 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.Serialization.cs @@ -0,0 +1,144 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember metadata. + internal partial class Metadata : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Metadata() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Metadata 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 DeserializeMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Metadata)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(Metadata)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + Metadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(Metadata)} does not support writing '{format}' format."); + } + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + 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. + Metadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Metadata 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(Metadata)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetadata(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Metadata DeserializeMetadata(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier resourceId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("resourceId"u8)) + { + resourceId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Metadata(resourceId, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.cs new file mode 100644 index 000000000000..03415796f3dd --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember metadata. + internal partial class Metadata + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Resource ID. + /// is null. + public Metadata(ResourceIdentifier resourceId) + { + Argument.AssertNotNull(resourceId, nameof(resourceId)); + + ResourceId = resourceId; + } + + /// Initializes a new instance of . + /// Resource ID. + /// Keeps track of any properties unknown to the library. + internal Metadata(ResourceIdentifier resourceId, IDictionary additionalBinaryDataProperties) + { + ResourceId = resourceId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Resource ID. + public ResourceIdentifier ResourceId { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.Serialization.cs new file mode 100644 index 000000000000..050c7702817f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember metrics profile. + internal partial class MetricsProfile : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricsProfile 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 DeserializeMetricsProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricsProfile)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(MetricsProfile)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + MetricsProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(MetricsProfile)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(MetricsEndpoint)) + { + writer.WritePropertyName("metricsEndpoint"u8); + writer.WriteStringValue(MetricsEndpoint); + } + 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. + MetricsProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricsProfile 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(MetricsProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricsProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricsProfile DeserializeMetricsProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string metricsEndpoint = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metricsEndpoint"u8)) + { + metricsEndpoint = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MetricsProfile(metricsEndpoint, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.cs new file mode 100644 index 000000000000..5361e9b10d2d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.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.AppLink.Models +{ + /// AppLinkMember metrics profile. + internal partial class MetricsProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public MetricsProfile() + { + } + + /// Initializes a new instance of . + /// Metrics endpoint URL. + /// Keeps track of any properties unknown to the library. + internal MetricsProfile(string metricsEndpoint, IDictionary additionalBinaryDataProperties) + { + MetricsEndpoint = metricsEndpoint; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Metrics endpoint URL. + public string MetricsEndpoint { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.Serialization.cs new file mode 100644 index 000000000000..e54b8ed92f1a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.Serialization.cs @@ -0,0 +1,145 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember observability profile. + internal partial class ObservabilityProfile : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ObservabilityProfile 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 DeserializeObservabilityProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ObservabilityProfile)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(ObservabilityProfile)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ObservabilityProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(ObservabilityProfile)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Metrics)) + { + writer.WritePropertyName("metrics"u8); + writer.WriteObjectValue(Metrics, options); + } + 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. + ObservabilityProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ObservabilityProfile 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(ObservabilityProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeObservabilityProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ObservabilityProfile DeserializeObservabilityProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MetricsProfile metrics = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metrics"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + metrics = MetricsProfile.DeserializeMetricsProfile(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ObservabilityProfile(metrics, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.cs new file mode 100644 index 000000000000..52fa0d12f4d8 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.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.AppLink.Models +{ + /// AppLinkMember observability profile. + internal partial class ObservabilityProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ObservabilityProfile() + { + } + + /// Initializes a new instance of . + /// Metrics configuration. + /// Keeps track of any properties unknown to the library. + internal ObservabilityProfile(MetricsProfile metrics, IDictionary additionalBinaryDataProperties) + { + Metrics = metrics; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Metrics configuration. + internal MetricsProfile Metrics { get; set; } + + /// Metrics endpoint URL. + public string MetricsEndpoint + { + get + { + return Metrics is null ? default : Metrics.MetricsEndpoint; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.Serialization.cs new file mode 100644 index 000000000000..9804bd575c29 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.Serialization.cs @@ -0,0 +1,144 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember private connect profile. + internal partial class PrivateConnectProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PrivateConnectProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PrivateConnectProfile 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 DeserializePrivateConnectProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrivateConnectProfile)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateConnectProfile)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + PrivateConnectProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(PrivateConnectProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("subnetResourceId"u8); + writer.WriteStringValue(SubnetResourceId); + 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. + PrivateConnectProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PrivateConnectProfile 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(PrivateConnectProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrivateConnectProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PrivateConnectProfile DeserializePrivateConnectProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier subnetResourceId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("subnetResourceId"u8)) + { + subnetResourceId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PrivateConnectProfile(subnetResourceId, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.cs new file mode 100644 index 000000000000..885d35b9e89e --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember private connect profile. + internal partial class PrivateConnectProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Delegated Subnet to AppLink. + /// is null. + public PrivateConnectProfile(ResourceIdentifier subnetResourceId) + { + Argument.AssertNotNull(subnetResourceId, nameof(subnetResourceId)); + + SubnetResourceId = subnetResourceId; + } + + /// Initializes a new instance of . + /// Delegated Subnet to AppLink. + /// Keeps track of any properties unknown to the library. + internal PrivateConnectProfile(ResourceIdentifier subnetResourceId, IDictionary additionalBinaryDataProperties) + { + SubnetResourceId = subnetResourceId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Delegated Subnet to AppLink. + public ResourceIdentifier SubnetResourceId { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ProvisioningState.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..1a3722d94d26 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Provisioning state of the resource. + 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"; + /// Resource is getting provisioned. + private const string ProvisioningValue = "Provisioning"; + /// Resource is Updating. + private const string UpdatingValue = "Updating"; + /// Resource is Deleting. + private const string DeletingValue = "Deleting"; + /// Resource has been Accepted. + 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); + + /// Resource is getting provisioned. + public static ProvisioningState Provisioning { get; } = new ProvisioningState(ProvisioningValue); + + /// Resource is Updating. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + + /// Resource is Deleting. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + + /// Resource has been 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.Serialization.cs new file mode 100644 index 000000000000..18f6a7fbdba7 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.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.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Release channel information. + public partial class ReleaseChannelInfo : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ReleaseChannelInfo() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ReleaseChannelInfo 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 DeserializeReleaseChannelInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ReleaseChannelInfo)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(ReleaseChannelInfo)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ReleaseChannelInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(ReleaseChannelInfo)} does not support writing '{format}' format."); + } + writer.WritePropertyName("releaseChannel"u8); + writer.WriteStringValue(ReleaseChannel); + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + 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. + ReleaseChannelInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ReleaseChannelInfo 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(ReleaseChannelInfo)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeReleaseChannelInfo(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ReleaseChannelInfo DeserializeReleaseChannelInfo(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string releaseChannel = default; + string version = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("releaseChannel"u8)) + { + releaseChannel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ReleaseChannelInfo(releaseChannel, version, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.cs new file mode 100644 index 000000000000..54d0e97dc5f9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.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.AppLink.Models +{ + /// Release channel information. + public partial class ReleaseChannelInfo + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Release channel. + /// Istio version behind release channel. + internal ReleaseChannelInfo(string releaseChannel, string version) + { + ReleaseChannel = releaseChannel; + Version = version; + } + + /// Initializes a new instance of . + /// Release channel. + /// Istio version behind release channel. + /// Keeps track of any properties unknown to the library. + internal ReleaseChannelInfo(string releaseChannel, string version, IDictionary additionalBinaryDataProperties) + { + ReleaseChannel = releaseChannel; + Version = version; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Release channel. + public string ReleaseChannel { get; } + + /// Istio version behind release channel. + public string Version { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.Serialization.cs new file mode 100644 index 000000000000..b0bb3e1e2366 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.Serialization.cs @@ -0,0 +1,143 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember self managed upgrade profile. + internal partial class SelfManagedUpgradeProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SelfManagedUpgradeProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfManagedUpgradeProfile 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 DeserializeSelfManagedUpgradeProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfManagedUpgradeProfile)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(SelfManagedUpgradeProfile)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SelfManagedUpgradeProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(SelfManagedUpgradeProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + 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. + SelfManagedUpgradeProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfManagedUpgradeProfile 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(SelfManagedUpgradeProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfManagedUpgradeProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfManagedUpgradeProfile DeserializeSelfManagedUpgradeProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string version = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SelfManagedUpgradeProfile(version, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.cs new file mode 100644 index 000000000000..cd20ebc414b9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember self managed upgrade profile. + internal partial class SelfManagedUpgradeProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Istio version. + /// is null. + public SelfManagedUpgradeProfile(string version) + { + Argument.AssertNotNull(version, nameof(version)); + + Version = version; + } + + /// Initializes a new instance of . + /// Istio version. + /// Keeps track of any properties unknown to the library. + internal SelfManagedUpgradeProfile(string version, IDictionary additionalBinaryDataProperties) + { + Version = version; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Istio version. + public string Version { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.Serialization.cs new file mode 100644 index 000000000000..d05eef32081f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.Serialization.cs @@ -0,0 +1,153 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Self managed versions. + internal partial class SelfManagedVersions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SelfManagedVersions() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfManagedVersions 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 DeserializeSelfManagedVersions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfManagedVersions)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(SelfManagedVersions)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SelfManagedVersions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(SelfManagedVersions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("versions"u8); + writer.WriteStartArray(); + foreach (VersionInfo item in Versions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + 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. + SelfManagedVersions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfManagedVersions 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(SelfManagedVersions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfManagedVersions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfManagedVersions DeserializeSelfManagedVersions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList versions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("versions"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(VersionInfo.DeserializeVersionInfo(item, options)); + } + versions = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SelfManagedVersions(versions, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.cs new file mode 100644 index 000000000000..fbd6a9fd0c68 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Self managed versions. + internal partial class SelfManagedVersions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Istio versions. + internal SelfManagedVersions(IEnumerable versions) + { + Versions = versions.ToList(); + } + + /// Initializes a new instance of . + /// Istio versions. + /// Keeps track of any properties unknown to the library. + internal SelfManagedVersions(IList versions, IDictionary additionalBinaryDataProperties) + { + Versions = versions; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Istio versions. + public IList Versions { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.Serialization.cs new file mode 100644 index 000000000000..2e49aed3b37d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.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; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.AppLink; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade history. + public partial class UpgradeHistory : ResourceData, IJsonModel + { + /// 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 DeserializeUpgradeHistory(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpgradeHistory)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(UpgradeHistory)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + UpgradeHistory IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UpgradeHistory)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(UpgradeHistory)} 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. + UpgradeHistory IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (UpgradeHistory)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(UpgradeHistory)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpgradeHistory(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpgradeHistory DeserializeUpgradeHistory(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(); + UpgradeHistoryProperties 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, AzureResourceManagerAppLinkContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = UpgradeHistoryProperties.DeserializeUpgradeHistoryProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UpgradeHistory( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.cs new file mode 100644 index 000000000000..ff9a544bb6fd --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.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.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade history. + public partial class UpgradeHistory : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal UpgradeHistory() + { + } + + /// 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 UpgradeHistory(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, UpgradeHistoryProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public UpgradeHistoryProperties Properties { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.Serialization.cs new file mode 100644 index 000000000000..33ff9e207ec6 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a UpgradeHistory list operation. + internal partial class UpgradeHistoryListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UpgradeHistoryListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UpgradeHistoryListResult 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 DeserializeUpgradeHistoryListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpgradeHistoryListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(UpgradeHistoryListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + UpgradeHistoryListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static UpgradeHistoryListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpgradeHistoryListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(UpgradeHistoryListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (UpgradeHistory 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. + UpgradeHistoryListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UpgradeHistoryListResult 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(UpgradeHistoryListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpgradeHistoryListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpgradeHistoryListResult DeserializeUpgradeHistoryListResult(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(UpgradeHistory.DeserializeUpgradeHistory(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UpgradeHistoryListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.cs new file mode 100644 index 000000000000..7dd3cece2f73 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a UpgradeHistory list operation. + internal partial class UpgradeHistoryListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The UpgradeHistory items on this page. + internal UpgradeHistoryListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The UpgradeHistory items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal UpgradeHistoryListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The UpgradeHistory items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.Serialization.cs new file mode 100644 index 000000000000..97647e5bbe0a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.Serialization.cs @@ -0,0 +1,204 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade history properties. + public partial class UpgradeHistoryProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UpgradeHistoryProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UpgradeHistoryProperties 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 DeserializeUpgradeHistoryProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpgradeHistoryProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(UpgradeHistoryProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + UpgradeHistoryProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(UpgradeHistoryProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("startTimestamp"u8); + writer.WriteStringValue(StartTimestamp, "O"); + if (Optional.IsDefined(EndTimestamp)) + { + writer.WritePropertyName("endTimestamp"u8); + writer.WriteStringValue(EndTimestamp.Value, "O"); + } + writer.WritePropertyName("initiatedBy"u8); + writer.WriteStringValue(InitiatedBy); + writer.WritePropertyName("fromVersion"u8); + writer.WriteStringValue(FromVersion); + writer.WritePropertyName("toVersion"u8); + writer.WriteStringValue(ToVersion); + 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. + UpgradeHistoryProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UpgradeHistoryProperties 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(UpgradeHistoryProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpgradeHistoryProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpgradeHistoryProperties DeserializeUpgradeHistoryProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset startTimestamp = default; + DateTimeOffset? endTimestamp = default; + string initiatedBy = default; + string fromVersion = default; + string toVersion = default; + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("startTimestamp"u8)) + { + startTimestamp = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("endTimestamp"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endTimestamp = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("initiatedBy"u8)) + { + initiatedBy = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("fromVersion"u8)) + { + fromVersion = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("toVersion"u8)) + { + toVersion = 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 UpgradeHistoryProperties( + startTimestamp, + endTimestamp, + initiatedBy, + fromVersion, + toVersion, + provisioningState, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.cs new file mode 100644 index 000000000000..ba5450655253 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade history properties. + public partial class UpgradeHistoryProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Start timestamp. + /// Upgrade initiator. + /// Version upgraded from. + /// Version upgraded to. + internal UpgradeHistoryProperties(DateTimeOffset startTimestamp, string initiatedBy, string fromVersion, string toVersion) + { + StartTimestamp = startTimestamp; + InitiatedBy = initiatedBy; + FromVersion = fromVersion; + ToVersion = toVersion; + } + + /// Initializes a new instance of . + /// Start timestamp. + /// End timestamp. + /// Upgrade initiator. + /// Version upgraded from. + /// Version upgraded to. + /// Provisioning state. + /// Keeps track of any properties unknown to the library. + internal UpgradeHistoryProperties(DateTimeOffset startTimestamp, DateTimeOffset? endTimestamp, string initiatedBy, string fromVersion, string toVersion, ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + StartTimestamp = startTimestamp; + EndTimestamp = endTimestamp; + InitiatedBy = initiatedBy; + FromVersion = fromVersion; + ToVersion = toVersion; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Start timestamp. + public DateTimeOffset StartTimestamp { get; } + + /// End timestamp. + public DateTimeOffset? EndTimestamp { get; } + + /// Upgrade initiator. + public string InitiatedBy { get; } + + /// Version upgraded from. + public string FromVersion { get; } + + /// Version upgraded to. + public string ToVersion { get; } + + /// Provisioning state. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeMode.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeMode.cs new file mode 100644 index 000000000000..024e7f906d3f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeMode.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade mode. + public readonly partial struct UpgradeMode : IEquatable + { + private readonly string _value; + /// Fully managed upgrade mode. + private const string FullyManagedValue = "FullyManaged"; + /// Self managed upgrade mode. + private const string SelfManagedValue = "SelfManaged"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public UpgradeMode(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Fully managed upgrade mode. + public static UpgradeMode FullyManaged { get; } = new UpgradeMode(FullyManagedValue); + + /// Self managed upgrade mode. + public static UpgradeMode SelfManaged { get; } = new UpgradeMode(SelfManagedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(UpgradeMode left, UpgradeMode 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 !=(UpgradeMode left, UpgradeMode right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator UpgradeMode(string value) => new UpgradeMode(value); + + /// Converts a string to a . + /// The value. + public static implicit operator UpgradeMode?(string value) => value == null ? null : new UpgradeMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is UpgradeMode other && Equals(other); + + /// + public bool Equals(UpgradeMode 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.Serialization.cs new file mode 100644 index 000000000000..33405da807c0 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.Serialization.cs @@ -0,0 +1,173 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade profile. + public partial class UpgradeProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UpgradeProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UpgradeProfile 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 DeserializeUpgradeProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpgradeProfile)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(UpgradeProfile)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + UpgradeProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(UpgradeProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.ToString()); + if (Optional.IsDefined(FullyManagedUpgradeProfile)) + { + writer.WritePropertyName("fullyManagedUpgradeProfile"u8); + writer.WriteObjectValue(FullyManagedUpgradeProfile, options); + } + if (Optional.IsDefined(SelfManagedUpgradeProfile)) + { + writer.WritePropertyName("selfManagedUpgradeProfile"u8); + writer.WriteObjectValue(SelfManagedUpgradeProfile, options); + } + 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. + UpgradeProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UpgradeProfile 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(UpgradeProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpgradeProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpgradeProfile DeserializeUpgradeProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpgradeMode mode = default; + FullyManagedUpgradeProfile fullyManagedUpgradeProfile = default; + SelfManagedUpgradeProfile selfManagedUpgradeProfile = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("mode"u8)) + { + mode = new UpgradeMode(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("fullyManagedUpgradeProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fullyManagedUpgradeProfile = FullyManagedUpgradeProfile.DeserializeFullyManagedUpgradeProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("selfManagedUpgradeProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + selfManagedUpgradeProfile = SelfManagedUpgradeProfile.DeserializeSelfManagedUpgradeProfile(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UpgradeProfile(mode, fullyManagedUpgradeProfile, selfManagedUpgradeProfile, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.cs new file mode 100644 index 000000000000..9aa9d4196da4 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade profile. + public partial class UpgradeProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Upgrade mode. + public UpgradeProfile(UpgradeMode mode) + { + Mode = mode; + } + + /// Initializes a new instance of . + /// Upgrade mode. + /// Fully managed upgrade profile. + /// Self managed upgrade profile. + /// Keeps track of any properties unknown to the library. + internal UpgradeProfile(UpgradeMode mode, FullyManagedUpgradeProfile fullyManagedUpgradeProfile, SelfManagedUpgradeProfile selfManagedUpgradeProfile, IDictionary additionalBinaryDataProperties) + { + Mode = mode; + FullyManagedUpgradeProfile = fullyManagedUpgradeProfile; + SelfManagedUpgradeProfile = selfManagedUpgradeProfile; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Upgrade mode. + public UpgradeMode Mode { get; set; } + + /// Fully managed upgrade profile. + internal FullyManagedUpgradeProfile FullyManagedUpgradeProfile { get; set; } + + /// Self managed upgrade profile. + internal SelfManagedUpgradeProfile SelfManagedUpgradeProfile { get; set; } + + /// Release channel. + public UpgradeReleaseChannel? FullyManagedUpgradeReleaseChannel + { + get + { + return FullyManagedUpgradeProfile is null ? default : FullyManagedUpgradeProfile.ReleaseChannel; + } + set + { + FullyManagedUpgradeProfile = value.HasValue ? new FullyManagedUpgradeProfile(value.Value) : default; + } + } + + /// Istio version. + public string SelfManagedUpgradeVersion + { + get + { + return SelfManagedUpgradeProfile is null ? default : SelfManagedUpgradeProfile.Version; + } + set + { + SelfManagedUpgradeProfile = new SelfManagedUpgradeProfile(value); + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeReleaseChannel.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeReleaseChannel.cs new file mode 100644 index 000000000000..bd9ffbc012f7 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeReleaseChannel.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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade release channel. + public readonly partial struct UpgradeReleaseChannel : IEquatable + { + private readonly string _value; + /// Rapid release channel. + private const string RapidValue = "Rapid"; + /// Stable release channel. + private const string StableValue = "Stable"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public UpgradeReleaseChannel(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Rapid release channel. + public static UpgradeReleaseChannel Rapid { get; } = new UpgradeReleaseChannel(RapidValue); + + /// Stable release channel. + public static UpgradeReleaseChannel Stable { get; } = new UpgradeReleaseChannel(StableValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(UpgradeReleaseChannel left, UpgradeReleaseChannel 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 !=(UpgradeReleaseChannel left, UpgradeReleaseChannel right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator UpgradeReleaseChannel(string value) => new UpgradeReleaseChannel(value); + + /// Converts a string to a . + /// The value. + public static implicit operator UpgradeReleaseChannel?(string value) => value == null ? null : new UpgradeReleaseChannel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is UpgradeReleaseChannel other && Equals(other); + + /// + public bool Equals(UpgradeReleaseChannel 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.Serialization.cs new file mode 100644 index 000000000000..d731472dec29 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.Serialization.cs @@ -0,0 +1,173 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Version information. + public partial class VersionInfo : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal VersionInfo() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual VersionInfo 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 DeserializeVersionInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VersionInfo)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(VersionInfo)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + VersionInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(VersionInfo)} does not support writing '{format}' format."); + } + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + writer.WritePropertyName("upgrades"u8); + writer.WriteStartArray(); + foreach (string item in Upgrades) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + 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. + VersionInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual VersionInfo 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(VersionInfo)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVersionInfo(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static VersionInfo DeserializeVersionInfo(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string version = default; + IList upgrades = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("upgrades"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + upgrades = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new VersionInfo(version, upgrades, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.cs new file mode 100644 index 000000000000..c7c968d74b98 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.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 System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Version information. + public partial class VersionInfo + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Istio version. + /// Available upgrades. + internal VersionInfo(string version, IEnumerable upgrades) + { + Version = version; + Upgrades = upgrades.ToList(); + } + + /// Initializes a new instance of . + /// Istio version. + /// Available upgrades. + /// Keeps track of any properties unknown to the library. + internal VersionInfo(string version, IList upgrades, IDictionary additionalBinaryDataProperties) + { + Version = version; + Upgrades = upgrades; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Istio version. + public string Version { get; } + + /// Available upgrades. + public IList Upgrades { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ProviderConstants.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..7d05f1f90356 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + internal static partial class ProviderConstants + { + /// Gets the DefaultProviderNamespace. + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinkMembersRestOperations.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinkMembersRestOperations.cs new file mode 100644 index 000000000000..09844489dc48 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinkMembersRestOperations.cs @@ -0,0 +1,189 @@ +// 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.AppLink +{ + internal partial class AppLinkMembers + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AppLinkMembers for mocking. + protected AppLinkMembers() + { + } + + /// Initializes a new instance of AppLinkMembers. + /// 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 AppLinkMembers(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 appLinkName, string appLinkMemberName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + if (_apiVersion != null) + { + 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, string appLinkName, string appLinkMemberName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + if (_apiVersion != null) + { + 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 appLinkName, string appLinkMemberName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + if (_apiVersion != null) + { + 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 appLinkName, string appLinkMemberName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + if (_apiVersion != null) + { + 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 CreateGetByAppLinkRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers", false); + if (_apiVersion != null) + { + 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 CreateNextGetByAppLinkRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinksRestOperations.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinksRestOperations.cs new file mode 100644 index 000000000000..21047fbb2167 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinksRestOperations.cs @@ -0,0 +1,221 @@ +// 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.AppLink +{ + internal partial class AppLinks + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AppLinks for mocking. + protected AppLinks() + { + } + + /// Initializes a new instance of AppLinks. + /// 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 AppLinks(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 appLinkName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + if (_apiVersion != null) + { + 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, string appLinkName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + if (_apiVersion != null) + { + 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 appLinkName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + if (_apiVersion != null) + { + 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 appLinkName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + if (_apiVersion != null) + { + 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/Microsoft.AppLink/appLinks", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/Microsoft.AppLink/appLinks", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AvailableVersionsRestOperations.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AvailableVersionsRestOperations.cs new file mode 100644 index 000000000000..d720a1d04cae --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AvailableVersionsRestOperations.cs @@ -0,0 +1,92 @@ +// 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.AppLink +{ + internal partial class AvailableVersions + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AvailableVersions for mocking. + protected AvailableVersions() + { + } + + /// Initializes a new instance of AvailableVersions. + /// 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 AvailableVersions(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 CreateGetByLocationRequest(Guid subscriptionId, AzureLocation location, string kubernetesVersion, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Microsoft.AppLink/locations/", false); + uri.AppendPath(location.ToString(), true); + uri.AppendPath("/availableVersions", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + if (kubernetesVersion != null) + { + uri.AppendQuery("kubernetesVersion", kubernetesVersion, 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, string kubernetesVersion, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/UpgradeHistoriesRestOperations.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/UpgradeHistoriesRestOperations.cs new file mode 100644 index 000000000000..9ab1b4ce95cf --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/UpgradeHistoriesRestOperations.cs @@ -0,0 +1,92 @@ +// 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.AppLink +{ + internal partial class UpgradeHistories + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of UpgradeHistories for mocking. + protected UpgradeHistories() + { + } + + /// Initializes a new instance of UpgradeHistories. + /// 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 UpgradeHistories(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 CreateGetByAppLinkMemberRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, 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/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + uri.AppendPath("/upgradeHistories", false); + if (_apiVersion != null) + { + 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 CreateNextGetByAppLinkMemberRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/applink/Azure.ResourceManager.AppLink/src/Properties/AssemblyInfo.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..807dc7c2007f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.AppLink")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.AppLink.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/applink/Azure.ResourceManager.AppLink/tests/AppLinkManagementTestBase.cs b/sdk/applink/Azure.ResourceManager.AppLink/tests/AppLinkManagementTestBase.cs new file mode 100644 index 000000000000..3f0be9fdaf9a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/tests/AppLinkManagementTestBase.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.AppLink.Tests +{ + public class AppLinkManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected AppLinkManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected AppLinkManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/tests/AppLinkManagementTestEnvironment.cs b/sdk/applink/Azure.ResourceManager.AppLink/tests/AppLinkManagementTestEnvironment.cs new file mode 100644 index 000000000000..191ee76f0329 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/tests/AppLinkManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.AppLink.Tests +{ + public class AppLinkManagementTestEnvironment : TestEnvironment + { + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/tests/Azure.ResourceManager.AppLink.Tests.csproj b/sdk/applink/Azure.ResourceManager.AppLink/tests/Azure.ResourceManager.AppLink.Tests.csproj new file mode 100644 index 000000000000..f93986424360 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/tests/Azure.ResourceManager.AppLink.Tests.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/applink/Azure.ResourceManager.AppLink/tsp-location.yaml b/sdk/applink/Azure.ResourceManager.AppLink/tsp-location.yaml new file mode 100644 index 000000000000..575d88b73623 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/tsp-location.yaml @@ -0,0 +1,6 @@ +directory: specification/applink/AppLink.Management +commit: 5bdcbdbbffe1d6417e9783f9cdf79432600e5a31 +repo: Azure/azure-rest-api-specs +additionalDirectories: + +emitterPackageJsonPath: eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json \ No newline at end of file diff --git a/sdk/applink/ci.mgmt.yml b/sdk/applink/ci.mgmt.yml new file mode 100644 index 000000000000..c1776aacf757 --- /dev/null +++ b/sdk/applink/ci.mgmt.yml @@ -0,0 +1,12 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: applink + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.AppLink + safeName: AzureResourceManagerAppLink diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/Azure.ResourceManager.Contoso.sln b/sdk/contoso/Azure.ResourceManager.Contoso/Azure.ResourceManager.Contoso.sln new file mode 100644 index 000000000000..7810011a0adc --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/Azure.ResourceManager.Contoso.sln @@ -0,0 +1,100 @@ + +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.Contoso", "src\Azure.ResourceManager.Contoso.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Contoso.Tests", "tests\Azure.ResourceManager.Contoso.Tests.csproj", "{9922029C-C526-4F75-B3BF-1D28F2D1E198}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{D459D5AD-0DA0-4908-A929-73EEDC202953}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core", "..\..\core\Azure.Core\src\Azure.Core.csproj", "{2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.SdkAnalyzers", "..\..\tools\Azure.SdkAnalyzers\src\Azure.SdkAnalyzers.csproj", "{AC717192-2F76-4D4C-80CE-053926AF2F67}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {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}.Debug|x64.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|x64.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|x86.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|x86.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 + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x64.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x64.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x86.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x86.Build.0 = Release|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Debug|x64.ActiveCfg = Debug|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Debug|x64.Build.0 = Debug|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Debug|x86.ActiveCfg = Debug|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Debug|x86.Build.0 = Debug|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Release|Any CPU.Build.0 = Release|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Release|x64.ActiveCfg = Release|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Release|x64.Build.0 = Release|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Release|x86.ActiveCfg = Release|Any CPU + {9922029C-C526-4F75-B3BF-1D28F2D1E198}.Release|x86.Build.0 = Release|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Debug|x64.ActiveCfg = Debug|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Debug|x64.Build.0 = Debug|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Debug|x86.ActiveCfg = Debug|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Debug|x86.Build.0 = Debug|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Release|Any CPU.Build.0 = Release|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Release|x64.ActiveCfg = Release|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Release|x64.Build.0 = Release|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Release|x86.ActiveCfg = Release|Any CPU + {D459D5AD-0DA0-4908-A929-73EEDC202953}.Release|x86.Build.0 = Release|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Debug|x64.ActiveCfg = Debug|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Debug|x64.Build.0 = Debug|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Debug|x86.ActiveCfg = Debug|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Debug|x86.Build.0 = Debug|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Release|Any CPU.Build.0 = Release|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Release|x64.ActiveCfg = Release|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Release|x64.Build.0 = Release|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Release|x86.ActiveCfg = Release|Any CPU + {2B067178-15F0-4ED0-B6B9-B2CDF4BA2FF9}.Release|x86.Build.0 = Release|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Debug|x64.ActiveCfg = Debug|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Debug|x64.Build.0 = Debug|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Debug|x86.ActiveCfg = Debug|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Debug|x86.Build.0 = Debug|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Release|Any CPU.Build.0 = Release|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Release|x64.ActiveCfg = Release|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Release|x64.Build.0 = Release|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Release|x86.ActiveCfg = Release|Any CPU + {AC717192-2F76-4D4C-80CE-053926AF2F67}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {9922029C-C526-4F75-B3BF-1D28F2D1E198} = {0AB3BF05-4346-4AA6-1389-037BE0695223} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/CHANGELOG.md b/sdk/contoso/Azure.ResourceManager.Contoso/CHANGELOG.md new file mode 100644 index 000000000000..f50dd6a1a0bf --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/CHANGELOG.md @@ -0,0 +1,12 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/Directory.Build.props b/sdk/contoso/Azure.ResourceManager.Contoso/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/README.md b/sdk/contoso/Azure.ResourceManager.Contoso/README.md new file mode 100644 index 000000000000..d0b367242b53 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure Contoso management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure Contoso management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.Contoso --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://docs.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/metadata.json b/sdk/contoso/Azure.ResourceManager.Contoso/metadata.json new file mode 100644 index 000000000000..fa58e6445bcb --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/metadata.json @@ -0,0 +1,5 @@ +{ + "apiVersions": { + "Microsoft.Contoso": "2021-11-01" + } +} \ No newline at end of file diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Azure.ResourceManager.Contoso.csproj b/sdk/contoso/Azure.ResourceManager.Contoso/src/Azure.ResourceManager.Contoso.csproj new file mode 100644 index 000000000000..69d22a8d3f0e --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Azure.ResourceManager.Contoso.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.Contoso client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.Contoso + 1.0.0-beta.1 + Azure.ResourceManager.Contoso + true + + diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/ArmContosoModelFactory.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/ArmContosoModelFactory.cs new file mode 100644 index 000000000000..15ffa4316f15 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/ArmContosoModelFactory.cs @@ -0,0 +1,57 @@ +// 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.Contoso; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Contoso.Models +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ArmContosoModelFactory + { + + /// Employee 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static EmployeeData EmployeeData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, EmployeeProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new EmployeeData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Employee properties. + /// Age of employee. + /// City of employee. + /// Profile of employee. + /// The status of the last operation. + /// A new instance for mocking. + public static EmployeeProperties EmployeeProperties(int? age = default, string city = default, BinaryData profile = default, ProvisioningState? provisioningState = default) + { + return new EmployeeProperties(age, city, profile, provisioningState, additionalBinaryDataProperties: null); + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..e9e9943783f1 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupAsyncCollectionResultOfT.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.Contoso.Models; + +namespace Azure.ResourceManager.Contoso +{ + internal partial class EmployeesGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly Employees _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of EmployeesGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Employees 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 EmployeesGetByResourceGroupAsyncCollectionResultOfT(Employees client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of EmployeesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of EmployeesGetByResourceGroupAsyncCollectionResultOfT 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; + } + EmployeeListResult result = EmployeeListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("EmployeeCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupCollectionResultOfT.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..227c4c10852d --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupCollectionResultOfT.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.Contoso.Models; + +namespace Azure.ResourceManager.Contoso +{ + internal partial class EmployeesGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly Employees _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of EmployeesGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Employees 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 EmployeesGetByResourceGroupCollectionResultOfT(Employees client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of EmployeesGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of EmployeesGetByResourceGroupCollectionResultOfT 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; + } + EmployeeListResult result = EmployeeListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("EmployeeCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..7d36bf4583fb --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionAsyncCollectionResultOfT.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.Contoso.Models; + +namespace Azure.ResourceManager.Contoso +{ + internal partial class EmployeesGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly Employees _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of EmployeesGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Employees 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 EmployeesGetBySubscriptionAsyncCollectionResultOfT(Employees client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of EmployeesGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of EmployeesGetBySubscriptionAsyncCollectionResultOfT 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; + } + EmployeeListResult result = EmployeeListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableContosoSubscriptionResource.GetEmployees"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionCollectionResultOfT.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..b5fb8fb0e65f --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionCollectionResultOfT.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.Contoso.Models; + +namespace Azure.ResourceManager.Contoso +{ + internal partial class EmployeesGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly Employees _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of EmployeesGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Employees 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 EmployeesGetBySubscriptionCollectionResultOfT(Employees client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of EmployeesGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of EmployeesGetBySubscriptionCollectionResultOfT 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; + } + EmployeeListResult result = EmployeeListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableContosoSubscriptionResource.GetEmployees"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeCollection.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeCollection.cs new file mode 100644 index 000000000000..d0c9bf1b3f69 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeCollection.cs @@ -0,0 +1,580 @@ +// 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; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Contoso +{ + /// + /// 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 GetEmployees method from an instance of . + /// + public partial class EmployeeCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _employeesClientDiagnostics; + private readonly Employees _employeesRestClient; + + /// Initializes a new instance of EmployeeCollection for mocking. + protected EmployeeCollection() + { + } + + /// 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 EmployeeCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(EmployeeResource.ResourceType, out string employeeApiVersion); + _employeesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Contoso", EmployeeResource.ResourceType.Namespace, Diagnostics); + _employeesRestClient = new Employees(_employeesClientDiagnostics, Pipeline, Endpoint, employeeApiVersion ?? "2021-11-01"); + 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), nameof(id)); + } + } + + /// + /// Create a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// 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 Employee. + /// 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 employeeName, EmployeeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, EmployeeData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ContosoArmOperation operation = new ContosoArmOperation( + new EmployeeOperationSource(Client), + _employeesClientDiagnostics, + 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 Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// 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 Employee. + /// 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 employeeName, EmployeeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, EmployeeData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ContosoArmOperation operation = new ContosoArmOperation( + new EmployeeOperationSource(Client), + _employeesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Employee resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees. + /// + /// + /// Operation Id. + /// Employees_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// 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 EmployeesGetByResourceGroupAsyncCollectionResultOfT(_employeesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new EmployeeResource(Client, data)); + } + + /// + /// List Employee resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees. + /// + /// + /// Operation Id. + /// Employees_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// 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 EmployeesGetByResourceGroupCollectionResultOfT(_employeesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new EmployeeResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(EmployeeData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((EmployeeData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(EmployeeData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((EmployeeData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(EmployeeData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((EmployeeData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(EmployeeData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((EmployeeData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new EmployeeResource(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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.Serialization.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.Serialization.cs new file mode 100644 index 000000000000..d44441c50548 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Contoso.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Contoso +{ + /// Employee resource. + public partial class EmployeeData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EmployeeData() + { + } + + /// 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 DeserializeEmployeeData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EmployeeData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerContosoContext.Default); + default: + throw new FormatException($"The model {nameof(EmployeeData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + EmployeeData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EmployeeData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(EmployeeData employeeData) + { + if (employeeData == null) + { + return null; + } + return RequestContent.Create(employeeData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static EmployeeData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEmployeeData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(EmployeeData)} 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. + EmployeeData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EmployeeData)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(EmployeeData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEmployeeData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EmployeeData DeserializeEmployeeData(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; + EmployeeProperties 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, AzureResourceManagerContosoContext.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 = EmployeeProperties.DeserializeEmployeeProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EmployeeData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.cs new file mode 100644 index 000000000000..7f8e0b7c6ebf --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.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.Contoso.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Contoso +{ + /// Employee resource. + public partial class EmployeeData : 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 EmployeeData(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 EmployeeData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, EmployeeProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public EmployeeProperties Properties { get; set; } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.Serialization.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.Serialization.cs new file mode 100644 index 000000000000..e71f1c6d90b3 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.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.Contoso +{ + /// + public partial class EmployeeResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new EmployeeData(); + + /// 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. + EmployeeData 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, AzureResourceManagerContosoContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + EmployeeData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerContosoContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.cs new file mode 100644 index 000000000000..4a3050319eaa --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.cs @@ -0,0 +1,667 @@ +// 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.Contoso +{ + /// + /// A class representing a Employee 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 GetEmployees method. + /// + public partial class EmployeeResource : ArmResource + { + private readonly ClientDiagnostics _employeesClientDiagnostics; + private readonly Employees _employeesRestClient; + private readonly EmployeeData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Contoso/employees"; + + /// Initializes a new instance of EmployeeResource for mocking. + protected EmployeeResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal EmployeeResource(ArmClient client, EmployeeData 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 EmployeeResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string employeeApiVersion); + _employeesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Contoso", ResourceType.Namespace, Diagnostics); + _employeesRestClient = new Employees(_employeesClientDiagnostics, Pipeline, Endpoint, employeeApiVersion ?? "2021-11-01"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual EmployeeData 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 employeeName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string employeeName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}"; + 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), nameof(id)); + } + } + + /// + /// Get a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Update. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(EmployeeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, EmployeeData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Update. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(EmployeeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, EmployeeData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Delete. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// 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 = _employeesClientDiagnostics.CreateScope("EmployeeResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ContosoArmOperation operation = new ContosoArmOperation(_employeesClientDiagnostics, 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 Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Delete. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// 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 = _employeesClientDiagnostics.CreateScope("EmployeeResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _employeesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + ContosoArmOperation operation = new ContosoArmOperation(_employeesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _employeesClientDiagnostics.CreateScope("EmployeeResource.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 = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + else + { + EmployeeData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + EmployeeData patch = new EmployeeData(); + 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 = _employeesClientDiagnostics.CreateScope("EmployeeResource.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 = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + else + { + EmployeeData current = Get(cancellationToken: cancellationToken).Value.Data; + EmployeeData patch = new EmployeeData(); + 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 = _employeesClientDiagnostics.CreateScope("EmployeeResource.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 = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + else + { + EmployeeData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + EmployeeData patch = new EmployeeData(); + 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 = _employeesClientDiagnostics.CreateScope("EmployeeResource.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 = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + else + { + EmployeeData current = Get(cancellationToken: cancellationToken).Value.Data; + EmployeeData patch = new EmployeeData(); + 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 = _employeesClientDiagnostics.CreateScope("EmployeeResource.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 = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + else + { + EmployeeData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + EmployeeData patch = new EmployeeData(); + 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 = _employeesClientDiagnostics.CreateScope("EmployeeResource.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 = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EmployeeData.FromResponse(result), result); + return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse()); + } + else + { + EmployeeData current = Get(cancellationToken: cancellationToken).Value.Data; + EmployeeData patch = new EmployeeData(); + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/ContosoExtensions.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/ContosoExtensions.cs new file mode 100644 index 000000000000..41a8b69f174b --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/ContosoExtensions.cs @@ -0,0 +1,149 @@ +// 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.Contoso.Mocking; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Contoso +{ + /// A class to add extension methods to Azure.ResourceManager.Contoso. + public static partial class ContosoExtensions + { + /// + private static MockableContosoArmClient GetMockableContosoArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableContosoArmClient(client0, ResourceIdentifier.Root)); + } + + /// + private static MockableContosoResourceGroupResource GetMockableContosoResourceGroupResource(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient(client => new MockableContosoResourceGroupResource(client, resourceGroupResource.Id)); + } + + /// + private static MockableContosoSubscriptionResource GetMockableContosoSubscriptionResource(SubscriptionResource subscriptionResource) + { + return subscriptionResource.GetCachedClient(client => new MockableContosoSubscriptionResource(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 EmployeeResource GetEmployeeResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContosoArmClient(client).GetEmployeeResource(id); + } + + /// + /// Gets a collection of Employees in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of Employees and their operations over a EmployeeResource. + public static EmployeeCollection GetEmployees(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContosoResourceGroupResource(resourceGroupResource).GetEmployees(); + } + + /// + /// Get a Employee + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetEmployeeAsync(this ResourceGroupResource resourceGroupResource, string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableContosoResourceGroupResource(resourceGroupResource).GetEmployeeAsync(employeeName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Employee + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetEmployee(this ResourceGroupResource resourceGroupResource, string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableContosoResourceGroupResource(resourceGroupResource).GetEmployee(employeeName, cancellationToken); + } + + /// + /// List Employee 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 GetEmployeesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableContosoSubscriptionResource(subscriptionResource).GetEmployeesAsync(cancellationToken); + } + + /// + /// List Employee 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 GetEmployees(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableContosoSubscriptionResource(subscriptionResource).GetEmployees(cancellationToken); + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoArmClient.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoArmClient.cs new file mode 100644 index 000000000000..3450bca08072 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoArmClient.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Contoso; + +namespace Azure.ResourceManager.Contoso.Mocking +{ + /// A class to add extension methods to . + public partial class MockableContosoArmClient : ArmResource + { + /// Initializes a new instance of MockableContosoArmClient for mocking. + protected MockableContosoArmClient() + { + } + + /// 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 MockableContosoArmClient(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 EmployeeResource GetEmployeeResource(ResourceIdentifier id) + { + EmployeeResource.ValidateResourceId(id); + return new EmployeeResource(Client, id); + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoResourceGroupResource.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoResourceGroupResource.cs new file mode 100644 index 000000000000..a50ea1e839b7 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoResourceGroupResource.cs @@ -0,0 +1,99 @@ +// 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.Contoso; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Contoso.Mocking +{ + /// A class to add extension methods to . + public partial class MockableContosoResourceGroupResource : ArmResource + { + /// Initializes a new instance of MockableContosoResourceGroupResource for mocking. + protected MockableContosoResourceGroupResource() + { + } + + /// 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 MockableContosoResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets a collection of Employees in the . + /// An object representing collection of Employees and their operations over a EmployeeResource. + public virtual EmployeeCollection GetEmployees() + { + return GetCachedClient(client => new EmployeeCollection(client, Id)); + } + + /// + /// Get a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetEmployeeAsync(string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + + return await GetEmployees().GetAsync(employeeName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Employee + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}. + /// + /// + /// Operation Id. + /// Employees_Get. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The name of the Employee. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetEmployee(string employeeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName)); + + return GetEmployees().Get(employeeName, cancellationToken); + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoSubscriptionResource.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoSubscriptionResource.cs new file mode 100644 index 000000000000..0cea4cbf9e82 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoSubscriptionResource.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Contoso; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Contoso.Mocking +{ + /// A class to add extension methods to . + public partial class MockableContosoSubscriptionResource : ArmResource + { + private ClientDiagnostics _employeesClientDiagnostics; + private Employees _employeesRestClient; + + /// Initializes a new instance of MockableContosoSubscriptionResource for mocking. + protected MockableContosoSubscriptionResource() + { + } + + /// 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 MockableContosoSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics EmployeesClientDiagnostics => _employeesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Contoso.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private Employees EmployeesRestClient => _employeesRestClient ??= new Employees(EmployeesClientDiagnostics, Pipeline, Endpoint, "2021-11-01"); + + /// + /// List Employee resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Contoso/employees. + /// + /// + /// Operation Id. + /// Employees_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetEmployeesAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new EmployeesGetBySubscriptionAsyncCollectionResultOfT(EmployeesRestClient, Guid.Parse(Id.SubscriptionId), context), data => new EmployeeResource(Client, data)); + } + + /// + /// List Employee resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Contoso/employees. + /// + /// + /// Operation Id. + /// Employees_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2021-11-01. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetEmployees(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new EmployeesGetBySubscriptionCollectionResultOfT(EmployeesRestClient, Guid.Parse(Id.SubscriptionId), context), data => new EmployeeResource(Client, data)); + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/Argument.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..8261d31c3590 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/Argument.cs @@ -0,0 +1,113 @@ +// 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.Contoso +{ + 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); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + /// The value. + /// The minimum value. + /// The maximum value. + /// The name. + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + /// The value. + /// The name. + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..c1a22dcfc8b5 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..da6e2e13a2a9 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingList.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..e0fb3a3b648f --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..2adf07b2bc39 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions errorOptions) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (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 errorOptions) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ErrorResult.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..f373edd78036 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..c92c52df1907 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,268 @@ +// 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.Runtime.InteropServices; +using System.Text.Json; + +namespace Azure.ResourceManager.Contoso +{ + 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); + } + + public static BinaryData GetUtf8Bytes(this JsonElement element) + { +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/Optional.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..277afa828119 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/PageableWrapper.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..66774e1c7bb2 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..fcf22d757d26 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,60 @@ +// 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.Contoso +{ + 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); + } + + public static void UpdateQuery(this RawRequestUriBuilder builder, string name, string value) + { + string currentQuery = builder.Query; + string searchPattern = string.Concat(name, "="); + int paramStartIndex = -1; + if (currentQuery.StartsWith(string.Concat("?", searchPattern))) + { + paramStartIndex = 1; + } + if (paramStartIndex == -1) + { + string prefixedPattern = string.Concat("&", searchPattern); + int prefixedIndex = currentQuery.IndexOf(prefixedPattern); + if (prefixedIndex >= 0) + { + paramStartIndex = prefixedIndex + 1; + } + } + if (paramStartIndex >= 0) + { + int valueStartIndex = paramStartIndex + searchPattern.Length; + int valueEndIndex = currentQuery.IndexOf('&', valueStartIndex); + if (valueEndIndex == -1) + { + valueEndIndex = currentQuery.Length; + } + string beforeParam = currentQuery.Substring(0, valueStartIndex); + string afterParam = currentQuery.Substring(valueEndIndex); + string newQuery = string.Concat(beforeParam, value, afterParam); + builder.Query = newQuery; + } + else + { + builder.AppendQuery(name, value, true); + } + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/RequestContextExtensions.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..65152463aed3 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/SerializationFormat.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..606f45f9a980 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/TypeFormatters.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..24566905cbbe --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/LongRunningOperation/ContosoArmOperation.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/LongRunningOperation/ContosoArmOperation.cs new file mode 100644 index 000000000000..3025abf3c2fe --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/LongRunningOperation/ContosoArmOperation.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.Contoso +{ + internal partial class ContosoArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of ContosoArmOperation for mocking. + protected ContosoArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal ContosoArmOperation(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 ContosoArmOperation(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, + "ContosoArmOperation", + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/LongRunningOperation/ContosoArmOperationOfT.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/LongRunningOperation/ContosoArmOperationOfT.cs new file mode 100644 index 000000000000..c47bbc4c8b61 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/LongRunningOperation/ContosoArmOperationOfT.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.Contoso +{ + internal partial class ContosoArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of ContosoArmOperation for mocking. + protected ContosoArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal ContosoArmOperation(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 ContosoArmOperation(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, + "ContosoArmOperation", + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/LongRunningOperation/EmployeeOperationSource.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/LongRunningOperation/EmployeeOperationSource.cs new file mode 100644 index 000000000000..3c7443ccc306 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/LongRunningOperation/EmployeeOperationSource.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.Contoso +{ + /// + internal partial class EmployeeOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal EmployeeOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + EmployeeResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + EmployeeData data = EmployeeData.DeserializeEmployeeData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new EmployeeResource(_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); + EmployeeData data = EmployeeData.DeserializeEmployeeData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new EmployeeResource(_client, data); + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/AzureResourceManagerContosoContext.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/AzureResourceManagerContosoContext.cs new file mode 100644 index 000000000000..1e7841e5e365 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/AzureResourceManagerContosoContext.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.Contoso.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Contoso +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(EmployeeData))] + [ModelReaderWriterBuildable(typeof(EmployeeListResult))] + [ModelReaderWriterBuildable(typeof(EmployeeProperties))] + [ModelReaderWriterBuildable(typeof(EmployeeResource))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(SystemData))] + public partial class AzureResourceManagerContosoContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeListResult.Serialization.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeListResult.Serialization.cs new file mode 100644 index 000000000000..59771189f2be --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeListResult.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.Contoso; + +namespace Azure.ResourceManager.Contoso.Models +{ + /// The response of a Employee list operation. + internal partial class EmployeeListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EmployeeListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EmployeeListResult 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 DeserializeEmployeeListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EmployeeListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerContosoContext.Default); + default: + throw new FormatException($"The model {nameof(EmployeeListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + EmployeeListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static EmployeeListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEmployeeListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(EmployeeListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (EmployeeData 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. + EmployeeListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EmployeeListResult 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(EmployeeListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEmployeeListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EmployeeListResult DeserializeEmployeeListResult(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(EmployeeData.DeserializeEmployeeData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EmployeeListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeListResult.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeListResult.cs new file mode 100644 index 000000000000..faf4f2f329f6 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeListResult.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.Contoso; + +namespace Azure.ResourceManager.Contoso.Models +{ + /// The response of a Employee list operation. + internal partial class EmployeeListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Employee items on this page. + internal EmployeeListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Employee items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal EmployeeListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Employee items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeProperties.Serialization.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeProperties.Serialization.cs new file mode 100644 index 000000000000..9c767062c89f --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeProperties.Serialization.cs @@ -0,0 +1,186 @@ +// 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.Contoso; + +namespace Azure.ResourceManager.Contoso.Models +{ + /// Employee properties. + public partial class EmployeeProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EmployeeProperties 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 DeserializeEmployeeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EmployeeProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerContosoContext.Default); + default: + throw new FormatException($"The model {nameof(EmployeeProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + EmployeeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(EmployeeProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Age)) + { + writer.WritePropertyName("age"u8); + writer.WriteNumberValue(Age.Value); + } + if (Optional.IsDefined(City)) + { + writer.WritePropertyName("city"u8); + writer.WriteStringValue(City); + } + if (Optional.IsDefined(Profile)) + { + writer.WritePropertyName("profile"u8); + writer.WriteBase64StringValue(Profile.ToArray(), "U"); + } + 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. + EmployeeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EmployeeProperties 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(EmployeeProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEmployeeProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EmployeeProperties DeserializeEmployeeProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? age = default; + string city = default; + BinaryData profile = default; + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("age"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + age = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("city"u8)) + { + city = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("profile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + profile = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("U")); + 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 EmployeeProperties(age, city, profile, provisioningState, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeProperties.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeProperties.cs new file mode 100644 index 000000000000..384c06c04c78 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/EmployeeProperties.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Contoso.Models +{ + /// Employee properties. + public partial class EmployeeProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public EmployeeProperties() + { + } + + /// Initializes a new instance of . + /// Age of employee. + /// City of employee. + /// Profile of employee. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal EmployeeProperties(int? age, string city, BinaryData profile, ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + Age = age; + City = city; + Profile = profile; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Age of employee. + public int? Age { get; set; } + + /// City of employee. + public string City { get; set; } + + /// + /// Profile of employee + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }). + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData Profile { get; set; } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/ProvisioningState.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..285db5fbc725 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Contoso; + +namespace Azure.ResourceManager.Contoso.Models +{ + /// The resource provisioning state. + 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"; + /// The resource is being provisioned. + private const string ProvisioningValue = "Provisioning"; + /// The resource is updating. + private const string UpdatingValue = "Updating"; + /// The resource is being deleted. + private const string DeletingValue = "Deleting"; + /// The resource create request has been accepted. + 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); + + /// The resource is being provisioned. + public static ProvisioningState Provisioning { get; } = new ProvisioningState(ProvisioningValue); + + /// The resource is updating. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + + /// The resource is being deleted. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + + /// The resource create request has been 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/ProviderConstants.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..cfe8376fe8be --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/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.Contoso +{ + internal static partial class ProviderConstants + { + /// Gets the DefaultProviderNamespace. + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/RestOperations/EmployeesRestOperations.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/RestOperations/EmployeesRestOperations.cs new file mode 100644 index 000000000000..5cb0dc3d6a66 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/RestOperations/EmployeesRestOperations.cs @@ -0,0 +1,221 @@ +// 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.Contoso +{ + internal partial class Employees + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Employees for mocking. + protected Employees() + { + } + + /// Initializes a new instance of Employees. + /// 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 Employees(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 employeeName, 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/Microsoft.Contoso/employees/", false); + uri.AppendPath(employeeName, true); + if (_apiVersion != null) + { + 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, string employeeName, 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/Microsoft.Contoso/employees/", false); + uri.AppendPath(employeeName, true); + if (_apiVersion != null) + { + 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 employeeName, 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/Microsoft.Contoso/employees/", false); + uri.AppendPath(employeeName, true); + if (_apiVersion != null) + { + 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 employeeName, 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/Microsoft.Contoso/employees/", false); + uri.AppendPath(employeeName, true); + if (_apiVersion != null) + { + 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/Microsoft.Contoso/employees", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/Microsoft.Contoso/employees", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/contoso/Azure.ResourceManager.Contoso/src/Properties/AssemblyInfo.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..a36d7a09b367 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Contoso")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.Contoso.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/tests/Azure.ResourceManager.Contoso.Tests.csproj b/sdk/contoso/Azure.ResourceManager.Contoso/tests/Azure.ResourceManager.Contoso.Tests.csproj new file mode 100644 index 000000000000..f5552b65c3f1 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/tests/Azure.ResourceManager.Contoso.Tests.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/tests/ContosoManagementTestBase.cs b/sdk/contoso/Azure.ResourceManager.Contoso/tests/ContosoManagementTestBase.cs new file mode 100644 index 000000000000..52c9b7f4aab2 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/tests/ContosoManagementTestBase.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Contoso.Tests +{ + public class ContosoManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected ContosoManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected ContosoManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/tests/ContosoManagementTestEnvironment.cs b/sdk/contoso/Azure.ResourceManager.Contoso/tests/ContosoManagementTestEnvironment.cs new file mode 100644 index 000000000000..b1c4c91e35b3 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/tests/ContosoManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Contoso.Tests +{ + public class ContosoManagementTestEnvironment : TestEnvironment + { + } +} diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/tsp-location.yaml b/sdk/contoso/Azure.ResourceManager.Contoso/tsp-location.yaml new file mode 100644 index 000000000000..1ae66637c769 --- /dev/null +++ b/sdk/contoso/Azure.ResourceManager.Contoso/tsp-location.yaml @@ -0,0 +1,6 @@ +directory: specification/contosowidgetmanager/Contoso.Management +commit: a3fd1efe038ca9c4a0042c3ee3afe6b279079ff6 +repo: Azure/azure-rest-api-specs +additionalDirectories: + +emitterPackageJsonPath: eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json \ No newline at end of file diff --git a/sdk/contoso/ci.mgmt.yml b/sdk/contoso/ci.mgmt.yml new file mode 100644 index 000000000000..40f0f52d8a06 --- /dev/null +++ b/sdk/contoso/ci.mgmt.yml @@ -0,0 +1,12 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: contoso + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.Contoso + safeName: AzureResourceManagerContoso diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/Azure.ResourceManager.Discovery.sln b/sdk/discovery/Azure.ResourceManager.Discovery/Azure.ResourceManager.Discovery.sln new file mode 100644 index 000000000000..f71ba0d29b33 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/Azure.ResourceManager.Discovery.sln @@ -0,0 +1,100 @@ + +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.Discovery", "src\Azure.ResourceManager.Discovery.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Discovery.Tests", "tests\Azure.ResourceManager.Discovery.Tests.csproj", "{A7C0B959-5161-4CA8-B542-92EB679A5EDF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{CDC66078-4846-4E23-ADA7-76740F3E6403}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core", "..\..\core\Azure.Core\src\Azure.Core.csproj", "{CE85CC40-178B-49BF-98F9-039314D6F465}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.SdkAnalyzers", "..\..\tools\Azure.SdkAnalyzers\src\Azure.SdkAnalyzers.csproj", "{F5037015-A169-41C8-BC40-EFF20782A207}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {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}.Debug|x64.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|x64.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|x86.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|x86.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 + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x64.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x64.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x86.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|x86.Build.0 = Release|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Debug|x64.ActiveCfg = Debug|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Debug|x64.Build.0 = Debug|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Debug|x86.ActiveCfg = Debug|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Debug|x86.Build.0 = Debug|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Release|Any CPU.Build.0 = Release|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Release|x64.ActiveCfg = Release|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Release|x64.Build.0 = Release|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Release|x86.ActiveCfg = Release|Any CPU + {A7C0B959-5161-4CA8-B542-92EB679A5EDF}.Release|x86.Build.0 = Release|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Debug|x64.ActiveCfg = Debug|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Debug|x64.Build.0 = Debug|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Debug|x86.ActiveCfg = Debug|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Debug|x86.Build.0 = Debug|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Release|Any CPU.Build.0 = Release|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Release|x64.ActiveCfg = Release|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Release|x64.Build.0 = Release|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Release|x86.ActiveCfg = Release|Any CPU + {CDC66078-4846-4E23-ADA7-76740F3E6403}.Release|x86.Build.0 = Release|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Debug|x64.ActiveCfg = Debug|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Debug|x64.Build.0 = Debug|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Debug|x86.ActiveCfg = Debug|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Debug|x86.Build.0 = Debug|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Release|Any CPU.Build.0 = Release|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Release|x64.ActiveCfg = Release|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Release|x64.Build.0 = Release|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Release|x86.ActiveCfg = Release|Any CPU + {CE85CC40-178B-49BF-98F9-039314D6F465}.Release|x86.Build.0 = Release|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Debug|x64.ActiveCfg = Debug|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Debug|x64.Build.0 = Debug|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Debug|x86.ActiveCfg = Debug|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Debug|x86.Build.0 = Debug|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Release|Any CPU.Build.0 = Release|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Release|x64.ActiveCfg = Release|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Release|x64.Build.0 = Release|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Release|x86.ActiveCfg = Release|Any CPU + {F5037015-A169-41C8-BC40-EFF20782A207}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A7C0B959-5161-4CA8-B542-92EB679A5EDF} = {0AB3BF05-4346-4AA6-1389-037BE0695223} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/CHANGELOG.md b/sdk/discovery/Azure.ResourceManager.Discovery/CHANGELOG.md new file mode 100644 index 000000000000..f50dd6a1a0bf --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/CHANGELOG.md @@ -0,0 +1,12 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/Directory.Build.props b/sdk/discovery/Azure.ResourceManager.Discovery/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/README.md b/sdk/discovery/Azure.ResourceManager.Discovery/README.md new file mode 100644 index 000000000000..a5adb50d7cee --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure Discovery management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure Discovery management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.Discovery --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://docs.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/metadata.json b/sdk/discovery/Azure.ResourceManager.Discovery/metadata.json new file mode 100644 index 000000000000..5d567444d94a --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/metadata.json @@ -0,0 +1,5 @@ +{ + "apiVersions": { + "Microsoft.Discovery": "2026-02-01-preview" + } +} \ No newline at end of file diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Azure.ResourceManager.Discovery.csproj b/sdk/discovery/Azure.ResourceManager.Discovery/src/Azure.ResourceManager.Discovery.csproj new file mode 100644 index 000000000000..842cb82e057a --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Azure.ResourceManager.Discovery.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.Discovery client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.Discovery + 1.0.0-beta.1 + Azure.ResourceManager.Discovery + true + + diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ArmDiscoveryModelFactory.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ArmDiscoveryModelFactory.cs new file mode 100644 index 000000000000..855883cf9607 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ArmDiscoveryModelFactory.cs @@ -0,0 +1,575 @@ +// 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.Discovery; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ArmDiscoveryModelFactory + { + + /// Bookshelf 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static BookshelfData BookshelfData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, BookshelfProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new BookshelfData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// The status of the last operation. + /// User assigned identity IDs to be used by knowledgebase workloads. The key value must be the resource ID of the identity resource. + /// Whether or not to use a customer managed key when encrypting data at rest. + /// The key to use for encrypting data at rest when customer managed keys are enabled. Required if Customer Managed Keys is enabled. + /// The Log Analytics Cluster to use for debug logs. This is required when Customer Managed Keys are enabled. + /// List of private endpoint connections. + /// Whether or not public network access is allowed for this resource. For security reasons, it is recommended to disable it whenever possible. + /// Private Endpoint Subnet ID for private endpoint connections. + /// Search Subnet ID for search resources. + /// The resource group for resources managed on behalf of customer. + /// Managed-On-Behalf-Of broker resources. + /// The bookshelf data plane API URI. + /// A new instance for mocking. + public static BookshelfProperties BookshelfProperties(ProvisioningState? provisioningState = default, IDictionary workloadIdentities = default, CustomerManagedKeys? customerManagedKeys = default, BookshelfKeyVaultProperties keyVaultProperties = default, ResourceIdentifier logAnalyticsClusterId = default, IEnumerable privateEndpointConnections = default, PublicNetworkAccess? publicNetworkAccess = default, ResourceIdentifier privateEndpointSubnetId = default, ResourceIdentifier searchSubnetId = default, string managedResourceGroup = default, IEnumerable managedOnBehalfOfMoboBrokerResources = default, Uri bookshelfUri = default) + { + workloadIdentities ??= new ChangeTrackingDictionary(); + privateEndpointConnections ??= new ChangeTrackingList(); + + return new BookshelfProperties( + provisioningState, + workloadIdentities, + customerManagedKeys, + keyVaultProperties, + logAnalyticsClusterId, + privateEndpointConnections.ToList(), + publicNetworkAccess, + privateEndpointSubnetId, + searchSubnetId, + managedResourceGroup, + managedOnBehalfOfMoboBrokerResources is null ? default : new WithMoboBrokerResources((managedOnBehalfOfMoboBrokerResources ?? new ChangeTrackingList()).ToList(), null), + bookshelfUri, + additionalBinaryDataProperties: null); + } + + /// The private endpoint connection 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 private endpoint connection properties. + /// A new instance for mocking. + public static DiscoveryPrivateEndpointConnection DiscoveryPrivateEndpointConnection(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, PrivateEndpointConnectionProperties properties = default) + { + return new DiscoveryPrivateEndpointConnection( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// The group ids for the private endpoint resource. + /// The resource identifier of the private endpoint. + /// A collection of information about the state of the connection between service consumer and provider. + /// The provisioning state of the private endpoint connection resource. + /// A new instance for mocking. + public static PrivateEndpointConnectionProperties PrivateEndpointConnectionProperties(IEnumerable groupIds = default, ResourceIdentifier privateEndpointId = default, DiscoveryPrivateLinkServiceConnectionState privateLinkServiceConnectionState = default, DiscoveryPrivateEndpointConnectionProvisioningState? provisioningState = default) + { + groupIds ??= new ChangeTrackingList(); + + return new PrivateEndpointConnectionProperties(groupIds.ToList(), privateEndpointId is null ? default : new PrivateEndpoint(privateEndpointId, null), privateLinkServiceConnectionState, provisioningState, additionalBinaryDataProperties: null); + } + + /// Managed-On-Behalf-Of broker resource. This resource is created by the Resource Provider to manage some resources on behalf of the user. + /// Resource identifier of a Managed-On-Behalf-Of broker resource. + /// A new instance for mocking. + public static MoboBrokerResource MoboBrokerResource(ResourceIdentifier id = default) + { + return new MoboBrokerResource(id, additionalBinaryDataProperties: null); + } + + /// The Private Endpoint Connection resource for Bookshelf. + /// 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 BookshelfPrivateEndpointConnectionData BookshelfPrivateEndpointConnectionData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, PrivateEndpointConnectionProperties properties = default) + { + return new BookshelfPrivateEndpointConnectionData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// A private link resource for Bookshelf. + /// 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 BookshelfPrivateLinkResourceData BookshelfPrivateLinkResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DiscoveryPrivateLinkResourceProperties properties = default) + { + return new BookshelfPrivateLinkResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// Properties of a private link resource. + /// The private link resource group id. + /// The private link resource required member names. + /// The private link resource private link DNS zone name. + /// A new instance for mocking. + public static DiscoveryPrivateLinkResourceProperties DiscoveryPrivateLinkResourceProperties(string groupId = default, IEnumerable requiredMembers = default, IEnumerable requiredZoneNames = default) + { + requiredMembers ??= new ChangeTrackingList(); + requiredZoneNames ??= new ChangeTrackingList(); + + return new DiscoveryPrivateLinkResourceProperties(groupId, requiredMembers.ToList(), requiredZoneNames.ToList(), additionalBinaryDataProperties: null); + } + + /// Tool 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ToolData ToolData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, ToolProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new ToolData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Discovery Tool list item properties. + /// The status of the last operation. + /// The version of a resource definition. + /// Environment variables to make available. + /// The JSON content for defining a resource. + /// A new instance for mocking. + public static ToolProperties ToolProperties(ProvisioningState? provisioningState = default, string version = default, IDictionary environmentVariables = default, IDictionary definitionContent = default) + { + environmentVariables ??= new ChangeTrackingDictionary(); + definitionContent ??= new ChangeTrackingDictionary(); + + return new ToolProperties(provisioningState, version, environmentVariables, definitionContent, additionalBinaryDataProperties: null); + } + + /// Project 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ProjectData ProjectData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, ProjectProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new ProjectData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// The status of the last operation. + /// Foundry project endpoint URI. + /// Allowed StorageContainers (Control plane resource references). + /// Default preferences to guide AI behaviors in this project. + /// A new instance for mocking. + public static ProjectProperties ProjectProperties(ProvisioningState? provisioningState = default, Uri foundryProjectEndpoint = default, IEnumerable storageContainerIds = default, string behaviorPreferences = default) + { + storageContainerIds ??= new ChangeTrackingList(); + + return new ProjectProperties(provisioningState, foundryProjectEndpoint, storageContainerIds.ToList(), behaviorPreferences is null ? default : new ProjectSettings(behaviorPreferences, null), additionalBinaryDataProperties: null); + } + + /// Workspace 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static WorkspaceData WorkspaceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, WorkspaceProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new WorkspaceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// The status of the last operation. + /// List of linked SuperComputers. + /// workspace API endpoint Uri. + /// workspace User Interface Uri. + /// Identity IDs used for leveraging Workspace resources. + /// Whether or not to use a customer managed key when encrypting data at rest. + /// The key to use for encrypting data at rest when customer managed keys are enabled. + /// The Log Analytics Cluster to use for debug logs. This is required when Customer Managed Keys are enabled. + /// List of private endpoint connections. + /// Whether or not public network access is allowed for this resource. For security reasons, it is recommended to disable it whenever possible. + /// Agent Subnet ID for agent resources. + /// Private Endpoint Subnet ID for private endpoint connections. + /// Function Subnet ID for workspace resources. + /// The resource group for resources managed on behalf of customer. + /// Managed-On-Behalf-Of broker resources. + /// A new instance for mocking. + public static WorkspaceProperties WorkspaceProperties(ProvisioningState? provisioningState = default, IEnumerable supercomputerIds = default, Uri workspaceApiUri = default, Uri workspaceUiUri = default, Identity workspaceIdentity = default, CustomerManagedKeys? customerManagedKeys = default, KeyVaultProperties keyVaultProperties = default, ResourceIdentifier logAnalyticsClusterId = default, IEnumerable privateEndpointConnections = default, PublicNetworkAccess? publicNetworkAccess = default, ResourceIdentifier agentSubnetId = default, ResourceIdentifier privateEndpointSubnetId = default, ResourceIdentifier workspaceSubnetId = default, string managedResourceGroup = default, IEnumerable managedOnBehalfOfMoboBrokerResources = default) + { + supercomputerIds ??= new ChangeTrackingList(); + privateEndpointConnections ??= new ChangeTrackingList(); + + return new WorkspaceProperties( + provisioningState, + supercomputerIds.ToList(), + workspaceApiUri, + workspaceUiUri, + workspaceIdentity, + customerManagedKeys, + keyVaultProperties, + logAnalyticsClusterId, + privateEndpointConnections.ToList(), + publicNetworkAccess, + agentSubnetId, + privateEndpointSubnetId, + workspaceSubnetId, + managedResourceGroup, + managedOnBehalfOfMoboBrokerResources is null ? default : new WithMoboBrokerResources((managedOnBehalfOfMoboBrokerResources ?? new ChangeTrackingList()).ToList(), null), + additionalBinaryDataProperties: null); + } + + /// For user assigned identity resource property. + /// The resource ID of the user assigned identity. + /// The principal ID of the assigned identity. + /// The client ID of the assigned identity. + /// A new instance for mocking. + public static Identity Identity(ResourceIdentifier id = default, Guid? principalId = default, Guid? clientId = default) + { + return new Identity(id, principalId, clientId, additionalBinaryDataProperties: null); + } + + /// The Private Endpoint Connection resource for Workspace. + /// 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 WorkspacePrivateEndpointConnectionData WorkspacePrivateEndpointConnectionData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, PrivateEndpointConnectionProperties properties = default) + { + return new WorkspacePrivateEndpointConnectionData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// Represents a deployment that ties a specific model family to a user defined deployment name used when invoking the chat model. + /// 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 ChatModelDeploymentData ChatModelDeploymentData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, ChatModelDeploymentProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new ChatModelDeploymentData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Defines a deployment binding a specific model family to a user-defined deployment name for chat inference. + /// The status of the last operation. + /// Model format as published by the provider. Verify supported formats per region using the Model Catalog API. + /// Canonical provider model name available in the selected region. Verify supported values per region using the Model Catalog API. + /// A new instance for mocking. + public static ChatModelDeploymentProperties ChatModelDeploymentProperties(ProvisioningState? provisioningState = default, string modelFormat = default, string modelName = default) + { + return new ChatModelDeploymentProperties(provisioningState, modelFormat, modelName, additionalBinaryDataProperties: null); + } + + /// A private link resource for Workspace. + /// 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 WorkspacePrivateLinkResourceData WorkspacePrivateLinkResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DiscoveryPrivateLinkResourceProperties properties = default) + { + return new WorkspacePrivateLinkResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// NodePool 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static NodePoolData NodePoolData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, NodePoolProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new NodePoolData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// NodePool properties. + /// The status of the last operation. + /// The node pool subnet. + /// The size of the underlying Azure VM. + /// The maximum number of nodes. + /// The minimum number of nodes. + /// The Virtual Machine Scale Set priority. If not specified, the default is 'Regular'. + /// A new instance for mocking. + public static NodePoolProperties NodePoolProperties(ProvisioningState? provisioningState = default, ResourceIdentifier subnetId = default, VmSize vmSize = default, int maxNodeCount = default, int? minNodeCount = default, ScaleSetPriority? scaleSetPriority = default) + { + return new NodePoolProperties( + provisioningState, + subnetId, + vmSize, + maxNodeCount, + minNodeCount, + scaleSetPriority, + additionalBinaryDataProperties: null); + } + + /// Supercomputer 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static SupercomputerData SupercomputerData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, SupercomputerProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new SupercomputerData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// The status of the last operation. + /// + /// System Subnet ID associated with managed NodePool for system resources. + /// It should have connectivity to the child NodePool subnets. + /// + /// + /// System Subnet ID associated with AKS apiserver. Must be delegated to Microsoft.ContainerService/managedClusters. + /// It should have connectivity to the system subnet and nodepool subnets. + /// + /// + /// Network egress type provisioned for the supercomputer workloads. + /// Defaults to LoadBalancer if not specified. + /// If None is specified, the customer is responsible for providing outbound connectivity for Supercomputer functionality. + /// + /// The SKU to use for the system node pool. + /// Dictionary of identity properties. + /// Whether or not to use a customer managed key when encrypting data at rest. + /// Disk Encryption Set ID to use for Customer Managed Keys encryption. Required if Customer Managed Keys is enabled. + /// The Log Analytics Cluster to use for debug logs. This is required when Customer Managed Keys are enabled. + /// The resource group for resources managed on behalf of customer. + /// Managed-On-Behalf-Of broker resources. + /// A new instance for mocking. + public static SupercomputerProperties SupercomputerProperties(ProvisioningState? provisioningState = default, ResourceIdentifier subnetId = default, ResourceIdentifier managementSubnetId = default, NetworkEgressType? outboundType = default, SystemSku? systemSku = default, SupercomputerIdentities identities = default, CustomerManagedKeys? customerManagedKeys = default, ResourceIdentifier diskEncryptionSetId = default, ResourceIdentifier logAnalyticsClusterId = default, string managedResourceGroup = default, IEnumerable managedOnBehalfOfMoboBrokerResources = default) + { + return new SupercomputerProperties( + provisioningState, + subnetId, + managementSubnetId, + outboundType, + systemSku, + identities, + customerManagedKeys, + diskEncryptionSetId, + logAnalyticsClusterId, + managedResourceGroup, + managedOnBehalfOfMoboBrokerResources is null ? default : new WithMoboBrokerResources((managedOnBehalfOfMoboBrokerResources ?? new ChangeTrackingList()).ToList(), null), + additionalBinaryDataProperties: null); + } + + /// Dictionary of identity properties for the Supercomputer. + /// Cluster identity ID. + /// + /// Kubelet identity ID used by the supercomputer. + /// This identity is used by the supercomputer at node level to access Azure resources. + /// This identity must have ManagedIdentityOperator role on the clusterIdentity. + /// + /// User assigned identity IDs to be used by workloads as federated credentials running on supercomputer. The key value must be the resource ID of the identity resource. + /// A new instance for mocking. + public static SupercomputerIdentities SupercomputerIdentities(Identity clusterIdentity = default, Identity kubeletIdentity = default, IDictionary workloadIdentities = default) + { + workloadIdentities ??= new ChangeTrackingDictionary(); + + return new SupercomputerIdentities(clusterIdentity, kubeletIdentity, workloadIdentities, additionalBinaryDataProperties: null); + } + + /// Storage Asset 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static StorageAssetData StorageAssetData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, StorageAssetProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new StorageAssetData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Storage Asset properties. + /// The description. + /// The status of the last operation. + /// The path to the data within its parent container. This should be relative to the root of the parent container. + /// A new instance for mocking. + public static StorageAssetProperties StorageAssetProperties(string description = default, ProvisioningState? provisioningState = default, string path = default) + { + return new StorageAssetProperties(description, provisioningState, path, additionalBinaryDataProperties: null); + } + + /// Storage Container 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. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static StorageContainerData StorageContainerData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, StorageContainerProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new StorageContainerData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Storage Container properties. + /// The status of the last operation. + /// Storage store properties. + /// A new instance for mocking. + public static StorageContainerProperties StorageContainerProperties(ProvisioningState? provisioningState = default, StorageStore storageStore = default) + { + return new StorageContainerProperties(provisioningState, storageStore, additionalBinaryDataProperties: null); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfCollection.cs new file mode 100644 index 000000000000..1b5234eb4439 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfCollection.cs @@ -0,0 +1,580 @@ +// 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; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Discovery +{ + /// + /// 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 GetBookshelves method from an instance of . + /// + public partial class BookshelfCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _bookshelvesClientDiagnostics; + private readonly Bookshelves _bookshelvesRestClient; + + /// Initializes a new instance of BookshelfCollection for mocking. + protected BookshelfCollection() + { + } + + /// 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 BookshelfCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(BookshelfResource.ResourceType, out string bookshelfApiVersion); + _bookshelvesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", BookshelfResource.ResourceType.Namespace, Diagnostics); + _bookshelvesRestClient = new Bookshelves(_bookshelvesClientDiagnostics, Pipeline, Endpoint, bookshelfApiVersion ?? "2026-02-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), nameof(id)); + } + } + + /// + /// Create a Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Bookshelf. + /// 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 bookshelfName, BookshelfData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, bookshelfName, BookshelfData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new BookshelfOperationSource(Client), + _bookshelvesClientDiagnostics, + 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 Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Bookshelf. + /// 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 bookshelfName, BookshelfData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, bookshelfName, BookshelfData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new BookshelfOperationSource(Client), + _bookshelvesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, bookshelfName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, bookshelfName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Bookshelf resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves. + /// + /// + /// Operation Id. + /// Bookshelves_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 BookshelvesGetByResourceGroupAsyncCollectionResultOfT(_bookshelvesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new BookshelfResource(Client, data)); + } + + /// + /// List Bookshelf resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves. + /// + /// + /// Operation Id. + /// Bookshelves_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 BookshelvesGetByResourceGroupCollectionResultOfT(_bookshelvesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new BookshelfResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, bookshelfName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, bookshelfName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, bookshelfName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, bookshelfName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfData.Serialization.cs new file mode 100644 index 000000000000..4f1af65f88e1 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Bookshelf tracked resource. + public partial class BookshelfData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BookshelfData() + { + } + + /// 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 DeserializeBookshelfData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BookshelfData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(BookshelfData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BookshelfData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (BookshelfData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(BookshelfData bookshelfData) + { + if (bookshelfData == null) + { + return null; + } + return RequestContent.Create(bookshelfData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static BookshelfData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBookshelfData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(BookshelfData)} 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. + BookshelfData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (BookshelfData)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(BookshelfData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBookshelfData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BookshelfData DeserializeBookshelfData(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; + BookshelfProperties 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, AzureResourceManagerDiscoveryContext.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 = BookshelfProperties.DeserializeBookshelfProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BookshelfData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfData.cs new file mode 100644 index 000000000000..3c801ba62380 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Bookshelf tracked resource. + public partial class BookshelfData : 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 BookshelfData(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 BookshelfData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, BookshelfProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public BookshelfProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionCollection.cs new file mode 100644 index 000000000000..6e055390c68e --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionCollection.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.Discovery +{ + /// + /// 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 GetBookshelfPrivateEndpointConnections method from an instance of . + /// + public partial class BookshelfPrivateEndpointConnectionCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _bookshelfPrivateEndpointConnectionsClientDiagnostics; + private readonly BookshelfPrivateEndpointConnections _bookshelfPrivateEndpointConnectionsRestClient; + + /// Initializes a new instance of BookshelfPrivateEndpointConnectionCollection for mocking. + protected BookshelfPrivateEndpointConnectionCollection() + { + } + + /// 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 BookshelfPrivateEndpointConnectionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(BookshelfPrivateEndpointConnectionResource.ResourceType, out string bookshelfPrivateEndpointConnectionApiVersion); + _bookshelfPrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", BookshelfPrivateEndpointConnectionResource.ResourceType.Namespace, Diagnostics); + _bookshelfPrivateEndpointConnectionsRestClient = new BookshelfPrivateEndpointConnections(_bookshelfPrivateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, bookshelfPrivateEndpointConnectionApiVersion ?? "2026-02-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != BookshelfResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, BookshelfResource.ResourceType), nameof(id)); + } + } + + /// + /// Approves or updates the specified private endpoint connection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 private endpoint connection associated with the Azure 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 privateEndpointConnectionName, BookshelfPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, BookshelfPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new BookshelfPrivateEndpointConnectionOperationSource(Client), + _bookshelfPrivateEndpointConnectionsClientDiagnostics, + 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; + } + } + + /// + /// Approves or updates the specified private endpoint connection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 private endpoint connection associated with the Azure 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 privateEndpointConnectionName, BookshelfPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, BookshelfPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new BookshelfPrivateEndpointConnectionOperationSource(Client), + _bookshelfPrivateEndpointConnectionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private endpoint connection associated with the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(BookshelfPrivateEndpointConnectionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private endpoint connection associated with the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BookshelfPrivateEndpointConnectionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all private endpoint connections for a bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_ListByBookshelf. + /// + /// + /// Default Api Version. + /// 2026-02-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 BookshelfPrivateEndpointConnectionsGetByBookshelfAsyncCollectionResultOfT(_bookshelfPrivateEndpointConnectionsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new BookshelfPrivateEndpointConnectionResource(Client, data)); + } + + /// + /// Lists all private endpoint connections for a bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_ListByBookshelf. + /// + /// + /// Default Api Version. + /// 2026-02-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 BookshelfPrivateEndpointConnectionsGetByBookshelfCollectionResultOfT(_bookshelfPrivateEndpointConnectionsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new BookshelfPrivateEndpointConnectionResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateEndpointConnectionResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionData.Serialization.cs new file mode 100644 index 000000000000..448feee10564 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionData.Serialization.cs @@ -0,0 +1,194 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// The Private Endpoint Connection resource for Bookshelf. + public partial class BookshelfPrivateEndpointConnectionData : ResourceData, IJsonModel + { + /// 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 DeserializeBookshelfPrivateEndpointConnectionData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BookshelfPrivateEndpointConnectionData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(BookshelfPrivateEndpointConnectionData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BookshelfPrivateEndpointConnectionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (BookshelfPrivateEndpointConnectionData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(BookshelfPrivateEndpointConnectionData bookshelfPrivateEndpointConnectionData) + { + if (bookshelfPrivateEndpointConnectionData == null) + { + return null; + } + return RequestContent.Create(bookshelfPrivateEndpointConnectionData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static BookshelfPrivateEndpointConnectionData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBookshelfPrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(BookshelfPrivateEndpointConnectionData)} 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. + BookshelfPrivateEndpointConnectionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (BookshelfPrivateEndpointConnectionData)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(BookshelfPrivateEndpointConnectionData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBookshelfPrivateEndpointConnectionData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BookshelfPrivateEndpointConnectionData DeserializeBookshelfPrivateEndpointConnectionData(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(); + PrivateEndpointConnectionProperties 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, AzureResourceManagerDiscoveryContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = PrivateEndpointConnectionProperties.DeserializePrivateEndpointConnectionProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BookshelfPrivateEndpointConnectionData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionData.cs new file mode 100644 index 000000000000..7c1ab21b5b8d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// The Private Endpoint Connection resource for Bookshelf. + public partial class BookshelfPrivateEndpointConnectionData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public BookshelfPrivateEndpointConnectionData() + { + } + + /// 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 BookshelfPrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, PrivateEndpointConnectionProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public PrivateEndpointConnectionProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionResource.Serialization.cs new file mode 100644 index 000000000000..854f4bf072fb --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionResource.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.Discovery +{ + /// + public partial class BookshelfPrivateEndpointConnectionResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new BookshelfPrivateEndpointConnectionData(); + + /// 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. + BookshelfPrivateEndpointConnectionData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + BookshelfPrivateEndpointConnectionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionResource.cs new file mode 100644 index 000000000000..2f436d13167f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateEndpointConnectionResource.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.Discovery +{ + /// + /// A class representing a BookshelfPrivateEndpointConnection 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 GetBookshelfPrivateEndpointConnections method. + /// + public partial class BookshelfPrivateEndpointConnectionResource : ArmResource + { + private readonly ClientDiagnostics _bookshelfPrivateEndpointConnectionsClientDiagnostics; + private readonly BookshelfPrivateEndpointConnections _bookshelfPrivateEndpointConnectionsRestClient; + private readonly BookshelfPrivateEndpointConnectionData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/bookshelves/privateEndpointConnections"; + + /// Initializes a new instance of BookshelfPrivateEndpointConnectionResource for mocking. + protected BookshelfPrivateEndpointConnectionResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal BookshelfPrivateEndpointConnectionResource(ArmClient client, BookshelfPrivateEndpointConnectionData 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 BookshelfPrivateEndpointConnectionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string bookshelfPrivateEndpointConnectionApiVersion); + _bookshelfPrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _bookshelfPrivateEndpointConnectionsRestClient = new BookshelfPrivateEndpointConnections(_bookshelfPrivateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, bookshelfPrivateEndpointConnectionApiVersion ?? "2026-02-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 BookshelfPrivateEndpointConnectionData 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 bookshelfName. + /// The privateEndpointConnectionName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string bookshelfName, string privateEndpointConnectionName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}"; + 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), nameof(id)); + } + } + + /// + /// Gets the specified private endpoint connection associated with the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.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(BookshelfPrivateEndpointConnectionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private endpoint connection associated with the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BookshelfPrivateEndpointConnectionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified private endpoint connection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_bookshelfPrivateEndpointConnectionsClientDiagnostics, 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; + } + } + + /// + /// Deletes the specified private endpoint connection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_bookshelfPrivateEndpointConnectionsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a BookshelfPrivateEndpointConnection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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, BookshelfPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, BookshelfPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new BookshelfPrivateEndpointConnectionOperationSource(Client), + _bookshelfPrivateEndpointConnectionsClientDiagnostics, + 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; + } + } + + /// + /// Update a BookshelfPrivateEndpointConnection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateEndpointConnections_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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, BookshelfPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _bookshelfPrivateEndpointConnectionsClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateEndpointConnectionsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, BookshelfPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new BookshelfPrivateEndpointConnectionOperationSource(Client), + _bookshelfPrivateEndpointConnectionsClientDiagnostics, + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResource.Serialization.cs new file mode 100644 index 000000000000..3e2329e53891 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResource.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.Discovery +{ + /// + public partial class BookshelfPrivateLinkResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new BookshelfPrivateLinkResourceData(); + + /// 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. + BookshelfPrivateLinkResourceData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + BookshelfPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResource.cs new file mode 100644 index 000000000000..0ba48f972617 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResource.cs @@ -0,0 +1,190 @@ +// 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.Discovery +{ + /// + /// A class representing a BookshelfPrivateLinkResource 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 GetBookshelfPrivateLinkResources method. + /// + public partial class BookshelfPrivateLinkResource : ArmResource + { + private readonly ClientDiagnostics _bookshelfPrivateLinkResourcesClientDiagnostics; + private readonly BookshelfPrivateLinkResources _bookshelfPrivateLinkResourcesRestClient; + private readonly BookshelfPrivateLinkResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/bookshelves/privateLinkResources"; + + /// Initializes a new instance of BookshelfPrivateLinkResource for mocking. + protected BookshelfPrivateLinkResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal BookshelfPrivateLinkResource(ArmClient client, BookshelfPrivateLinkResourceData 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 BookshelfPrivateLinkResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string bookshelfPrivateLinkResourceApiVersion); + _bookshelfPrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _bookshelfPrivateLinkResourcesRestClient = new BookshelfPrivateLinkResources(_bookshelfPrivateLinkResourcesClientDiagnostics, Pipeline, Endpoint, bookshelfPrivateLinkResourceApiVersion ?? "2026-02-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 BookshelfPrivateLinkResourceData 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 bookshelfName. + /// The privateLinkResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string bookshelfName, string privateLinkResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources/{privateLinkResourceName}"; + 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), nameof(id)); + } + } + + /// + /// Gets the specified private link resource for the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _bookshelfPrivateLinkResourcesClientDiagnostics.CreateScope("BookshelfPrivateLinkResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateLinkResourcesRestClient.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(BookshelfPrivateLinkResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private link resource for the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _bookshelfPrivateLinkResourcesClientDiagnostics.CreateScope("BookshelfPrivateLinkResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BookshelfPrivateLinkResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResourceCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResourceCollection.cs new file mode 100644 index 000000000000..db83edc782ec --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResourceCollection.cs @@ -0,0 +1,463 @@ +// 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.Discovery +{ + /// + /// 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 GetBookshelfPrivateLinkResources method from an instance of . + /// + public partial class BookshelfPrivateLinkResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _bookshelfPrivateLinkResourcesClientDiagnostics; + private readonly BookshelfPrivateLinkResources _bookshelfPrivateLinkResourcesRestClient; + + /// Initializes a new instance of BookshelfPrivateLinkResourceCollection for mocking. + protected BookshelfPrivateLinkResourceCollection() + { + } + + /// 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 BookshelfPrivateLinkResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(BookshelfPrivateLinkResource.ResourceType, out string bookshelfPrivateLinkResourceApiVersion); + _bookshelfPrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", BookshelfPrivateLinkResource.ResourceType.Namespace, Diagnostics); + _bookshelfPrivateLinkResourcesRestClient = new BookshelfPrivateLinkResources(_bookshelfPrivateLinkResourcesClientDiagnostics, Pipeline, Endpoint, bookshelfPrivateLinkResourceApiVersion ?? "2026-02-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != BookshelfResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, BookshelfResource.ResourceType), nameof(id)); + } + } + + /// + /// Gets the specified private link resource for the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure 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 privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _bookshelfPrivateLinkResourcesClientDiagnostics.CreateScope("BookshelfPrivateLinkResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(BookshelfPrivateLinkResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private link resource for the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _bookshelfPrivateLinkResourcesClientDiagnostics.CreateScope("BookshelfPrivateLinkResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BookshelfPrivateLinkResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all private link resources for the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_ListByBookshelf. + /// + /// + /// Default Api Version. + /// 2026-02-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 BookshelfPrivateLinkResourcesGetByBookshelfAsyncCollectionResultOfT(_bookshelfPrivateLinkResourcesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new BookshelfPrivateLinkResource(Client, data)); + } + + /// + /// Lists all private link resources for the bookshelf. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_ListByBookshelf. + /// + /// + /// Default Api Version. + /// 2026-02-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 BookshelfPrivateLinkResourcesGetByBookshelfCollectionResultOfT(_bookshelfPrivateLinkResourcesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new BookshelfPrivateLinkResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure 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 privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _bookshelfPrivateLinkResourcesClientDiagnostics.CreateScope("BookshelfPrivateLinkResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _bookshelfPrivateLinkResourcesClientDiagnostics.CreateScope("BookshelfPrivateLinkResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure 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 privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _bookshelfPrivateLinkResourcesClientDiagnostics.CreateScope("BookshelfPrivateLinkResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// BookshelfPrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _bookshelfPrivateLinkResourcesClientDiagnostics.CreateScope("BookshelfPrivateLinkResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelfPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(BookshelfPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((BookshelfPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfPrivateLinkResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResourceData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResourceData.Serialization.cs new file mode 100644 index 000000000000..5c5295bd9481 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResourceData.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; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// A private link resource for Bookshelf. + public partial class BookshelfPrivateLinkResourceData : ResourceData, IJsonModel + { + /// 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 DeserializeBookshelfPrivateLinkResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BookshelfPrivateLinkResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(BookshelfPrivateLinkResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BookshelfPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (BookshelfPrivateLinkResourceData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static BookshelfPrivateLinkResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBookshelfPrivateLinkResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(BookshelfPrivateLinkResourceData)} 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. + BookshelfPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (BookshelfPrivateLinkResourceData)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(BookshelfPrivateLinkResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBookshelfPrivateLinkResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BookshelfPrivateLinkResourceData DeserializeBookshelfPrivateLinkResourceData(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(); + DiscoveryPrivateLinkResourceProperties 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, AzureResourceManagerDiscoveryContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = DiscoveryPrivateLinkResourceProperties.DeserializeDiscoveryPrivateLinkResourceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BookshelfPrivateLinkResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResourceData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResourceData.cs new file mode 100644 index 000000000000..424fb6f237ec --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfPrivateLinkResourceData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// A private link resource for Bookshelf. + public partial class BookshelfPrivateLinkResourceData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal BookshelfPrivateLinkResourceData() + { + } + + /// 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 BookshelfPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DiscoveryPrivateLinkResourceProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public DiscoveryPrivateLinkResourceProperties Properties { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfResource.Serialization.cs new file mode 100644 index 000000000000..211f0a68d738 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfResource.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.Discovery +{ + /// + public partial class BookshelfResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new BookshelfData(); + + /// 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. + BookshelfData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + BookshelfData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfResource.cs new file mode 100644 index 000000000000..2381069a3a57 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/BookshelfResource.cs @@ -0,0 +1,747 @@ +// 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.Discovery +{ + /// + /// A class representing a Bookshelf 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 GetBookshelves method. + /// + public partial class BookshelfResource : ArmResource + { + private readonly ClientDiagnostics _bookshelvesClientDiagnostics; + private readonly Bookshelves _bookshelvesRestClient; + private readonly BookshelfData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/bookshelves"; + + /// Initializes a new instance of BookshelfResource for mocking. + protected BookshelfResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal BookshelfResource(ArmClient client, BookshelfData 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 BookshelfResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string bookshelfApiVersion); + _bookshelvesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _bookshelvesRestClient = new Bookshelves(_bookshelvesClientDiagnostics, Pipeline, Endpoint, bookshelfApiVersion ?? "2026-02-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 BookshelfData 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 bookshelfName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string bookshelfName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}"; + 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), nameof(id)); + } + } + + /// + /// Get a Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, BookshelfData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, BookshelfData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new BookshelfOperationSource(Client), + _bookshelvesClientDiagnostics, + 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 Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, BookshelfData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, BookshelfData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new BookshelfOperationSource(Client), + _bookshelvesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_bookshelvesClientDiagnostics, 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 Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _bookshelvesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_bookshelvesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.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 = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + else + { + BookshelfData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + BookshelfData patch = new BookshelfData(); + 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 = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.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 = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + else + { + BookshelfData current = Get(cancellationToken: cancellationToken).Value.Data; + BookshelfData patch = new BookshelfData(); + 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 = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.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 = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + else + { + BookshelfData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + BookshelfData patch = new BookshelfData(); + 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 = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.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 = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + else + { + BookshelfData current = Get(cancellationToken: cancellationToken).Value.Data; + BookshelfData patch = new BookshelfData(); + 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 = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.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 = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + else + { + BookshelfData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + BookshelfData patch = new BookshelfData(); + 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 = _bookshelvesClientDiagnostics.CreateScope("BookshelfResource.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 = _bookshelvesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(BookshelfData.FromResponse(result), result); + return Response.FromValue(new BookshelfResource(Client, response.Value), response.GetRawResponse()); + } + else + { + BookshelfData current = Get(cancellationToken: cancellationToken).Value.Data; + BookshelfData patch = new BookshelfData(); + 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 BookshelfPrivateEndpointConnections in the . + /// An object representing collection of BookshelfPrivateEndpointConnections and their operations over a BookshelfPrivateEndpointConnectionResource. + public virtual BookshelfPrivateEndpointConnectionCollection GetBookshelfPrivateEndpointConnections() + { + return GetCachedClient(client => new BookshelfPrivateEndpointConnectionCollection(client, Id)); + } + + /// Gets the specified private endpoint connection associated with the bookshelf. + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetBookshelfPrivateEndpointConnectionAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + return await GetBookshelfPrivateEndpointConnections().GetAsync(privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); + } + + /// Gets the specified private endpoint connection associated with the bookshelf. + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetBookshelfPrivateEndpointConnection(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + return GetBookshelfPrivateEndpointConnections().Get(privateEndpointConnectionName, cancellationToken); + } + + /// Gets a collection of BookshelfPrivateLinkResources in the . + /// An object representing collection of BookshelfPrivateLinkResources and their operations over a BookshelfPrivateLinkResource. + public virtual BookshelfPrivateLinkResourceCollection GetBookshelfPrivateLinkResources() + { + return GetCachedClient(client => new BookshelfPrivateLinkResourceCollection(client, Id)); + } + + /// Gets the specified private link resource for the bookshelf. + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetBookshelfPrivateLinkResourceAsync(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + return await GetBookshelfPrivateLinkResources().GetAsync(privateLinkResourceName, cancellationToken).ConfigureAwait(false); + } + + /// Gets the specified private link resource for the bookshelf. + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetBookshelfPrivateLinkResource(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + return GetBookshelfPrivateLinkResources().Get(privateLinkResourceName, cancellationToken); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentCollection.cs new file mode 100644 index 000000000000..cea5d782e4af --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentCollection.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.Discovery +{ + /// + /// 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 GetChatModelDeployments method from an instance of . + /// + public partial class ChatModelDeploymentCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _chatModelDeploymentsClientDiagnostics; + private readonly ChatModelDeployments _chatModelDeploymentsRestClient; + + /// Initializes a new instance of ChatModelDeploymentCollection for mocking. + protected ChatModelDeploymentCollection() + { + } + + /// 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 ChatModelDeploymentCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ChatModelDeploymentResource.ResourceType, out string chatModelDeploymentApiVersion); + _chatModelDeploymentsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ChatModelDeploymentResource.ResourceType.Namespace, Diagnostics); + _chatModelDeploymentsRestClient = new ChatModelDeployments(_chatModelDeploymentsClientDiagnostics, Pipeline, Endpoint, chatModelDeploymentApiVersion ?? "2026-02-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != WorkspaceResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, WorkspaceResource.ResourceType), nameof(id)); + } + } + + /// + /// Create a ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 ChatModelDeployment. + /// 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 chatModelDeploymentName, ChatModelDeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, chatModelDeploymentName, ChatModelDeploymentData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ChatModelDeploymentOperationSource(Client), + _chatModelDeploymentsClientDiagnostics, + 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 ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 ChatModelDeployment. + /// 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 chatModelDeploymentName, ChatModelDeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, chatModelDeploymentName, ChatModelDeploymentData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ChatModelDeploymentOperationSource(Client), + _chatModelDeploymentsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the ChatModelDeployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string chatModelDeploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, chatModelDeploymentName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the ChatModelDeployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string chatModelDeploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, chatModelDeploymentName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List ChatModelDeployment resources by Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments. + /// + /// + /// Operation Id. + /// ChatModelDeployments_ListByWorkspace. + /// + /// + /// Default Api Version. + /// 2026-02-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 ChatModelDeploymentsGetByWorkspaceAsyncCollectionResultOfT(_chatModelDeploymentsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new ChatModelDeploymentResource(Client, data)); + } + + /// + /// List ChatModelDeployment resources by Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments. + /// + /// + /// Operation Id. + /// ChatModelDeployments_ListByWorkspace. + /// + /// + /// Default Api Version. + /// 2026-02-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 ChatModelDeploymentsGetByWorkspaceCollectionResultOfT(_chatModelDeploymentsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new ChatModelDeploymentResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the ChatModelDeployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string chatModelDeploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, chatModelDeploymentName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ChatModelDeploymentData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the ChatModelDeployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string chatModelDeploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, chatModelDeploymentName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ChatModelDeploymentData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the ChatModelDeployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string chatModelDeploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, chatModelDeploymentName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ChatModelDeploymentData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the ChatModelDeployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string chatModelDeploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, chatModelDeploymentName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ChatModelDeploymentData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ChatModelDeploymentResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentData.Serialization.cs new file mode 100644 index 000000000000..78a8455ecff6 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Represents a deployment that ties a specific model family to a user defined deployment name used when invoking the chat model. + public partial class ChatModelDeploymentData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ChatModelDeploymentData() + { + } + + /// 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 DeserializeChatModelDeploymentData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatModelDeploymentData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ChatModelDeploymentData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ChatModelDeploymentData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ChatModelDeploymentData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ChatModelDeploymentData chatModelDeploymentData) + { + if (chatModelDeploymentData == null) + { + return null; + } + return RequestContent.Create(chatModelDeploymentData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static ChatModelDeploymentData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatModelDeploymentData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(ChatModelDeploymentData)} 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. + ChatModelDeploymentData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ChatModelDeploymentData)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(ChatModelDeploymentData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatModelDeploymentData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ChatModelDeploymentData DeserializeChatModelDeploymentData(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; + ChatModelDeploymentProperties 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, AzureResourceManagerDiscoveryContext.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 = ChatModelDeploymentProperties.DeserializeChatModelDeploymentProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChatModelDeploymentData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentData.cs new file mode 100644 index 000000000000..3b167ed1ed36 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Represents a deployment that ties a specific model family to a user defined deployment name used when invoking the chat model. + public partial class ChatModelDeploymentData : 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 ChatModelDeploymentData(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 ChatModelDeploymentData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, ChatModelDeploymentProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public ChatModelDeploymentProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentResource.Serialization.cs new file mode 100644 index 000000000000..e702ca11bafd --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentResource.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.Discovery +{ + /// + public partial class ChatModelDeploymentResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ChatModelDeploymentData(); + + /// 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. + ChatModelDeploymentData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + ChatModelDeploymentData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentResource.cs new file mode 100644 index 000000000000..3654605c611e --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ChatModelDeploymentResource.cs @@ -0,0 +1,682 @@ +// 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.Discovery +{ + /// + /// A class representing a ChatModelDeployment 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 GetChatModelDeployments method. + /// + public partial class ChatModelDeploymentResource : ArmResource + { + private readonly ClientDiagnostics _chatModelDeploymentsClientDiagnostics; + private readonly ChatModelDeployments _chatModelDeploymentsRestClient; + private readonly ChatModelDeploymentData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/workspaces/chatModelDeployments"; + + /// Initializes a new instance of ChatModelDeploymentResource for mocking. + protected ChatModelDeploymentResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ChatModelDeploymentResource(ArmClient client, ChatModelDeploymentData 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 ChatModelDeploymentResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string chatModelDeploymentApiVersion); + _chatModelDeploymentsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _chatModelDeploymentsRestClient = new ChatModelDeployments(_chatModelDeploymentsClientDiagnostics, Pipeline, Endpoint, chatModelDeploymentApiVersion ?? "2026-02-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 ChatModelDeploymentData 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 workspaceName. + /// The chatModelDeploymentName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string chatModelDeploymentName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}"; + 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), nameof(id)); + } + } + + /// + /// Get a ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.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(ChatModelDeploymentData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, ChatModelDeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, ChatModelDeploymentData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ChatModelDeploymentOperationSource(Client), + _chatModelDeploymentsClientDiagnostics, + 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 ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, ChatModelDeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, ChatModelDeploymentData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ChatModelDeploymentOperationSource(Client), + _chatModelDeploymentsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_chatModelDeploymentsClientDiagnostics, 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 ChatModelDeployment + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/chatModelDeployments/{chatModelDeploymentName}. + /// + /// + /// Operation Id. + /// ChatModelDeployments_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _chatModelDeploymentsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_chatModelDeploymentsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.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 = _chatModelDeploymentsRestClient.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(ChatModelDeploymentData.FromResponse(result), result); + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ChatModelDeploymentData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ChatModelDeploymentData patch = new ChatModelDeploymentData(); + 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 = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.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 = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ChatModelDeploymentData current = Get(cancellationToken: cancellationToken).Value.Data; + ChatModelDeploymentData patch = new ChatModelDeploymentData(); + 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 = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.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 = _chatModelDeploymentsRestClient.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(ChatModelDeploymentData.FromResponse(result), result); + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ChatModelDeploymentData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ChatModelDeploymentData patch = new ChatModelDeploymentData(); + 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 = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.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 = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ChatModelDeploymentData current = Get(cancellationToken: cancellationToken).Value.Data; + ChatModelDeploymentData patch = new ChatModelDeploymentData(); + 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 = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.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 = _chatModelDeploymentsRestClient.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(ChatModelDeploymentData.FromResponse(result), result); + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ChatModelDeploymentData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ChatModelDeploymentData patch = new ChatModelDeploymentData(); + 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 = _chatModelDeploymentsClientDiagnostics.CreateScope("ChatModelDeploymentResource.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 = _chatModelDeploymentsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ChatModelDeploymentData.FromResponse(result), result); + return Response.FromValue(new ChatModelDeploymentResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ChatModelDeploymentData current = Get(cancellationToken: cancellationToken).Value.Data; + ChatModelDeploymentData patch = new ChatModelDeploymentData(); + 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; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateEndpointConnectionsGetByBookshelfAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateEndpointConnectionsGetByBookshelfAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..711c34d4cecd --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateEndpointConnectionsGetByBookshelfAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class BookshelfPrivateEndpointConnectionsGetByBookshelfAsyncCollectionResultOfT : AsyncPageable + { + private readonly BookshelfPrivateEndpointConnections _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _bookshelfName; + private readonly RequestContext _context; + + /// Initializes a new instance of BookshelfPrivateEndpointConnectionsGetByBookshelfAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The BookshelfPrivateEndpointConnections 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 name of the Bookshelf. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public BookshelfPrivateEndpointConnectionsGetByBookshelfAsyncCollectionResultOfT(BookshelfPrivateEndpointConnections client, Guid subscriptionId, string resourceGroupName, string bookshelfName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _bookshelfName = bookshelfName; + _context = context; + } + + /// Gets the pages of BookshelfPrivateEndpointConnectionsGetByBookshelfAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BookshelfPrivateEndpointConnectionsGetByBookshelfAsyncCollectionResultOfT 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; + } + BookshelfPrivateEndpointConnectionListResult result = BookshelfPrivateEndpointConnectionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByBookshelfRequest(nextLink, _subscriptionId, _resourceGroupName, _bookshelfName, _context) : _client.CreateGetByBookshelfRequest(_subscriptionId, _resourceGroupName, _bookshelfName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateEndpointConnectionsGetByBookshelfCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateEndpointConnectionsGetByBookshelfCollectionResultOfT.cs new file mode 100644 index 000000000000..2d3ded73716b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateEndpointConnectionsGetByBookshelfCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class BookshelfPrivateEndpointConnectionsGetByBookshelfCollectionResultOfT : Pageable + { + private readonly BookshelfPrivateEndpointConnections _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _bookshelfName; + private readonly RequestContext _context; + + /// Initializes a new instance of BookshelfPrivateEndpointConnectionsGetByBookshelfCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The BookshelfPrivateEndpointConnections 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 name of the Bookshelf. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public BookshelfPrivateEndpointConnectionsGetByBookshelfCollectionResultOfT(BookshelfPrivateEndpointConnections client, Guid subscriptionId, string resourceGroupName, string bookshelfName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _bookshelfName = bookshelfName; + _context = context; + } + + /// Gets the pages of BookshelfPrivateEndpointConnectionsGetByBookshelfCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BookshelfPrivateEndpointConnectionsGetByBookshelfCollectionResultOfT 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; + } + BookshelfPrivateEndpointConnectionListResult result = BookshelfPrivateEndpointConnectionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByBookshelfRequest(nextLink, _subscriptionId, _resourceGroupName, _bookshelfName, _context) : _client.CreateGetByBookshelfRequest(_subscriptionId, _resourceGroupName, _bookshelfName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("BookshelfPrivateEndpointConnectionCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateLinkResourcesGetByBookshelfAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateLinkResourcesGetByBookshelfAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..292164f44278 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateLinkResourcesGetByBookshelfAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class BookshelfPrivateLinkResourcesGetByBookshelfAsyncCollectionResultOfT : AsyncPageable + { + private readonly BookshelfPrivateLinkResources _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _bookshelfName; + private readonly RequestContext _context; + + /// Initializes a new instance of BookshelfPrivateLinkResourcesGetByBookshelfAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The BookshelfPrivateLinkResources 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 name of the Bookshelf. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public BookshelfPrivateLinkResourcesGetByBookshelfAsyncCollectionResultOfT(BookshelfPrivateLinkResources client, Guid subscriptionId, string resourceGroupName, string bookshelfName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _bookshelfName = bookshelfName; + _context = context; + } + + /// Gets the pages of BookshelfPrivateLinkResourcesGetByBookshelfAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BookshelfPrivateLinkResourcesGetByBookshelfAsyncCollectionResultOfT 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; + } + BookshelfPrivateLinkResourceListResult result = BookshelfPrivateLinkResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByBookshelfRequest(nextLink, _subscriptionId, _resourceGroupName, _bookshelfName, _context) : _client.CreateGetByBookshelfRequest(_subscriptionId, _resourceGroupName, _bookshelfName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("BookshelfPrivateLinkResourceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateLinkResourcesGetByBookshelfCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateLinkResourcesGetByBookshelfCollectionResultOfT.cs new file mode 100644 index 000000000000..05e09dadfa2e --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelfPrivateLinkResourcesGetByBookshelfCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class BookshelfPrivateLinkResourcesGetByBookshelfCollectionResultOfT : Pageable + { + private readonly BookshelfPrivateLinkResources _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _bookshelfName; + private readonly RequestContext _context; + + /// Initializes a new instance of BookshelfPrivateLinkResourcesGetByBookshelfCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The BookshelfPrivateLinkResources 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 name of the Bookshelf. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public BookshelfPrivateLinkResourcesGetByBookshelfCollectionResultOfT(BookshelfPrivateLinkResources client, Guid subscriptionId, string resourceGroupName, string bookshelfName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _bookshelfName = bookshelfName; + _context = context; + } + + /// Gets the pages of BookshelfPrivateLinkResourcesGetByBookshelfCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BookshelfPrivateLinkResourcesGetByBookshelfCollectionResultOfT 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; + } + BookshelfPrivateLinkResourceListResult result = BookshelfPrivateLinkResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByBookshelfRequest(nextLink, _subscriptionId, _resourceGroupName, _bookshelfName, _context) : _client.CreateGetByBookshelfRequest(_subscriptionId, _resourceGroupName, _bookshelfName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("BookshelfPrivateLinkResourceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..bb93778356e5 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetByResourceGroupAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class BookshelvesGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly Bookshelves _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of BookshelvesGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Bookshelves 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 BookshelvesGetByResourceGroupAsyncCollectionResultOfT(Bookshelves client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of BookshelvesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BookshelvesGetByResourceGroupAsyncCollectionResultOfT 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; + } + BookshelfListResult result = BookshelfListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("BookshelfCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetByResourceGroupCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..6e6d24938adb --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetByResourceGroupCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class BookshelvesGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly Bookshelves _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of BookshelvesGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Bookshelves 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 BookshelvesGetByResourceGroupCollectionResultOfT(Bookshelves client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of BookshelvesGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BookshelvesGetByResourceGroupCollectionResultOfT 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; + } + BookshelfListResult result = BookshelfListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("BookshelfCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..e8ac21999af0 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetBySubscriptionAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class BookshelvesGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly Bookshelves _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of BookshelvesGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Bookshelves 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 BookshelvesGetBySubscriptionAsyncCollectionResultOfT(Bookshelves client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of BookshelvesGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BookshelvesGetBySubscriptionAsyncCollectionResultOfT 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; + } + BookshelfListResult result = BookshelfListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetBookshelves"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetBySubscriptionCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..3e5d5519a7b3 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/BookshelvesGetBySubscriptionCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class BookshelvesGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly Bookshelves _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of BookshelvesGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Bookshelves 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 BookshelvesGetBySubscriptionCollectionResultOfT(Bookshelves client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of BookshelvesGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BookshelvesGetBySubscriptionCollectionResultOfT 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; + } + BookshelfListResult result = BookshelfListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetBookshelves"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ChatModelDeploymentsGetByWorkspaceAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ChatModelDeploymentsGetByWorkspaceAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..b56a89178bb6 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ChatModelDeploymentsGetByWorkspaceAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class ChatModelDeploymentsGetByWorkspaceAsyncCollectionResultOfT : AsyncPageable + { + private readonly ChatModelDeployments _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ChatModelDeploymentsGetByWorkspaceAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ChatModelDeployments 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 name of the Workspace. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ChatModelDeploymentsGetByWorkspaceAsyncCollectionResultOfT(ChatModelDeployments client, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of ChatModelDeploymentsGetByWorkspaceAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ChatModelDeploymentsGetByWorkspaceAsyncCollectionResultOfT 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; + } + ChatModelDeploymentListResult result = ChatModelDeploymentListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetByWorkspaceRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ChatModelDeploymentCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ChatModelDeploymentsGetByWorkspaceCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ChatModelDeploymentsGetByWorkspaceCollectionResultOfT.cs new file mode 100644 index 000000000000..cbc703e557a4 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ChatModelDeploymentsGetByWorkspaceCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class ChatModelDeploymentsGetByWorkspaceCollectionResultOfT : Pageable + { + private readonly ChatModelDeployments _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ChatModelDeploymentsGetByWorkspaceCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ChatModelDeployments 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 name of the Workspace. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ChatModelDeploymentsGetByWorkspaceCollectionResultOfT(ChatModelDeployments client, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of ChatModelDeploymentsGetByWorkspaceCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ChatModelDeploymentsGetByWorkspaceCollectionResultOfT 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; + } + ChatModelDeploymentListResult result = ChatModelDeploymentListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetByWorkspaceRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ChatModelDeploymentCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/NodePoolsGetBySupercomputerAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/NodePoolsGetBySupercomputerAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..a084d3054be6 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/NodePoolsGetBySupercomputerAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class NodePoolsGetBySupercomputerAsyncCollectionResultOfT : AsyncPageable + { + private readonly NodePools _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _supercomputerName; + private readonly RequestContext _context; + + /// Initializes a new instance of NodePoolsGetBySupercomputerAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The NodePools 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 name of the Supercomputer. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public NodePoolsGetBySupercomputerAsyncCollectionResultOfT(NodePools client, Guid subscriptionId, string resourceGroupName, string supercomputerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _supercomputerName = supercomputerName; + _context = context; + } + + /// Gets the pages of NodePoolsGetBySupercomputerAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of NodePoolsGetBySupercomputerAsyncCollectionResultOfT 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; + } + NodePoolListResult result = NodePoolListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetBySupercomputerRequest(nextLink, _subscriptionId, _resourceGroupName, _supercomputerName, _context) : _client.CreateGetBySupercomputerRequest(_subscriptionId, _resourceGroupName, _supercomputerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("NodePoolCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/NodePoolsGetBySupercomputerCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/NodePoolsGetBySupercomputerCollectionResultOfT.cs new file mode 100644 index 000000000000..13509a0fb746 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/NodePoolsGetBySupercomputerCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class NodePoolsGetBySupercomputerCollectionResultOfT : Pageable + { + private readonly NodePools _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _supercomputerName; + private readonly RequestContext _context; + + /// Initializes a new instance of NodePoolsGetBySupercomputerCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The NodePools 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 name of the Supercomputer. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public NodePoolsGetBySupercomputerCollectionResultOfT(NodePools client, Guid subscriptionId, string resourceGroupName, string supercomputerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _supercomputerName = supercomputerName; + _context = context; + } + + /// Gets the pages of NodePoolsGetBySupercomputerCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of NodePoolsGetBySupercomputerCollectionResultOfT 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; + } + NodePoolListResult result = NodePoolListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetBySupercomputerRequest(nextLink, _subscriptionId, _resourceGroupName, _supercomputerName, _context) : _client.CreateGetBySupercomputerRequest(_subscriptionId, _resourceGroupName, _supercomputerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("NodePoolCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ProjectsGetByWorkspaceAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ProjectsGetByWorkspaceAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..dd9c8c5684c7 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ProjectsGetByWorkspaceAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class ProjectsGetByWorkspaceAsyncCollectionResultOfT : AsyncPageable + { + private readonly Projects _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProjectsGetByWorkspaceAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Projects 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 name of the Workspace. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProjectsGetByWorkspaceAsyncCollectionResultOfT(Projects client, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of ProjectsGetByWorkspaceAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProjectsGetByWorkspaceAsyncCollectionResultOfT 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; + } + ProjectListResult result = ProjectListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetByWorkspaceRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ProjectCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ProjectsGetByWorkspaceCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ProjectsGetByWorkspaceCollectionResultOfT.cs new file mode 100644 index 000000000000..f983cbecbbdf --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ProjectsGetByWorkspaceCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class ProjectsGetByWorkspaceCollectionResultOfT : Pageable + { + private readonly Projects _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProjectsGetByWorkspaceCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Projects 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 name of the Workspace. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProjectsGetByWorkspaceCollectionResultOfT(Projects client, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of ProjectsGetByWorkspaceCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProjectsGetByWorkspaceCollectionResultOfT 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; + } + ProjectListResult result = ProjectListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetByWorkspaceRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ProjectCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageAssetsGetByStorageContainerAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageAssetsGetByStorageContainerAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..c567cbb4835a --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageAssetsGetByStorageContainerAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class StorageAssetsGetByStorageContainerAsyncCollectionResultOfT : AsyncPageable + { + private readonly StorageAssets _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _storageContainerName; + private readonly RequestContext _context; + + /// Initializes a new instance of StorageAssetsGetByStorageContainerAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The StorageAssets 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 name of the StorageContainer. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public StorageAssetsGetByStorageContainerAsyncCollectionResultOfT(StorageAssets client, Guid subscriptionId, string resourceGroupName, string storageContainerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _storageContainerName = storageContainerName; + _context = context; + } + + /// Gets the pages of StorageAssetsGetByStorageContainerAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of StorageAssetsGetByStorageContainerAsyncCollectionResultOfT 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; + } + StorageAssetListResult result = StorageAssetListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByStorageContainerRequest(nextLink, _subscriptionId, _resourceGroupName, _storageContainerName, _context) : _client.CreateGetByStorageContainerRequest(_subscriptionId, _resourceGroupName, _storageContainerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("StorageAssetCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageAssetsGetByStorageContainerCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageAssetsGetByStorageContainerCollectionResultOfT.cs new file mode 100644 index 000000000000..38021c5bee0f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageAssetsGetByStorageContainerCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class StorageAssetsGetByStorageContainerCollectionResultOfT : Pageable + { + private readonly StorageAssets _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _storageContainerName; + private readonly RequestContext _context; + + /// Initializes a new instance of StorageAssetsGetByStorageContainerCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The StorageAssets 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 name of the StorageContainer. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public StorageAssetsGetByStorageContainerCollectionResultOfT(StorageAssets client, Guid subscriptionId, string resourceGroupName, string storageContainerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _storageContainerName = storageContainerName; + _context = context; + } + + /// Gets the pages of StorageAssetsGetByStorageContainerCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of StorageAssetsGetByStorageContainerCollectionResultOfT 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; + } + StorageAssetListResult result = StorageAssetListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByStorageContainerRequest(nextLink, _subscriptionId, _resourceGroupName, _storageContainerName, _context) : _client.CreateGetByStorageContainerRequest(_subscriptionId, _resourceGroupName, _storageContainerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("StorageAssetCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..0bab2d956a88 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetByResourceGroupAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class StorageContainersGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly StorageContainers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of StorageContainersGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The StorageContainers 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 StorageContainersGetByResourceGroupAsyncCollectionResultOfT(StorageContainers client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of StorageContainersGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of StorageContainersGetByResourceGroupAsyncCollectionResultOfT 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; + } + StorageContainerListResult result = StorageContainerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("StorageContainerCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetByResourceGroupCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..53e4b2a8454b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetByResourceGroupCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class StorageContainersGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly StorageContainers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of StorageContainersGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The StorageContainers 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 StorageContainersGetByResourceGroupCollectionResultOfT(StorageContainers client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of StorageContainersGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of StorageContainersGetByResourceGroupCollectionResultOfT 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; + } + StorageContainerListResult result = StorageContainerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("StorageContainerCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..0bc8944314ee --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetBySubscriptionAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class StorageContainersGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly StorageContainers _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of StorageContainersGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The StorageContainers 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 StorageContainersGetBySubscriptionAsyncCollectionResultOfT(StorageContainers client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of StorageContainersGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of StorageContainersGetBySubscriptionAsyncCollectionResultOfT 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; + } + StorageContainerListResult result = StorageContainerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetStorageContainers"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetBySubscriptionCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..91ece1ca1ba2 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/StorageContainersGetBySubscriptionCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class StorageContainersGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly StorageContainers _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of StorageContainersGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The StorageContainers 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 StorageContainersGetBySubscriptionCollectionResultOfT(StorageContainers client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of StorageContainersGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of StorageContainersGetBySubscriptionCollectionResultOfT 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; + } + StorageContainerListResult result = StorageContainerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetStorageContainers"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..ba5d80aa56c9 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetByResourceGroupAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class SupercomputersGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly Supercomputers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of SupercomputersGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Supercomputers 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 SupercomputersGetByResourceGroupAsyncCollectionResultOfT(Supercomputers client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of SupercomputersGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SupercomputersGetByResourceGroupAsyncCollectionResultOfT 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; + } + SupercomputerListResult result = SupercomputerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("SupercomputerCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetByResourceGroupCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..8295ecfd94a2 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetByResourceGroupCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class SupercomputersGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly Supercomputers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of SupercomputersGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Supercomputers 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 SupercomputersGetByResourceGroupCollectionResultOfT(Supercomputers client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of SupercomputersGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SupercomputersGetByResourceGroupCollectionResultOfT 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; + } + SupercomputerListResult result = SupercomputerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("SupercomputerCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..4a02face1efd --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetBySubscriptionAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class SupercomputersGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly Supercomputers _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of SupercomputersGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Supercomputers 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 SupercomputersGetBySubscriptionAsyncCollectionResultOfT(Supercomputers client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of SupercomputersGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SupercomputersGetBySubscriptionAsyncCollectionResultOfT 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; + } + SupercomputerListResult result = SupercomputerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetSupercomputers"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetBySubscriptionCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..a971f5b3771c --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/SupercomputersGetBySubscriptionCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class SupercomputersGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly Supercomputers _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of SupercomputersGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Supercomputers 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 SupercomputersGetBySubscriptionCollectionResultOfT(Supercomputers client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of SupercomputersGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SupercomputersGetBySubscriptionCollectionResultOfT 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; + } + SupercomputerListResult result = SupercomputerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetSupercomputers"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..07342398dec5 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetByResourceGroupAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class ToolsGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly Tools _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ToolsGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Tools 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 ToolsGetByResourceGroupAsyncCollectionResultOfT(Tools client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ToolsGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ToolsGetByResourceGroupAsyncCollectionResultOfT 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; + } + ToolListResult result = ToolListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("ToolCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetByResourceGroupCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..f1e4aafc5717 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetByResourceGroupCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class ToolsGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly Tools _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ToolsGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Tools 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 ToolsGetByResourceGroupCollectionResultOfT(Tools client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ToolsGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ToolsGetByResourceGroupCollectionResultOfT 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; + } + ToolListResult result = ToolListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("ToolCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..8d2ae4582cb5 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetBySubscriptionAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class ToolsGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly Tools _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ToolsGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Tools 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 ToolsGetBySubscriptionAsyncCollectionResultOfT(Tools client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ToolsGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ToolsGetBySubscriptionAsyncCollectionResultOfT 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; + } + ToolListResult result = ToolListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetTools"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetBySubscriptionCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..44ecaa1933eb --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/ToolsGetBySubscriptionCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class ToolsGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly Tools _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ToolsGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Tools 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 ToolsGetBySubscriptionCollectionResultOfT(Tools client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ToolsGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ToolsGetBySubscriptionCollectionResultOfT 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; + } + ToolListResult result = ToolListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetTools"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateEndpointConnectionsGetByWorkspaceAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateEndpointConnectionsGetByWorkspaceAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..49a73721a3c3 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateEndpointConnectionsGetByWorkspaceAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class WorkspacePrivateEndpointConnectionsGetByWorkspaceAsyncCollectionResultOfT : AsyncPageable + { + private readonly WorkspacePrivateEndpointConnections _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of WorkspacePrivateEndpointConnectionsGetByWorkspaceAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The WorkspacePrivateEndpointConnections 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 name of the Workspace. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public WorkspacePrivateEndpointConnectionsGetByWorkspaceAsyncCollectionResultOfT(WorkspacePrivateEndpointConnections client, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of WorkspacePrivateEndpointConnectionsGetByWorkspaceAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WorkspacePrivateEndpointConnectionsGetByWorkspaceAsyncCollectionResultOfT 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; + } + WorkspacePrivateEndpointConnectionListResult result = WorkspacePrivateEndpointConnectionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetByWorkspaceRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateEndpointConnectionsGetByWorkspaceCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateEndpointConnectionsGetByWorkspaceCollectionResultOfT.cs new file mode 100644 index 000000000000..1c2b88a70379 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateEndpointConnectionsGetByWorkspaceCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class WorkspacePrivateEndpointConnectionsGetByWorkspaceCollectionResultOfT : Pageable + { + private readonly WorkspacePrivateEndpointConnections _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of WorkspacePrivateEndpointConnectionsGetByWorkspaceCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The WorkspacePrivateEndpointConnections 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 name of the Workspace. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public WorkspacePrivateEndpointConnectionsGetByWorkspaceCollectionResultOfT(WorkspacePrivateEndpointConnections client, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of WorkspacePrivateEndpointConnectionsGetByWorkspaceCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WorkspacePrivateEndpointConnectionsGetByWorkspaceCollectionResultOfT 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; + } + WorkspacePrivateEndpointConnectionListResult result = WorkspacePrivateEndpointConnectionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetByWorkspaceRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateLinkResourcesGetByWorkspaceAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateLinkResourcesGetByWorkspaceAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..12555888387d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateLinkResourcesGetByWorkspaceAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class WorkspacePrivateLinkResourcesGetByWorkspaceAsyncCollectionResultOfT : AsyncPageable + { + private readonly WorkspacePrivateLinkResources _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of WorkspacePrivateLinkResourcesGetByWorkspaceAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The WorkspacePrivateLinkResources 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 name of the Workspace. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public WorkspacePrivateLinkResourcesGetByWorkspaceAsyncCollectionResultOfT(WorkspacePrivateLinkResources client, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of WorkspacePrivateLinkResourcesGetByWorkspaceAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WorkspacePrivateLinkResourcesGetByWorkspaceAsyncCollectionResultOfT 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; + } + WorkspacePrivateLinkResourceListResult result = WorkspacePrivateLinkResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetByWorkspaceRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("WorkspacePrivateLinkResourceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateLinkResourcesGetByWorkspaceCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateLinkResourcesGetByWorkspaceCollectionResultOfT.cs new file mode 100644 index 000000000000..a2a8d9b3e728 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacePrivateLinkResourcesGetByWorkspaceCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class WorkspacePrivateLinkResourcesGetByWorkspaceCollectionResultOfT : Pageable + { + private readonly WorkspacePrivateLinkResources _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _workspaceName; + private readonly RequestContext _context; + + /// Initializes a new instance of WorkspacePrivateLinkResourcesGetByWorkspaceCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The WorkspacePrivateLinkResources 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 name of the Workspace. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public WorkspacePrivateLinkResourcesGetByWorkspaceCollectionResultOfT(WorkspacePrivateLinkResources client, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _workspaceName = workspaceName; + _context = context; + } + + /// Gets the pages of WorkspacePrivateLinkResourcesGetByWorkspaceCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WorkspacePrivateLinkResourcesGetByWorkspaceCollectionResultOfT 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; + } + WorkspacePrivateLinkResourceListResult result = WorkspacePrivateLinkResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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.CreateNextGetByWorkspaceRequest(nextLink, _subscriptionId, _resourceGroupName, _workspaceName, _context) : _client.CreateGetByWorkspaceRequest(_subscriptionId, _resourceGroupName, _workspaceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("WorkspacePrivateLinkResourceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..86c854058dd5 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetByResourceGroupAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class WorkspacesGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly Workspaces _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of WorkspacesGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Workspaces 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 WorkspacesGetByResourceGroupAsyncCollectionResultOfT(Workspaces client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of WorkspacesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WorkspacesGetByResourceGroupAsyncCollectionResultOfT 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; + } + WorkspaceListResult result = WorkspaceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("WorkspaceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetByResourceGroupCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..60e8df8b334c --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetByResourceGroupCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class WorkspacesGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly Workspaces _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of WorkspacesGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Workspaces 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 WorkspacesGetByResourceGroupCollectionResultOfT(Workspaces client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of WorkspacesGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WorkspacesGetByResourceGroupCollectionResultOfT 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; + } + WorkspaceListResult result = WorkspaceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("WorkspaceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..46162519ab6b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetBySubscriptionAsyncCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class WorkspacesGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly Workspaces _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of WorkspacesGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Workspaces 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 WorkspacesGetBySubscriptionAsyncCollectionResultOfT(Workspaces client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of WorkspacesGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WorkspacesGetBySubscriptionAsyncCollectionResultOfT 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; + } + WorkspaceListResult result = WorkspaceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetWorkspaces"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetBySubscriptionCollectionResultOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..3bd192da5f0c --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/CollectionResults/WorkspacesGetBySubscriptionCollectionResultOfT.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.Discovery.Models; + +namespace Azure.ResourceManager.Discovery +{ + internal partial class WorkspacesGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly Workspaces _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of WorkspacesGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Workspaces 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 WorkspacesGetBySubscriptionCollectionResultOfT(Workspaces client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of WorkspacesGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WorkspacesGetBySubscriptionCollectionResultOfT 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; + } + WorkspaceListResult result = WorkspaceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, 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("MockableDiscoverySubscriptionResource.GetWorkspaces"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/DiscoveryExtensions.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/DiscoveryExtensions.cs new file mode 100644 index 000000000000..09d93bf7bf0b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/DiscoveryExtensions.cs @@ -0,0 +1,729 @@ +// 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.Discovery.Mocking; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Discovery +{ + /// A class to add extension methods to Azure.ResourceManager.Discovery. + public static partial class DiscoveryExtensions + { + /// + private static MockableDiscoveryArmClient GetMockableDiscoveryArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableDiscoveryArmClient(client0, ResourceIdentifier.Root)); + } + + /// + private static MockableDiscoveryResourceGroupResource GetMockableDiscoveryResourceGroupResource(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient(client => new MockableDiscoveryResourceGroupResource(client, resourceGroupResource.Id)); + } + + /// + private static MockableDiscoverySubscriptionResource GetMockableDiscoverySubscriptionResource(SubscriptionResource subscriptionResource) + { + return subscriptionResource.GetCachedClient(client => new MockableDiscoverySubscriptionResource(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 BookshelfResource GetBookshelfResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetBookshelfResource(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 BookshelfPrivateEndpointConnectionResource GetBookshelfPrivateEndpointConnectionResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetBookshelfPrivateEndpointConnectionResource(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 BookshelfPrivateLinkResource GetBookshelfPrivateLinkResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetBookshelfPrivateLinkResource(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 ToolResource GetToolResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetToolResource(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 ProjectResource GetProjectResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetProjectResource(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 WorkspaceResource GetWorkspaceResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetWorkspaceResource(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 WorkspacePrivateEndpointConnectionResource GetWorkspacePrivateEndpointConnectionResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetWorkspacePrivateEndpointConnectionResource(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 ChatModelDeploymentResource GetChatModelDeploymentResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetChatModelDeploymentResource(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 WorkspacePrivateLinkResource GetWorkspacePrivateLinkResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetWorkspacePrivateLinkResource(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 NodePoolResource GetNodePoolResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetNodePoolResource(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 SupercomputerResource GetSupercomputerResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetSupercomputerResource(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 StorageAssetResource GetStorageAssetResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetStorageAssetResource(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 StorageContainerResource GetStorageContainerResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDiscoveryArmClient(client).GetStorageContainerResource(id); + } + + /// + /// Gets a collection of Bookshelves in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of Bookshelves and their operations over a BookshelfResource. + public static BookshelfCollection GetBookshelves(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetBookshelves(); + } + + /// + /// Get a Bookshelf + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetBookshelfAsync(this ResourceGroupResource resourceGroupResource, string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetBookshelfAsync(bookshelfName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Bookshelf + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetBookshelf(this ResourceGroupResource resourceGroupResource, string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetBookshelf(bookshelfName, cancellationToken); + } + + /// + /// Gets a collection of Tools in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of Tools and their operations over a ToolResource. + public static ToolCollection GetTools(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetTools(); + } + + /// + /// Get a Tool + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetToolAsync(this ResourceGroupResource resourceGroupResource, string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetToolAsync(toolName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Tool + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetTool(this ResourceGroupResource resourceGroupResource, string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetTool(toolName, cancellationToken); + } + + /// + /// Gets a collection of Workspaces in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of Workspaces and their operations over a WorkspaceResource. + public static WorkspaceCollection GetWorkspaces(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetWorkspaces(); + } + + /// + /// Get a Workspace + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetWorkspaceAsync(this ResourceGroupResource resourceGroupResource, string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetWorkspaceAsync(workspaceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Workspace + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetWorkspace(this ResourceGroupResource resourceGroupResource, string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetWorkspace(workspaceName, cancellationToken); + } + + /// + /// Gets a collection of Supercomputers in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of Supercomputers and their operations over a SupercomputerResource. + public static SupercomputerCollection GetSupercomputers(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetSupercomputers(); + } + + /// + /// Get a Supercomputer + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetSupercomputerAsync(this ResourceGroupResource resourceGroupResource, string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetSupercomputerAsync(supercomputerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Supercomputer + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetSupercomputer(this ResourceGroupResource resourceGroupResource, string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetSupercomputer(supercomputerName, cancellationToken); + } + + /// + /// Gets a collection of StorageContainers in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of StorageContainers and their operations over a StorageContainerResource. + public static StorageContainerCollection GetStorageContainers(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetStorageContainers(); + } + + /// + /// Get a StorageContainer + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetStorageContainerAsync(this ResourceGroupResource resourceGroupResource, string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetStorageContainerAsync(storageContainerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a StorageContainer + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetStorageContainer(this ResourceGroupResource resourceGroupResource, string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDiscoveryResourceGroupResource(resourceGroupResource).GetStorageContainer(storageContainerName, cancellationToken); + } + + /// + /// List Bookshelf 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 GetBookshelvesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetBookshelvesAsync(cancellationToken); + } + + /// + /// List Bookshelf 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 GetBookshelves(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetBookshelves(cancellationToken); + } + + /// + /// List Tool 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 GetToolsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetToolsAsync(cancellationToken); + } + + /// + /// List Tool 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 GetTools(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetTools(cancellationToken); + } + + /// + /// List Workspace 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 GetWorkspacesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetWorkspacesAsync(cancellationToken); + } + + /// + /// List Workspace 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 GetWorkspaces(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetWorkspaces(cancellationToken); + } + + /// + /// List Supercomputer 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 GetSupercomputersAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetSupercomputersAsync(cancellationToken); + } + + /// + /// List Supercomputer 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 GetSupercomputers(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetSupercomputers(cancellationToken); + } + + /// + /// List StorageContainer 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 GetStorageContainersAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetStorageContainersAsync(cancellationToken); + } + + /// + /// List StorageContainer 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 GetStorageContainers(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDiscoverySubscriptionResource(subscriptionResource).GetStorageContainers(cancellationToken); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/MockableDiscoveryArmClient.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/MockableDiscoveryArmClient.cs new file mode 100644 index 000000000000..16693405c736 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/MockableDiscoveryArmClient.cs @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Mocking +{ + /// A class to add extension methods to . + public partial class MockableDiscoveryArmClient : ArmResource + { + /// Initializes a new instance of MockableDiscoveryArmClient for mocking. + protected MockableDiscoveryArmClient() + { + } + + /// 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 MockableDiscoveryArmClient(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 BookshelfResource GetBookshelfResource(ResourceIdentifier id) + { + BookshelfResource.ValidateResourceId(id); + return new BookshelfResource(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 BookshelfPrivateEndpointConnectionResource GetBookshelfPrivateEndpointConnectionResource(ResourceIdentifier id) + { + BookshelfPrivateEndpointConnectionResource.ValidateResourceId(id); + return new BookshelfPrivateEndpointConnectionResource(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 BookshelfPrivateLinkResource GetBookshelfPrivateLinkResource(ResourceIdentifier id) + { + BookshelfPrivateLinkResource.ValidateResourceId(id); + return new BookshelfPrivateLinkResource(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 ToolResource GetToolResource(ResourceIdentifier id) + { + ToolResource.ValidateResourceId(id); + return new ToolResource(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 ProjectResource GetProjectResource(ResourceIdentifier id) + { + ProjectResource.ValidateResourceId(id); + return new ProjectResource(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 WorkspaceResource GetWorkspaceResource(ResourceIdentifier id) + { + WorkspaceResource.ValidateResourceId(id); + return new WorkspaceResource(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 WorkspacePrivateEndpointConnectionResource GetWorkspacePrivateEndpointConnectionResource(ResourceIdentifier id) + { + WorkspacePrivateEndpointConnectionResource.ValidateResourceId(id); + return new WorkspacePrivateEndpointConnectionResource(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 ChatModelDeploymentResource GetChatModelDeploymentResource(ResourceIdentifier id) + { + ChatModelDeploymentResource.ValidateResourceId(id); + return new ChatModelDeploymentResource(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 WorkspacePrivateLinkResource GetWorkspacePrivateLinkResource(ResourceIdentifier id) + { + WorkspacePrivateLinkResource.ValidateResourceId(id); + return new WorkspacePrivateLinkResource(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 NodePoolResource GetNodePoolResource(ResourceIdentifier id) + { + NodePoolResource.ValidateResourceId(id); + return new NodePoolResource(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 SupercomputerResource GetSupercomputerResource(ResourceIdentifier id) + { + SupercomputerResource.ValidateResourceId(id); + return new SupercomputerResource(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 StorageAssetResource GetStorageAssetResource(ResourceIdentifier id) + { + StorageAssetResource.ValidateResourceId(id); + return new StorageAssetResource(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 StorageContainerResource GetStorageContainerResource(ResourceIdentifier id) + { + StorageContainerResource.ValidateResourceId(id); + return new StorageContainerResource(Client, id); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/MockableDiscoveryResourceGroupResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/MockableDiscoveryResourceGroupResource.cs new file mode 100644 index 000000000000..c606900fff06 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/MockableDiscoveryResourceGroupResource.cs @@ -0,0 +1,359 @@ +// 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.Discovery; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Discovery.Mocking +{ + /// A class to add extension methods to . + public partial class MockableDiscoveryResourceGroupResource : ArmResource + { + /// Initializes a new instance of MockableDiscoveryResourceGroupResource for mocking. + protected MockableDiscoveryResourceGroupResource() + { + } + + /// 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 MockableDiscoveryResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets a collection of Bookshelves in the . + /// An object representing collection of Bookshelves and their operations over a BookshelfResource. + public virtual BookshelfCollection GetBookshelves() + { + return GetCachedClient(client => new BookshelfCollection(client, Id)); + } + + /// + /// Get a Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetBookshelfAsync(string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + + return await GetBookshelves().GetAsync(bookshelfName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Bookshelf + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/bookshelves/{bookshelfName}. + /// + /// + /// Operation Id. + /// Bookshelves_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Bookshelf. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetBookshelf(string bookshelfName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bookshelfName, nameof(bookshelfName)); + + return GetBookshelves().Get(bookshelfName, cancellationToken); + } + + /// Gets a collection of Tools in the . + /// An object representing collection of Tools and their operations over a ToolResource. + public virtual ToolCollection GetTools() + { + return GetCachedClient(client => new ToolCollection(client, Id)); + } + + /// + /// Get a Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetToolAsync(string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + + return await GetTools().GetAsync(toolName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTool(string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + + return GetTools().Get(toolName, cancellationToken); + } + + /// Gets a collection of Workspaces in the . + /// An object representing collection of Workspaces and their operations over a WorkspaceResource. + public virtual WorkspaceCollection GetWorkspaces() + { + return GetCachedClient(client => new WorkspaceCollection(client, Id)); + } + + /// + /// Get a Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetWorkspaceAsync(string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + + return await GetWorkspaces().GetAsync(workspaceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetWorkspace(string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + + return GetWorkspaces().Get(workspaceName, cancellationToken); + } + + /// Gets a collection of Supercomputers in the . + /// An object representing collection of Supercomputers and their operations over a SupercomputerResource. + public virtual SupercomputerCollection GetSupercomputers() + { + return GetCachedClient(client => new SupercomputerCollection(client, Id)); + } + + /// + /// Get a Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSupercomputerAsync(string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + + return await GetSupercomputers().GetAsync(supercomputerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSupercomputer(string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + + return GetSupercomputers().Get(supercomputerName, cancellationToken); + } + + /// Gets a collection of StorageContainers in the . + /// An object representing collection of StorageContainers and their operations over a StorageContainerResource. + public virtual StorageContainerCollection GetStorageContainers() + { + return GetCachedClient(client => new StorageContainerCollection(client, Id)); + } + + /// + /// Get a StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetStorageContainerAsync(string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + + return await GetStorageContainers().GetAsync(storageContainerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetStorageContainer(string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + + return GetStorageContainers().Get(storageContainerName, cancellationToken); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/MockableDiscoverySubscriptionResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/MockableDiscoverySubscriptionResource.cs new file mode 100644 index 000000000000..c70df21ef553 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Extensions/MockableDiscoverySubscriptionResource.cs @@ -0,0 +1,345 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Discovery; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Discovery.Mocking +{ + /// A class to add extension methods to . + public partial class MockableDiscoverySubscriptionResource : ArmResource + { + private ClientDiagnostics _bookshelvesClientDiagnostics; + private Bookshelves _bookshelvesRestClient; + private ClientDiagnostics _toolsClientDiagnostics; + private Tools _toolsRestClient; + private ClientDiagnostics _workspacesClientDiagnostics; + private Workspaces _workspacesRestClient; + private ClientDiagnostics _supercomputersClientDiagnostics; + private Supercomputers _supercomputersRestClient; + private ClientDiagnostics _storageContainersClientDiagnostics; + private StorageContainers _storageContainersRestClient; + + /// Initializes a new instance of MockableDiscoverySubscriptionResource for mocking. + protected MockableDiscoverySubscriptionResource() + { + } + + /// 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 MockableDiscoverySubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics BookshelvesClientDiagnostics => _bookshelvesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Discovery.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private Bookshelves BookshelvesRestClient => _bookshelvesRestClient ??= new Bookshelves(BookshelvesClientDiagnostics, Pipeline, Endpoint, "2026-02-01-preview"); + + private ClientDiagnostics ToolsClientDiagnostics => _toolsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Discovery.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private Tools ToolsRestClient => _toolsRestClient ??= new Tools(ToolsClientDiagnostics, Pipeline, Endpoint, "2026-02-01-preview"); + + private ClientDiagnostics WorkspacesClientDiagnostics => _workspacesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Discovery.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private Workspaces WorkspacesRestClient => _workspacesRestClient ??= new Workspaces(WorkspacesClientDiagnostics, Pipeline, Endpoint, "2026-02-01-preview"); + + private ClientDiagnostics SupercomputersClientDiagnostics => _supercomputersClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Discovery.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private Supercomputers SupercomputersRestClient => _supercomputersRestClient ??= new Supercomputers(SupercomputersClientDiagnostics, Pipeline, Endpoint, "2026-02-01-preview"); + + private ClientDiagnostics StorageContainersClientDiagnostics => _storageContainersClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Discovery.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private StorageContainers StorageContainersRestClient => _storageContainersRestClient ??= new StorageContainers(StorageContainersClientDiagnostics, Pipeline, Endpoint, "2026-02-01-preview"); + + /// + /// List Bookshelf resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/bookshelves. + /// + /// + /// Operation Id. + /// Bookshelves_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetBookshelvesAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new BookshelvesGetBySubscriptionAsyncCollectionResultOfT(BookshelvesRestClient, Guid.Parse(Id.SubscriptionId), context), data => new BookshelfResource(Client, data)); + } + + /// + /// List Bookshelf resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/bookshelves. + /// + /// + /// Operation Id. + /// Bookshelves_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetBookshelves(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new BookshelvesGetBySubscriptionCollectionResultOfT(BookshelvesRestClient, Guid.Parse(Id.SubscriptionId), context), data => new BookshelfResource(Client, data)); + } + + /// + /// List Tool resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/tools. + /// + /// + /// Operation Id. + /// Tools_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetToolsAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ToolsGetBySubscriptionAsyncCollectionResultOfT(ToolsRestClient, Guid.Parse(Id.SubscriptionId), context), data => new ToolResource(Client, data)); + } + + /// + /// List Tool resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/tools. + /// + /// + /// Operation Id. + /// Tools_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetTools(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ToolsGetBySubscriptionCollectionResultOfT(ToolsRestClient, Guid.Parse(Id.SubscriptionId), context), data => new ToolResource(Client, data)); + } + + /// + /// List Workspace resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/workspaces. + /// + /// + /// Operation Id. + /// Workspaces_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetWorkspacesAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new WorkspacesGetBySubscriptionAsyncCollectionResultOfT(WorkspacesRestClient, Guid.Parse(Id.SubscriptionId), context), data => new WorkspaceResource(Client, data)); + } + + /// + /// List Workspace resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/workspaces. + /// + /// + /// Operation Id. + /// Workspaces_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetWorkspaces(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new WorkspacesGetBySubscriptionCollectionResultOfT(WorkspacesRestClient, Guid.Parse(Id.SubscriptionId), context), data => new WorkspaceResource(Client, data)); + } + + /// + /// List Supercomputer resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/supercomputers. + /// + /// + /// Operation Id. + /// Supercomputers_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetSupercomputersAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new SupercomputersGetBySubscriptionAsyncCollectionResultOfT(SupercomputersRestClient, Guid.Parse(Id.SubscriptionId), context), data => new SupercomputerResource(Client, data)); + } + + /// + /// List Supercomputer resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/supercomputers. + /// + /// + /// Operation Id. + /// Supercomputers_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetSupercomputers(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new SupercomputersGetBySubscriptionCollectionResultOfT(SupercomputersRestClient, Guid.Parse(Id.SubscriptionId), context), data => new SupercomputerResource(Client, data)); + } + + /// + /// List StorageContainer resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/storageContainers. + /// + /// + /// Operation Id. + /// StorageContainers_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetStorageContainersAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new StorageContainersGetBySubscriptionAsyncCollectionResultOfT(StorageContainersRestClient, Guid.Parse(Id.SubscriptionId), context), data => new StorageContainerResource(Client, data)); + } + + /// + /// List StorageContainer resources by subscription ID + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Discovery/storageContainers. + /// + /// + /// Operation Id. + /// StorageContainers_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetStorageContainers(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new StorageContainersGetBySubscriptionCollectionResultOfT(StorageContainersRestClient, Guid.Parse(Id.SubscriptionId), context), data => new StorageContainerResource(Client, data)); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/Argument.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..578fa48bd3c5 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/Argument.cs @@ -0,0 +1,113 @@ +// 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.Discovery +{ + 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); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + /// The value. + /// The minimum value. + /// The maximum value. + /// The name. + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + /// The value. + /// The name. + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..d9ca4f4287df --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..6438c72915f6 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ChangeTrackingList.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..331b617be402 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..1fb3682efa42 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions errorOptions) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (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 errorOptions) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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 Microsoft.TypeSpec.Generator.Customizations +{ + [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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ErrorResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..904ba47d7fb0 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..9821e5d4e367 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,268 @@ +// 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.Runtime.InteropServices; +using System.Text.Json; + +namespace Azure.ResourceManager.Discovery +{ + 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); + } + + public static BinaryData GetUtf8Bytes(this JsonElement element) + { +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/Optional.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..50341426a04e --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/PageableWrapper.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..d1745ccd5a4c --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..9f3b49c89d51 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,60 @@ +// 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.Discovery +{ + 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); + } + + public static void UpdateQuery(this RawRequestUriBuilder builder, string name, string value) + { + string currentQuery = builder.Query; + string searchPattern = string.Concat(name, "="); + int paramStartIndex = -1; + if (currentQuery.StartsWith(string.Concat("?", searchPattern))) + { + paramStartIndex = 1; + } + if (paramStartIndex == -1) + { + string prefixedPattern = string.Concat("&", searchPattern); + int prefixedIndex = currentQuery.IndexOf(prefixedPattern); + if (prefixedIndex >= 0) + { + paramStartIndex = prefixedIndex + 1; + } + } + if (paramStartIndex >= 0) + { + int valueStartIndex = paramStartIndex + searchPattern.Length; + int valueEndIndex = currentQuery.IndexOf('&', valueStartIndex); + if (valueEndIndex == -1) + { + valueEndIndex = currentQuery.Length; + } + string beforeParam = currentQuery.Substring(0, valueStartIndex); + string afterParam = currentQuery.Substring(valueEndIndex); + string newQuery = string.Concat(beforeParam, value, afterParam); + builder.Query = newQuery; + } + else + { + builder.AppendQuery(name, value, true); + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/RequestContextExtensions.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..869afd1ee092 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/SerializationFormat.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..fc41984f2cb6 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/TypeFormatters.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..55d9b2918f08 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/BookshelfOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/BookshelfOperationSource.cs new file mode 100644 index 000000000000..91d8e0da65c5 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/BookshelfOperationSource.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.Discovery +{ + /// + internal partial class BookshelfOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal BookshelfOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + BookshelfResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + BookshelfData data = BookshelfData.DeserializeBookshelfData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new BookshelfResource(_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); + BookshelfData data = BookshelfData.DeserializeBookshelfData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new BookshelfResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/BookshelfPrivateEndpointConnectionOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/BookshelfPrivateEndpointConnectionOperationSource.cs new file mode 100644 index 000000000000..510427751055 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/BookshelfPrivateEndpointConnectionOperationSource.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.Discovery +{ + /// + internal partial class BookshelfPrivateEndpointConnectionOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal BookshelfPrivateEndpointConnectionOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + BookshelfPrivateEndpointConnectionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + BookshelfPrivateEndpointConnectionData data = BookshelfPrivateEndpointConnectionData.DeserializeBookshelfPrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new BookshelfPrivateEndpointConnectionResource(_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); + BookshelfPrivateEndpointConnectionData data = BookshelfPrivateEndpointConnectionData.DeserializeBookshelfPrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new BookshelfPrivateEndpointConnectionResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/ChatModelDeploymentOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/ChatModelDeploymentOperationSource.cs new file mode 100644 index 000000000000..52ed8741b256 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/ChatModelDeploymentOperationSource.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.Discovery +{ + /// + internal partial class ChatModelDeploymentOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal ChatModelDeploymentOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + ChatModelDeploymentResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + ChatModelDeploymentData data = ChatModelDeploymentData.DeserializeChatModelDeploymentData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ChatModelDeploymentResource(_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); + ChatModelDeploymentData data = ChatModelDeploymentData.DeserializeChatModelDeploymentData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ChatModelDeploymentResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/DiscoveryArmOperation.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/DiscoveryArmOperation.cs new file mode 100644 index 000000000000..96450bca372b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/DiscoveryArmOperation.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.Discovery +{ + internal partial class DiscoveryArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of DiscoveryArmOperation for mocking. + protected DiscoveryArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal DiscoveryArmOperation(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 DiscoveryArmOperation(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, + "DiscoveryArmOperation", + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/DiscoveryArmOperationOfT.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/DiscoveryArmOperationOfT.cs new file mode 100644 index 000000000000..f359563e7681 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/DiscoveryArmOperationOfT.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.Discovery +{ + internal partial class DiscoveryArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of DiscoveryArmOperation for mocking. + protected DiscoveryArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal DiscoveryArmOperation(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 DiscoveryArmOperation(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, + "DiscoveryArmOperation", + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/NodePoolOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/NodePoolOperationSource.cs new file mode 100644 index 000000000000..60c6a87230f7 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/NodePoolOperationSource.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.Discovery +{ + /// + internal partial class NodePoolOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal NodePoolOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + NodePoolResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + NodePoolData data = NodePoolData.DeserializeNodePoolData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new NodePoolResource(_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); + NodePoolData data = NodePoolData.DeserializeNodePoolData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new NodePoolResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/ProjectOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/ProjectOperationSource.cs new file mode 100644 index 000000000000..45bf7efb5e1b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/ProjectOperationSource.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.Discovery +{ + /// + internal partial class ProjectOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal ProjectOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + ProjectResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + ProjectData data = ProjectData.DeserializeProjectData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ProjectResource(_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); + ProjectData data = ProjectData.DeserializeProjectData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ProjectResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/StorageAssetOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/StorageAssetOperationSource.cs new file mode 100644 index 000000000000..8b9e1208e260 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/StorageAssetOperationSource.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.Discovery +{ + /// + internal partial class StorageAssetOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal StorageAssetOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + StorageAssetResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + StorageAssetData data = StorageAssetData.DeserializeStorageAssetData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new StorageAssetResource(_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); + StorageAssetData data = StorageAssetData.DeserializeStorageAssetData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new StorageAssetResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/StorageContainerOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/StorageContainerOperationSource.cs new file mode 100644 index 000000000000..9e88eaadc5a7 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/StorageContainerOperationSource.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.Discovery +{ + /// + internal partial class StorageContainerOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal StorageContainerOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + StorageContainerResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + StorageContainerData data = StorageContainerData.DeserializeStorageContainerData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new StorageContainerResource(_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); + StorageContainerData data = StorageContainerData.DeserializeStorageContainerData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new StorageContainerResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/SupercomputerOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/SupercomputerOperationSource.cs new file mode 100644 index 000000000000..2efe67c70545 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/SupercomputerOperationSource.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.Discovery +{ + /// + internal partial class SupercomputerOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal SupercomputerOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + SupercomputerResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + SupercomputerData data = SupercomputerData.DeserializeSupercomputerData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new SupercomputerResource(_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); + SupercomputerData data = SupercomputerData.DeserializeSupercomputerData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new SupercomputerResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/ToolOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/ToolOperationSource.cs new file mode 100644 index 000000000000..2ed43b10bed2 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/ToolOperationSource.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.Discovery +{ + /// + internal partial class ToolOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal ToolOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + ToolResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + ToolData data = ToolData.DeserializeToolData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ToolResource(_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); + ToolData data = ToolData.DeserializeToolData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ToolResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/WorkspaceOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/WorkspaceOperationSource.cs new file mode 100644 index 000000000000..7e289368579c --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/WorkspaceOperationSource.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.Discovery +{ + /// + internal partial class WorkspaceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal WorkspaceOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + WorkspaceResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + WorkspaceData data = WorkspaceData.DeserializeWorkspaceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new WorkspaceResource(_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); + WorkspaceData data = WorkspaceData.DeserializeWorkspaceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new WorkspaceResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/WorkspacePrivateEndpointConnectionOperationSource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/WorkspacePrivateEndpointConnectionOperationSource.cs new file mode 100644 index 000000000000..cfd2d6e9d601 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/LongRunningOperation/WorkspacePrivateEndpointConnectionOperationSource.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.Discovery +{ + /// + internal partial class WorkspacePrivateEndpointConnectionOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal WorkspacePrivateEndpointConnectionOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + WorkspacePrivateEndpointConnectionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + WorkspacePrivateEndpointConnectionData data = WorkspacePrivateEndpointConnectionData.DeserializeWorkspacePrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new WorkspacePrivateEndpointConnectionResource(_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); + WorkspacePrivateEndpointConnectionData data = WorkspacePrivateEndpointConnectionData.DeserializeWorkspacePrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new WorkspacePrivateEndpointConnectionResource(_client, data); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureNetAppFilesStore.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureNetAppFilesStore.Serialization.cs new file mode 100644 index 000000000000..8fb6d4536189 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureNetAppFilesStore.Serialization.cs @@ -0,0 +1,136 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The Azure NetApp Files properties. + public partial class AzureNetAppFilesStore : StorageStore, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureNetAppFilesStore() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override StorageStore 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 DeserializeAzureNetAppFilesStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureNetAppFilesStore)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(AzureNetAppFilesStore)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AzureNetAppFilesStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureNetAppFilesStore)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(AzureNetAppFilesStore)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("netAppVolumeId"u8); + writer.WriteStringValue(NetAppVolumeId); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureNetAppFilesStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureNetAppFilesStore)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override StorageStore 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(AzureNetAppFilesStore)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureNetAppFilesStore(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureNetAppFilesStore DeserializeAzureNetAppFilesStore(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageStoreType kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResourceIdentifier netAppVolumeId = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new StorageStoreType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("netAppVolumeId"u8)) + { + netAppVolumeId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureNetAppFilesStore(kind, additionalBinaryDataProperties, netAppVolumeId); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureNetAppFilesStore.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureNetAppFilesStore.cs new file mode 100644 index 000000000000..3c1ecd314575 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureNetAppFilesStore.cs @@ -0,0 +1,40 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The Azure NetApp Files properties. + public partial class AzureNetAppFilesStore : StorageStore + { + /// Initializes a new instance of . + /// The associated Azure NetApp Files volume ID. + /// is null. + public AzureNetAppFilesStore(ResourceIdentifier netAppVolumeId) : base(StorageStoreType.AzureNetAppFiles) + { + Argument.AssertNotNull(netAppVolumeId, nameof(netAppVolumeId)); + + NetAppVolumeId = netAppVolumeId; + } + + /// Initializes a new instance of . + /// The storage store kind. + /// Keeps track of any properties unknown to the library. + /// The associated Azure NetApp Files volume ID. + internal AzureNetAppFilesStore(StorageStoreType kind, IDictionary additionalBinaryDataProperties, ResourceIdentifier netAppVolumeId) : base(kind, additionalBinaryDataProperties) + { + NetAppVolumeId = netAppVolumeId; + } + + /// The associated Azure NetApp Files volume ID. + public ResourceIdentifier NetAppVolumeId { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureResourceManagerDiscoveryContext.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureResourceManagerDiscoveryContext.cs new file mode 100644 index 000000000000..d13d847137a8 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureResourceManagerDiscoveryContext.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(AzureNetAppFilesStore))] + [ModelReaderWriterBuildable(typeof(AzureStorageBlobStore))] + [ModelReaderWriterBuildable(typeof(BookshelfData))] + [ModelReaderWriterBuildable(typeof(BookshelfKeyVaultProperties))] + [ModelReaderWriterBuildable(typeof(BookshelfListResult))] + [ModelReaderWriterBuildable(typeof(BookshelfPrivateEndpointConnectionData))] + [ModelReaderWriterBuildable(typeof(BookshelfPrivateEndpointConnectionListResult))] + [ModelReaderWriterBuildable(typeof(BookshelfPrivateEndpointConnectionResource))] + [ModelReaderWriterBuildable(typeof(BookshelfPrivateLinkResource))] + [ModelReaderWriterBuildable(typeof(BookshelfPrivateLinkResourceData))] + [ModelReaderWriterBuildable(typeof(BookshelfPrivateLinkResourceListResult))] + [ModelReaderWriterBuildable(typeof(BookshelfProperties))] + [ModelReaderWriterBuildable(typeof(BookshelfResource))] + [ModelReaderWriterBuildable(typeof(ChatModelDeploymentData))] + [ModelReaderWriterBuildable(typeof(ChatModelDeploymentListResult))] + [ModelReaderWriterBuildable(typeof(ChatModelDeploymentProperties))] + [ModelReaderWriterBuildable(typeof(ChatModelDeploymentResource))] + [ModelReaderWriterBuildable(typeof(DiscoveryPrivateEndpointConnection))] + [ModelReaderWriterBuildable(typeof(DiscoveryPrivateLinkResourceProperties))] + [ModelReaderWriterBuildable(typeof(DiscoveryPrivateLinkServiceConnectionState))] + [ModelReaderWriterBuildable(typeof(Identity))] + [ModelReaderWriterBuildable(typeof(Models.KeyVaultProperties))] + [ModelReaderWriterBuildable(typeof(MoboBrokerResource))] + [ModelReaderWriterBuildable(typeof(NodePoolData))] + [ModelReaderWriterBuildable(typeof(NodePoolListResult))] + [ModelReaderWriterBuildable(typeof(NodePoolProperties))] + [ModelReaderWriterBuildable(typeof(NodePoolResource))] + [ModelReaderWriterBuildable(typeof(PrivateEndpoint))] + [ModelReaderWriterBuildable(typeof(PrivateEndpointConnectionProperties))] + [ModelReaderWriterBuildable(typeof(ProjectData))] + [ModelReaderWriterBuildable(typeof(ProjectListResult))] + [ModelReaderWriterBuildable(typeof(ProjectProperties))] + [ModelReaderWriterBuildable(typeof(ProjectResource))] + [ModelReaderWriterBuildable(typeof(ProjectSettings))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(StorageAssetData))] + [ModelReaderWriterBuildable(typeof(StorageAssetListResult))] + [ModelReaderWriterBuildable(typeof(StorageAssetProperties))] + [ModelReaderWriterBuildable(typeof(StorageAssetResource))] + [ModelReaderWriterBuildable(typeof(StorageContainerData))] + [ModelReaderWriterBuildable(typeof(StorageContainerListResult))] + [ModelReaderWriterBuildable(typeof(StorageContainerProperties))] + [ModelReaderWriterBuildable(typeof(StorageContainerResource))] + [ModelReaderWriterBuildable(typeof(StorageStore))] + [ModelReaderWriterBuildable(typeof(SupercomputerData))] + [ModelReaderWriterBuildable(typeof(SupercomputerIdentities))] + [ModelReaderWriterBuildable(typeof(SupercomputerListResult))] + [ModelReaderWriterBuildable(typeof(SupercomputerProperties))] + [ModelReaderWriterBuildable(typeof(SupercomputerResource))] + [ModelReaderWriterBuildable(typeof(SystemData))] + [ModelReaderWriterBuildable(typeof(ToolData))] + [ModelReaderWriterBuildable(typeof(ToolListResult))] + [ModelReaderWriterBuildable(typeof(ToolProperties))] + [ModelReaderWriterBuildable(typeof(ToolResource))] + [ModelReaderWriterBuildable(typeof(UnknownStorageStore))] + [ModelReaderWriterBuildable(typeof(UserAssignedIdentity))] + [ModelReaderWriterBuildable(typeof(WithMoboBrokerResources))] + [ModelReaderWriterBuildable(typeof(WorkspaceData))] + [ModelReaderWriterBuildable(typeof(WorkspaceListResult))] + [ModelReaderWriterBuildable(typeof(WorkspacePrivateEndpointConnectionData))] + [ModelReaderWriterBuildable(typeof(WorkspacePrivateEndpointConnectionListResult))] + [ModelReaderWriterBuildable(typeof(WorkspacePrivateEndpointConnectionResource))] + [ModelReaderWriterBuildable(typeof(WorkspacePrivateLinkResource))] + [ModelReaderWriterBuildable(typeof(WorkspacePrivateLinkResourceData))] + [ModelReaderWriterBuildable(typeof(WorkspacePrivateLinkResourceListResult))] + [ModelReaderWriterBuildable(typeof(WorkspaceProperties))] + [ModelReaderWriterBuildable(typeof(WorkspaceResource))] + public partial class AzureResourceManagerDiscoveryContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureStorageBlobStore.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureStorageBlobStore.Serialization.cs new file mode 100644 index 000000000000..a8e6a45e4132 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureStorageBlobStore.Serialization.cs @@ -0,0 +1,136 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The Azure storage blob properties. + public partial class AzureStorageBlobStore : StorageStore, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureStorageBlobStore() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override StorageStore 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 DeserializeAzureStorageBlobStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureStorageBlobStore)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(AzureStorageBlobStore)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + AzureStorageBlobStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureStorageBlobStore)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(AzureStorageBlobStore)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("storageAccountId"u8); + writer.WriteStringValue(StorageAccountId); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureStorageBlobStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureStorageBlobStore)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override StorageStore 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(AzureStorageBlobStore)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureStorageBlobStore(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureStorageBlobStore DeserializeAzureStorageBlobStore(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageStoreType kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResourceIdentifier storageAccountId = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new StorageStoreType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("storageAccountId"u8)) + { + storageAccountId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureStorageBlobStore(kind, additionalBinaryDataProperties, storageAccountId); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureStorageBlobStore.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureStorageBlobStore.cs new file mode 100644 index 000000000000..157c9a32e755 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/AzureStorageBlobStore.cs @@ -0,0 +1,40 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The Azure storage blob properties. + public partial class AzureStorageBlobStore : StorageStore + { + /// Initializes a new instance of . + /// The associated Azure Storage Account ID. + /// is null. + public AzureStorageBlobStore(ResourceIdentifier storageAccountId) : base(StorageStoreType.AzureStorageBlob) + { + Argument.AssertNotNull(storageAccountId, nameof(storageAccountId)); + + StorageAccountId = storageAccountId; + } + + /// Initializes a new instance of . + /// The storage store kind. + /// Keeps track of any properties unknown to the library. + /// The associated Azure Storage Account ID. + internal AzureStorageBlobStore(StorageStoreType kind, IDictionary additionalBinaryDataProperties, ResourceIdentifier storageAccountId) : base(kind, additionalBinaryDataProperties) + { + StorageAccountId = storageAccountId; + } + + /// The associated Azure Storage Account ID. + public ResourceIdentifier StorageAccountId { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfKeyVaultProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfKeyVaultProperties.Serialization.cs new file mode 100644 index 000000000000..79269a9a9d45 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfKeyVaultProperties.Serialization.cs @@ -0,0 +1,170 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Key Vault Properties with clientId selection. + public partial class BookshelfKeyVaultProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BookshelfKeyVaultProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BookshelfKeyVaultProperties 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 DeserializeBookshelfKeyVaultProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BookshelfKeyVaultProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(BookshelfKeyVaultProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BookshelfKeyVaultProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(BookshelfKeyVaultProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("keyVaultUri"u8); + writer.WriteStringValue(KeyVaultUri.AbsoluteUri); + writer.WritePropertyName("keyName"u8); + writer.WriteStringValue(KeyName); + if (Optional.IsDefined(KeyVersion)) + { + writer.WritePropertyName("keyVersion"u8); + writer.WriteStringValue(KeyVersion); + } + writer.WritePropertyName("identityClientId"u8); + writer.WriteStringValue(IdentityClientId); + 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. + BookshelfKeyVaultProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BookshelfKeyVaultProperties 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(BookshelfKeyVaultProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBookshelfKeyVaultProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BookshelfKeyVaultProperties DeserializeBookshelfKeyVaultProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri keyVaultUri = default; + string keyName = default; + string keyVersion = default; + string identityClientId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("keyVaultUri"u8)) + { + keyVaultUri = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (prop.NameEquals("keyName"u8)) + { + keyName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("keyVersion"u8)) + { + keyVersion = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("identityClientId"u8)) + { + identityClientId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BookshelfKeyVaultProperties(keyVaultUri, keyName, keyVersion, identityClientId, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfKeyVaultProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfKeyVaultProperties.cs new file mode 100644 index 000000000000..66d5ff673afb --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfKeyVaultProperties.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Key Vault Properties with clientId selection. + public partial class BookshelfKeyVaultProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Key Vault URI. + /// The Key Name in Key Vault. + /// The client ID of the identity to use for accessing the Key Vault. Must be a workload identity assigned to the Bookshelf resource. + /// , or is null. + public BookshelfKeyVaultProperties(Uri keyVaultUri, string keyName, string identityClientId) + { + Argument.AssertNotNull(keyVaultUri, nameof(keyVaultUri)); + Argument.AssertNotNull(keyName, nameof(keyName)); + Argument.AssertNotNull(identityClientId, nameof(identityClientId)); + + KeyVaultUri = keyVaultUri; + KeyName = keyName; + IdentityClientId = identityClientId; + } + + /// Initializes a new instance of . + /// The Key Vault URI. + /// The Key Name in Key Vault. + /// The Key Version in Key Vault. + /// The client ID of the identity to use for accessing the Key Vault. Must be a workload identity assigned to the Bookshelf resource. + /// Keeps track of any properties unknown to the library. + internal BookshelfKeyVaultProperties(Uri keyVaultUri, string keyName, string keyVersion, string identityClientId, IDictionary additionalBinaryDataProperties) + { + KeyVaultUri = keyVaultUri; + KeyName = keyName; + KeyVersion = keyVersion; + IdentityClientId = identityClientId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Key Vault URI. + public Uri KeyVaultUri { get; set; } + + /// The Key Name in Key Vault. + public string KeyName { get; set; } + + /// The Key Version in Key Vault. + public string KeyVersion { get; set; } + + /// The client ID of the identity to use for accessing the Key Vault. Must be a workload identity assigned to the Bookshelf resource. + public string IdentityClientId { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfListResult.Serialization.cs new file mode 100644 index 000000000000..77a0a90f789c --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Bookshelf list operation. + internal partial class BookshelfListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BookshelfListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BookshelfListResult 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 DeserializeBookshelfListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BookshelfListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(BookshelfListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BookshelfListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static BookshelfListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBookshelfListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(BookshelfListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (BookshelfData 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. + BookshelfListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BookshelfListResult 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(BookshelfListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBookshelfListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BookshelfListResult DeserializeBookshelfListResult(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(BookshelfData.DeserializeBookshelfData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BookshelfListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfListResult.cs new file mode 100644 index 000000000000..4bdeed1901ed --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Bookshelf list operation. + internal partial class BookshelfListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Bookshelf items on this page. + internal BookshelfListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Bookshelf items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal BookshelfListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Bookshelf items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateEndpointConnectionListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateEndpointConnectionListResult.Serialization.cs new file mode 100644 index 000000000000..adcc20b722ba --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateEndpointConnectionListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a BookshelfPrivateEndpointConnection list operation. + internal partial class BookshelfPrivateEndpointConnectionListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BookshelfPrivateEndpointConnectionListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BookshelfPrivateEndpointConnectionListResult 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 DeserializeBookshelfPrivateEndpointConnectionListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BookshelfPrivateEndpointConnectionListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(BookshelfPrivateEndpointConnectionListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BookshelfPrivateEndpointConnectionListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static BookshelfPrivateEndpointConnectionListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBookshelfPrivateEndpointConnectionListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(BookshelfPrivateEndpointConnectionListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (BookshelfPrivateEndpointConnectionData 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. + BookshelfPrivateEndpointConnectionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BookshelfPrivateEndpointConnectionListResult 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(BookshelfPrivateEndpointConnectionListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBookshelfPrivateEndpointConnectionListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BookshelfPrivateEndpointConnectionListResult DeserializeBookshelfPrivateEndpointConnectionListResult(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(BookshelfPrivateEndpointConnectionData.DeserializeBookshelfPrivateEndpointConnectionData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BookshelfPrivateEndpointConnectionListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateEndpointConnectionListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateEndpointConnectionListResult.cs new file mode 100644 index 000000000000..3da4eb68f13b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateEndpointConnectionListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a BookshelfPrivateEndpointConnection list operation. + internal partial class BookshelfPrivateEndpointConnectionListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The BookshelfPrivateEndpointConnection items on this page. + internal BookshelfPrivateEndpointConnectionListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The BookshelfPrivateEndpointConnection items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal BookshelfPrivateEndpointConnectionListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The BookshelfPrivateEndpointConnection items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateLinkResourceListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateLinkResourceListResult.Serialization.cs new file mode 100644 index 000000000000..a4706a6e8f22 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateLinkResourceListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a BookshelfPrivateLinkResource list operation. + internal partial class BookshelfPrivateLinkResourceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BookshelfPrivateLinkResourceListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BookshelfPrivateLinkResourceListResult 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 DeserializeBookshelfPrivateLinkResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BookshelfPrivateLinkResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(BookshelfPrivateLinkResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BookshelfPrivateLinkResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static BookshelfPrivateLinkResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBookshelfPrivateLinkResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(BookshelfPrivateLinkResourceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (BookshelfPrivateLinkResourceData 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. + BookshelfPrivateLinkResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BookshelfPrivateLinkResourceListResult 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(BookshelfPrivateLinkResourceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBookshelfPrivateLinkResourceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BookshelfPrivateLinkResourceListResult DeserializeBookshelfPrivateLinkResourceListResult(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(BookshelfPrivateLinkResourceData.DeserializeBookshelfPrivateLinkResourceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BookshelfPrivateLinkResourceListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateLinkResourceListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateLinkResourceListResult.cs new file mode 100644 index 000000000000..e6c248860244 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfPrivateLinkResourceListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a BookshelfPrivateLinkResource list operation. + internal partial class BookshelfPrivateLinkResourceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The BookshelfPrivateLinkResource items on this page. + internal BookshelfPrivateLinkResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The BookshelfPrivateLinkResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal BookshelfPrivateLinkResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The BookshelfPrivateLinkResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfProperties.Serialization.cs new file mode 100644 index 000000000000..b91102626a38 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfProperties.Serialization.cs @@ -0,0 +1,355 @@ +// 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.Core; +using Azure.ResourceManager.Discovery; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Bookshelf properties. + public partial class BookshelfProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BookshelfProperties 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 DeserializeBookshelfProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BookshelfProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(BookshelfProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + BookshelfProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(BookshelfProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsCollectionDefined(WorkloadIdentities)) + { + writer.WritePropertyName("workloadIdentities"u8); + writer.WriteStartObject(); + foreach (var item in WorkloadIdentities) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + ((IJsonModel)item.Value).Write(writer, options); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(CustomerManagedKeys)) + { + writer.WritePropertyName("customerManagedKeys"u8); + writer.WriteStringValue(CustomerManagedKeys.Value.ToString()); + } + if (Optional.IsDefined(KeyVaultProperties)) + { + writer.WritePropertyName("keyVaultProperties"u8); + writer.WriteObjectValue(KeyVaultProperties, options); + } + if (Optional.IsDefined(LogAnalyticsClusterId)) + { + writer.WritePropertyName("logAnalyticsClusterId"u8); + writer.WriteStringValue(LogAnalyticsClusterId); + } + if (options.Format != "W" && Optional.IsCollectionDefined(PrivateEndpointConnections)) + { + writer.WritePropertyName("privateEndpointConnections"u8); + writer.WriteStartArray(); + foreach (DiscoveryPrivateEndpointConnection item in PrivateEndpointConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PublicNetworkAccess)) + { + writer.WritePropertyName("publicNetworkAccess"u8); + writer.WriteStringValue(PublicNetworkAccess.Value.ToString()); + } + if (Optional.IsDefined(PrivateEndpointSubnetId)) + { + writer.WritePropertyName("privateEndpointSubnetId"u8); + writer.WriteStringValue(PrivateEndpointSubnetId); + } + if (Optional.IsDefined(SearchSubnetId)) + { + writer.WritePropertyName("searchSubnetId"u8); + writer.WriteStringValue(SearchSubnetId); + } + if (options.Format != "W" && Optional.IsDefined(ManagedResourceGroup)) + { + writer.WritePropertyName("managedResourceGroup"u8); + writer.WriteStringValue(ManagedResourceGroup); + } + if (options.Format != "W" && Optional.IsDefined(ManagedOnBehalfOfConfiguration)) + { + writer.WritePropertyName("managedOnBehalfOfConfiguration"u8); + writer.WriteObjectValue(ManagedOnBehalfOfConfiguration, options); + } + if (options.Format != "W" && Optional.IsDefined(BookshelfUri)) + { + writer.WritePropertyName("bookshelfUri"u8); + writer.WriteStringValue(BookshelfUri.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. + BookshelfProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BookshelfProperties 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(BookshelfProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBookshelfProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BookshelfProperties DeserializeBookshelfProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + IDictionary workloadIdentities = default; + CustomerManagedKeys? customerManagedKeys = default; + BookshelfKeyVaultProperties keyVaultProperties = default; + ResourceIdentifier logAnalyticsClusterId = default; + IReadOnlyList privateEndpointConnections = default; + PublicNetworkAccess? publicNetworkAccess = default; + ResourceIdentifier privateEndpointSubnetId = default; + ResourceIdentifier searchSubnetId = default; + string managedResourceGroup = default; + WithMoboBrokerResources managedOnBehalfOfConfiguration = default; + Uri bookshelfUri = 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("workloadIdentities"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, ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDiscoveryContext.Default)); + } + } + workloadIdentities = dictionary; + continue; + } + if (prop.NameEquals("customerManagedKeys"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + customerManagedKeys = new CustomerManagedKeys(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("keyVaultProperties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keyVaultProperties = BookshelfKeyVaultProperties.DeserializeBookshelfKeyVaultProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("logAnalyticsClusterId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logAnalyticsClusterId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("privateEndpointConnections"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DiscoveryPrivateEndpointConnection.DeserializeDiscoveryPrivateEndpointConnection(item, options)); + } + privateEndpointConnections = array; + continue; + } + if (prop.NameEquals("publicNetworkAccess"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicNetworkAccess = new PublicNetworkAccess(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("privateEndpointSubnetId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateEndpointSubnetId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("searchSubnetId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + searchSubnetId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("managedResourceGroup"u8)) + { + managedResourceGroup = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("managedOnBehalfOfConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managedOnBehalfOfConfiguration = WithMoboBrokerResources.DeserializeWithMoboBrokerResources(prop.Value, options); + continue; + } + if (prop.NameEquals("bookshelfUri"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + bookshelfUri = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BookshelfProperties( + provisioningState, + workloadIdentities ?? new ChangeTrackingDictionary(), + customerManagedKeys, + keyVaultProperties, + logAnalyticsClusterId, + privateEndpointConnections ?? new ChangeTrackingList(), + publicNetworkAccess, + privateEndpointSubnetId, + searchSubnetId, + managedResourceGroup, + managedOnBehalfOfConfiguration, + bookshelfUri, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfProperties.cs new file mode 100644 index 000000000000..477a94da8557 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/BookshelfProperties.cs @@ -0,0 +1,105 @@ +// 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.Discovery; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Bookshelf properties. + public partial class BookshelfProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public BookshelfProperties() + { + WorkloadIdentities = new ChangeTrackingDictionary(); + PrivateEndpointConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// User assigned identity IDs to be used by knowledgebase workloads. The key value must be the resource ID of the identity resource. + /// Whether or not to use a customer managed key when encrypting data at rest. + /// The key to use for encrypting data at rest when customer managed keys are enabled. Required if Customer Managed Keys is enabled. + /// The Log Analytics Cluster to use for debug logs. This is required when Customer Managed Keys are enabled. + /// List of private endpoint connections. + /// Whether or not public network access is allowed for this resource. For security reasons, it is recommended to disable it whenever possible. + /// Private Endpoint Subnet ID for private endpoint connections. + /// Search Subnet ID for search resources. + /// The resource group for resources managed on behalf of customer. + /// Managed-On-Behalf-Of configuration properties. This configuration exists for the resources where a resource provider manages those resources on behalf of the resource owner. + /// The bookshelf data plane API URI. + /// Keeps track of any properties unknown to the library. + internal BookshelfProperties(ProvisioningState? provisioningState, IDictionary workloadIdentities, CustomerManagedKeys? customerManagedKeys, BookshelfKeyVaultProperties keyVaultProperties, ResourceIdentifier logAnalyticsClusterId, IReadOnlyList privateEndpointConnections, PublicNetworkAccess? publicNetworkAccess, ResourceIdentifier privateEndpointSubnetId, ResourceIdentifier searchSubnetId, string managedResourceGroup, WithMoboBrokerResources managedOnBehalfOfConfiguration, Uri bookshelfUri, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + WorkloadIdentities = workloadIdentities; + CustomerManagedKeys = customerManagedKeys; + KeyVaultProperties = keyVaultProperties; + LogAnalyticsClusterId = logAnalyticsClusterId; + PrivateEndpointConnections = privateEndpointConnections; + PublicNetworkAccess = publicNetworkAccess; + PrivateEndpointSubnetId = privateEndpointSubnetId; + SearchSubnetId = searchSubnetId; + ManagedResourceGroup = managedResourceGroup; + ManagedOnBehalfOfConfiguration = managedOnBehalfOfConfiguration; + BookshelfUri = bookshelfUri; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// User assigned identity IDs to be used by knowledgebase workloads. The key value must be the resource ID of the identity resource. + public IDictionary WorkloadIdentities { get; } + + /// Whether or not to use a customer managed key when encrypting data at rest. + public CustomerManagedKeys? CustomerManagedKeys { get; set; } + + /// The key to use for encrypting data at rest when customer managed keys are enabled. Required if Customer Managed Keys is enabled. + public BookshelfKeyVaultProperties KeyVaultProperties { get; set; } + + /// The Log Analytics Cluster to use for debug logs. This is required when Customer Managed Keys are enabled. + public ResourceIdentifier LogAnalyticsClusterId { get; set; } + + /// List of private endpoint connections. + public IReadOnlyList PrivateEndpointConnections { get; } + + /// Whether or not public network access is allowed for this resource. For security reasons, it is recommended to disable it whenever possible. + public PublicNetworkAccess? PublicNetworkAccess { get; set; } + + /// Private Endpoint Subnet ID for private endpoint connections. + public ResourceIdentifier PrivateEndpointSubnetId { get; set; } + + /// Search Subnet ID for search resources. + public ResourceIdentifier SearchSubnetId { get; set; } + + /// The resource group for resources managed on behalf of customer. + public string ManagedResourceGroup { get; } + + /// Managed-On-Behalf-Of configuration properties. This configuration exists for the resources where a resource provider manages those resources on behalf of the resource owner. + internal WithMoboBrokerResources ManagedOnBehalfOfConfiguration { get; } + + /// The bookshelf data plane API URI. + public Uri BookshelfUri { get; } + + /// Managed-On-Behalf-Of broker resources. + public IReadOnlyList ManagedOnBehalfOfMoboBrokerResources + { + get + { + return ManagedOnBehalfOfConfiguration.MoboBrokerResources; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentListResult.Serialization.cs new file mode 100644 index 000000000000..23f67cdaa072 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a ChatModelDeployment list operation. + internal partial class ChatModelDeploymentListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ChatModelDeploymentListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChatModelDeploymentListResult 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 DeserializeChatModelDeploymentListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatModelDeploymentListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ChatModelDeploymentListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ChatModelDeploymentListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ChatModelDeploymentListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatModelDeploymentListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(ChatModelDeploymentListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (ChatModelDeploymentData 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. + ChatModelDeploymentListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChatModelDeploymentListResult 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(ChatModelDeploymentListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatModelDeploymentListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ChatModelDeploymentListResult DeserializeChatModelDeploymentListResult(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(ChatModelDeploymentData.DeserializeChatModelDeploymentData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChatModelDeploymentListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentListResult.cs new file mode 100644 index 000000000000..cb92633a3baf --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a ChatModelDeployment list operation. + internal partial class ChatModelDeploymentListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The ChatModelDeployment items on this page. + internal ChatModelDeploymentListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The ChatModelDeployment items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal ChatModelDeploymentListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ChatModelDeployment items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentProperties.Serialization.cs new file mode 100644 index 000000000000..0657578fe589 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentProperties.Serialization.cs @@ -0,0 +1,166 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Defines a deployment binding a specific model family to a user-defined deployment name for chat inference. + public partial class ChatModelDeploymentProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ChatModelDeploymentProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChatModelDeploymentProperties 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 DeserializeChatModelDeploymentProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatModelDeploymentProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ChatModelDeploymentProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ChatModelDeploymentProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(ChatModelDeploymentProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + writer.WritePropertyName("modelFormat"u8); + writer.WriteStringValue(ModelFormat); + writer.WritePropertyName("modelName"u8); + writer.WriteStringValue(ModelName); + 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. + ChatModelDeploymentProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChatModelDeploymentProperties 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(ChatModelDeploymentProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatModelDeploymentProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ChatModelDeploymentProperties DeserializeChatModelDeploymentProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + string modelFormat = default; + string modelName = 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("modelFormat"u8)) + { + modelFormat = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("modelName"u8)) + { + modelName = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChatModelDeploymentProperties(provisioningState, modelFormat, modelName, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentProperties.cs new file mode 100644 index 000000000000..97077dc5362f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ChatModelDeploymentProperties.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Defines a deployment binding a specific model family to a user-defined deployment name for chat inference. + public partial class ChatModelDeploymentProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Model format as published by the provider. Verify supported formats per region using the Model Catalog API. + /// Canonical provider model name available in the selected region. Verify supported values per region using the Model Catalog API. + /// or is null. + public ChatModelDeploymentProperties(string modelFormat, string modelName) + { + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + + ModelFormat = modelFormat; + ModelName = modelName; + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// Model format as published by the provider. Verify supported formats per region using the Model Catalog API. + /// Canonical provider model name available in the selected region. Verify supported values per region using the Model Catalog API. + /// Keeps track of any properties unknown to the library. + internal ChatModelDeploymentProperties(ProvisioningState? provisioningState, string modelFormat, string modelName, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + ModelFormat = modelFormat; + ModelName = modelName; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// Model format as published by the provider. Verify supported formats per region using the Model Catalog API. + public string ModelFormat { get; set; } + + /// Canonical provider model name available in the selected region. Verify supported values per region using the Model Catalog API. + public string ModelName { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/CustomerManagedKeys.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/CustomerManagedKeys.cs new file mode 100644 index 000000000000..83329684121a --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/CustomerManagedKeys.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// State of customer managed key usage. + public readonly partial struct CustomerManagedKeys : IEquatable + { + private readonly string _value; + /// Customer managed keys are enabled. + private const string EnabledValue = "Enabled"; + /// Customer managed keys are disabled. + private const string DisabledValue = "Disabled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public CustomerManagedKeys(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Customer managed keys are enabled. + public static CustomerManagedKeys Enabled { get; } = new CustomerManagedKeys(EnabledValue); + + /// Customer managed keys are disabled. + public static CustomerManagedKeys Disabled { get; } = new CustomerManagedKeys(DisabledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(CustomerManagedKeys left, CustomerManagedKeys 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 !=(CustomerManagedKeys left, CustomerManagedKeys right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator CustomerManagedKeys(string value) => new CustomerManagedKeys(value); + + /// Converts a string to a . + /// The value. + public static implicit operator CustomerManagedKeys?(string value) => value == null ? null : new CustomerManagedKeys(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CustomerManagedKeys other && Equals(other); + + /// + public bool Equals(CustomerManagedKeys 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointConnection.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointConnection.Serialization.cs new file mode 100644 index 000000000000..b50977b6aab4 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointConnection.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; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Discovery; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The private endpoint connection resource. + public partial class DiscoveryPrivateEndpointConnection : ResourceData, IJsonModel + { + /// 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 DeserializeDiscoveryPrivateEndpointConnection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DiscoveryPrivateEndpointConnection)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(DiscoveryPrivateEndpointConnection)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + DiscoveryPrivateEndpointConnection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DiscoveryPrivateEndpointConnection)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(DiscoveryPrivateEndpointConnection)} 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. + DiscoveryPrivateEndpointConnection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DiscoveryPrivateEndpointConnection)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(DiscoveryPrivateEndpointConnection)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDiscoveryPrivateEndpointConnection(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DiscoveryPrivateEndpointConnection DeserializeDiscoveryPrivateEndpointConnection(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(); + PrivateEndpointConnectionProperties 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, AzureResourceManagerDiscoveryContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = PrivateEndpointConnectionProperties.DeserializePrivateEndpointConnectionProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DiscoveryPrivateEndpointConnection( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointConnection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointConnection.cs new file mode 100644 index 000000000000..b4dfc5f9e4cc --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointConnection.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.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The private endpoint connection resource. + public partial class DiscoveryPrivateEndpointConnection : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal DiscoveryPrivateEndpointConnection() + { + } + + /// 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 private endpoint connection properties. + internal DiscoveryPrivateEndpointConnection(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, PrivateEndpointConnectionProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The private endpoint connection properties. + public PrivateEndpointConnectionProperties Properties { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointConnectionProvisioningState.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointConnectionProvisioningState.cs new file mode 100644 index 000000000000..15c5826bfe5f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointConnectionProvisioningState.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The current provisioning state. + public readonly partial struct DiscoveryPrivateEndpointConnectionProvisioningState : IEquatable + { + private readonly string _value; + /// Connection has been provisioned. + private const string SucceededValue = "Succeeded"; + /// Connection is being created. + private const string CreatingValue = "Creating"; + /// Connection is being deleted. + private const string DeletingValue = "Deleting"; + /// Connection provisioning has failed. + private const string FailedValue = "Failed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public DiscoveryPrivateEndpointConnectionProvisioningState(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Connection has been provisioned. + public static DiscoveryPrivateEndpointConnectionProvisioningState Succeeded { get; } = new DiscoveryPrivateEndpointConnectionProvisioningState(SucceededValue); + + /// Connection is being created. + public static DiscoveryPrivateEndpointConnectionProvisioningState Creating { get; } = new DiscoveryPrivateEndpointConnectionProvisioningState(CreatingValue); + + /// Connection is being deleted. + public static DiscoveryPrivateEndpointConnectionProvisioningState Deleting { get; } = new DiscoveryPrivateEndpointConnectionProvisioningState(DeletingValue); + + /// Connection provisioning has failed. + public static DiscoveryPrivateEndpointConnectionProvisioningState Failed { get; } = new DiscoveryPrivateEndpointConnectionProvisioningState(FailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(DiscoveryPrivateEndpointConnectionProvisioningState left, DiscoveryPrivateEndpointConnectionProvisioningState 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 !=(DiscoveryPrivateEndpointConnectionProvisioningState left, DiscoveryPrivateEndpointConnectionProvisioningState right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator DiscoveryPrivateEndpointConnectionProvisioningState(string value) => new DiscoveryPrivateEndpointConnectionProvisioningState(value); + + /// Converts a string to a . + /// The value. + public static implicit operator DiscoveryPrivateEndpointConnectionProvisioningState?(string value) => value == null ? null : new DiscoveryPrivateEndpointConnectionProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DiscoveryPrivateEndpointConnectionProvisioningState other && Equals(other); + + /// + public bool Equals(DiscoveryPrivateEndpointConnectionProvisioningState 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointServiceConnectionStatus.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointServiceConnectionStatus.cs new file mode 100644 index 000000000000..46e77b7968b5 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateEndpointServiceConnectionStatus.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The private endpoint connection status. + public readonly partial struct DiscoveryPrivateEndpointServiceConnectionStatus : IEquatable + { + private readonly string _value; + /// Connection waiting for approval or rejection. + private const string PendingValue = "Pending"; + /// Connection approved. + private const string ApprovedValue = "Approved"; + /// Connection Rejected. + private const string RejectedValue = "Rejected"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public DiscoveryPrivateEndpointServiceConnectionStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Connection waiting for approval or rejection. + public static DiscoveryPrivateEndpointServiceConnectionStatus Pending { get; } = new DiscoveryPrivateEndpointServiceConnectionStatus(PendingValue); + + /// Connection approved. + public static DiscoveryPrivateEndpointServiceConnectionStatus Approved { get; } = new DiscoveryPrivateEndpointServiceConnectionStatus(ApprovedValue); + + /// Connection Rejected. + public static DiscoveryPrivateEndpointServiceConnectionStatus Rejected { get; } = new DiscoveryPrivateEndpointServiceConnectionStatus(RejectedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(DiscoveryPrivateEndpointServiceConnectionStatus left, DiscoveryPrivateEndpointServiceConnectionStatus 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 !=(DiscoveryPrivateEndpointServiceConnectionStatus left, DiscoveryPrivateEndpointServiceConnectionStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator DiscoveryPrivateEndpointServiceConnectionStatus(string value) => new DiscoveryPrivateEndpointServiceConnectionStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator DiscoveryPrivateEndpointServiceConnectionStatus?(string value) => value == null ? null : new DiscoveryPrivateEndpointServiceConnectionStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DiscoveryPrivateEndpointServiceConnectionStatus other && Equals(other); + + /// + public bool Equals(DiscoveryPrivateEndpointServiceConnectionStatus 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkResourceProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkResourceProperties.Serialization.cs new file mode 100644 index 000000000000..746a8a956729 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkResourceProperties.Serialization.cs @@ -0,0 +1,215 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Properties of a private link resource. + public partial class DiscoveryPrivateLinkResourceProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DiscoveryPrivateLinkResourceProperties 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 DeserializeDiscoveryPrivateLinkResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DiscoveryPrivateLinkResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(DiscoveryPrivateLinkResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + DiscoveryPrivateLinkResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(DiscoveryPrivateLinkResourceProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(GroupId)) + { + writer.WritePropertyName("groupId"u8); + writer.WriteStringValue(GroupId); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RequiredMembers)) + { + writer.WritePropertyName("requiredMembers"u8); + writer.WriteStartArray(); + foreach (string item in RequiredMembers) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(RequiredZoneNames)) + { + writer.WritePropertyName("requiredZoneNames"u8); + writer.WriteStartArray(); + foreach (string item in RequiredZoneNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + 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. + DiscoveryPrivateLinkResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DiscoveryPrivateLinkResourceProperties 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(DiscoveryPrivateLinkResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDiscoveryPrivateLinkResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DiscoveryPrivateLinkResourceProperties DeserializeDiscoveryPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string groupId = default; + IReadOnlyList requiredMembers = default; + IList requiredZoneNames = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("groupId"u8)) + { + groupId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("requiredMembers"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + requiredMembers = array; + continue; + } + if (prop.NameEquals("requiredZoneNames"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + requiredZoneNames = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DiscoveryPrivateLinkResourceProperties(groupId, requiredMembers ?? new ChangeTrackingList(), requiredZoneNames ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkResourceProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkResourceProperties.cs new file mode 100644 index 000000000000..364c912eef22 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkResourceProperties.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Properties of a private link resource. + public partial class DiscoveryPrivateLinkResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal DiscoveryPrivateLinkResourceProperties() + { + RequiredMembers = new ChangeTrackingList(); + RequiredZoneNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The private link resource group id. + /// The private link resource required member names. + /// The private link resource private link DNS zone name. + /// Keeps track of any properties unknown to the library. + internal DiscoveryPrivateLinkResourceProperties(string groupId, IReadOnlyList requiredMembers, IList requiredZoneNames, IDictionary additionalBinaryDataProperties) + { + GroupId = groupId; + RequiredMembers = requiredMembers; + RequiredZoneNames = requiredZoneNames; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The private link resource group id. + public string GroupId { get; } + + /// The private link resource required member names. + public IReadOnlyList RequiredMembers { get; } + + /// The private link resource private link DNS zone name. + public IList RequiredZoneNames { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkServiceConnectionState.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkServiceConnectionState.Serialization.cs new file mode 100644 index 000000000000..5c33b97678c3 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkServiceConnectionState.Serialization.cs @@ -0,0 +1,167 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// A collection of information about the state of the connection between service consumer and provider. + public partial class DiscoveryPrivateLinkServiceConnectionState : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DiscoveryPrivateLinkServiceConnectionState 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 DeserializeDiscoveryPrivateLinkServiceConnectionState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DiscoveryPrivateLinkServiceConnectionState)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(DiscoveryPrivateLinkServiceConnectionState)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + DiscoveryPrivateLinkServiceConnectionState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(DiscoveryPrivateLinkServiceConnectionState)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(ActionsRequired)) + { + writer.WritePropertyName("actionsRequired"u8); + writer.WriteStringValue(ActionsRequired); + } + 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. + DiscoveryPrivateLinkServiceConnectionState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DiscoveryPrivateLinkServiceConnectionState 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(DiscoveryPrivateLinkServiceConnectionState)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDiscoveryPrivateLinkServiceConnectionState(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DiscoveryPrivateLinkServiceConnectionState DeserializeDiscoveryPrivateLinkServiceConnectionState(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DiscoveryPrivateEndpointServiceConnectionStatus? status = default; + string description = default; + string actionsRequired = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new DiscoveryPrivateEndpointServiceConnectionStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("actionsRequired"u8)) + { + actionsRequired = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DiscoveryPrivateLinkServiceConnectionState(status, description, actionsRequired, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkServiceConnectionState.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkServiceConnectionState.cs new file mode 100644 index 000000000000..fa1ff90bf4bf --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/DiscoveryPrivateLinkServiceConnectionState.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.Discovery.Models +{ + /// A collection of information about the state of the connection between service consumer and provider. + public partial class DiscoveryPrivateLinkServiceConnectionState + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public DiscoveryPrivateLinkServiceConnectionState() + { + } + + /// Initializes a new instance of . + /// Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + /// The reason for approval/rejection of the connection. + /// A message indicating if changes on the service provider require any updates on the consumer. + /// Keeps track of any properties unknown to the library. + internal DiscoveryPrivateLinkServiceConnectionState(DiscoveryPrivateEndpointServiceConnectionStatus? status, string description, string actionsRequired, IDictionary additionalBinaryDataProperties) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + public DiscoveryPrivateEndpointServiceConnectionStatus? Status { get; set; } + + /// The reason for approval/rejection of the connection. + public string Description { get; set; } + + /// A message indicating if changes on the service provider require any updates on the consumer. + public string ActionsRequired { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/Identity.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/Identity.Serialization.cs new file mode 100644 index 000000000000..94c17a9c35f2 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/Identity.Serialization.cs @@ -0,0 +1,174 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// For user assigned identity resource property. + public partial class Identity : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Identity() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Identity 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 DeserializeIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Identity)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(Identity)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + Identity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(Identity)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + if (options.Format != "W" && Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId.Value); + } + if (options.Format != "W" && Optional.IsDefined(ClientId)) + { + writer.WritePropertyName("clientId"u8); + writer.WriteStringValue(ClientId.Value); + } + 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. + Identity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Identity 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(Identity)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIdentity(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Identity DeserializeIdentity(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + Guid? principalId = default; + Guid? clientId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("principalId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + principalId = new Guid(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("clientId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + clientId = new Guid(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Identity(id, principalId, clientId, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/Identity.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/Identity.cs new file mode 100644 index 000000000000..84cd46bb182b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/Identity.cs @@ -0,0 +1,53 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// For user assigned identity resource property. + public partial class Identity + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The resource ID of the user assigned identity. + /// is null. + public Identity(ResourceIdentifier id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// The resource ID of the user assigned identity. + /// The principal ID of the assigned identity. + /// The client ID of the assigned identity. + /// Keeps track of any properties unknown to the library. + internal Identity(ResourceIdentifier id, Guid? principalId, Guid? clientId, IDictionary additionalBinaryDataProperties) + { + Id = id; + PrincipalId = principalId; + ClientId = clientId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The resource ID of the user assigned identity. + public ResourceIdentifier Id { get; set; } + + /// The principal ID of the assigned identity. + public Guid? PrincipalId { get; } + + /// The client ID of the assigned identity. + public Guid? ClientId { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/KeyVaultProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/KeyVaultProperties.Serialization.cs new file mode 100644 index 000000000000..af57b7f42bb4 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/KeyVaultProperties.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// For Key Vault Key references. + public partial class KeyVaultProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal KeyVaultProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual KeyVaultProperties 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 DeserializeKeyVaultProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyVaultProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(KeyVaultProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + KeyVaultProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(KeyVaultProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("keyVaultUri"u8); + writer.WriteStringValue(KeyVaultUri.AbsoluteUri); + writer.WritePropertyName("keyName"u8); + writer.WriteStringValue(KeyName); + if (Optional.IsDefined(KeyVersion)) + { + writer.WritePropertyName("keyVersion"u8); + writer.WriteStringValue(KeyVersion); + } + 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. + KeyVaultProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual KeyVaultProperties 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(KeyVaultProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyVaultProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static KeyVaultProperties DeserializeKeyVaultProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri keyVaultUri = default; + string keyName = default; + string keyVersion = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("keyVaultUri"u8)) + { + keyVaultUri = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (prop.NameEquals("keyName"u8)) + { + keyName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("keyVersion"u8)) + { + keyVersion = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new KeyVaultProperties(keyVaultUri, keyName, keyVersion, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/KeyVaultProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/KeyVaultProperties.cs new file mode 100644 index 000000000000..ca16981df1e1 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/KeyVaultProperties.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// For Key Vault Key references. + public partial class KeyVaultProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Key Vault URI. + /// The Key Name in Key Vault. + /// or is null. + public KeyVaultProperties(Uri keyVaultUri, string keyName) + { + Argument.AssertNotNull(keyVaultUri, nameof(keyVaultUri)); + Argument.AssertNotNull(keyName, nameof(keyName)); + + KeyVaultUri = keyVaultUri; + KeyName = keyName; + } + + /// Initializes a new instance of . + /// The Key Vault URI. + /// The Key Name in Key Vault. + /// The Key Version in Key Vault. + /// Keeps track of any properties unknown to the library. + internal KeyVaultProperties(Uri keyVaultUri, string keyName, string keyVersion, IDictionary additionalBinaryDataProperties) + { + KeyVaultUri = keyVaultUri; + KeyName = keyName; + KeyVersion = keyVersion; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Key Vault URI. + public Uri KeyVaultUri { get; set; } + + /// The Key Name in Key Vault. + public string KeyName { get; set; } + + /// The Key Version in Key Vault. + public string KeyVersion { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/MoboBrokerResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/MoboBrokerResource.Serialization.cs new file mode 100644 index 000000000000..f2be3afc2cb6 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/MoboBrokerResource.Serialization.cs @@ -0,0 +1,146 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Managed-On-Behalf-Of broker resource. This resource is created by the Resource Provider to manage some resources on behalf of the user. + public partial class MoboBrokerResource : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MoboBrokerResource 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 DeserializeMoboBrokerResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MoboBrokerResource)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(MoboBrokerResource)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + MoboBrokerResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(MoboBrokerResource)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + 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. + MoboBrokerResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MoboBrokerResource 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(MoboBrokerResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMoboBrokerResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MoboBrokerResource DeserializeMoboBrokerResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + 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 (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MoboBrokerResource(id, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/MoboBrokerResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/MoboBrokerResource.cs new file mode 100644 index 000000000000..b8769f407ef0 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/MoboBrokerResource.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Managed-On-Behalf-Of broker resource. This resource is created by the Resource Provider to manage some resources on behalf of the user. + public partial class MoboBrokerResource + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal MoboBrokerResource() + { + } + + /// Initializes a new instance of . + /// Resource identifier of a Managed-On-Behalf-Of broker resource. + /// Keeps track of any properties unknown to the library. + internal MoboBrokerResource(ResourceIdentifier id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Resource identifier of a Managed-On-Behalf-Of broker resource. + public ResourceIdentifier Id { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NetworkEgressType.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NetworkEgressType.cs new file mode 100644 index 000000000000..6767096870b2 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NetworkEgressType.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Supported network egress types. + public readonly partial struct NetworkEgressType : IEquatable + { + private readonly string _value; + /// Public outbound network via load balancer (Default). + private const string LoadBalancerValue = "LoadBalancer"; + /// No default outbound. + private const string NoneValue = "None"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public NetworkEgressType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Public outbound network via load balancer (Default). + public static NetworkEgressType LoadBalancer { get; } = new NetworkEgressType(LoadBalancerValue); + + /// No default outbound. + public static NetworkEgressType None { get; } = new NetworkEgressType(NoneValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(NetworkEgressType left, NetworkEgressType 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 !=(NetworkEgressType left, NetworkEgressType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator NetworkEgressType(string value) => new NetworkEgressType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator NetworkEgressType?(string value) => value == null ? null : new NetworkEgressType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NetworkEgressType other && Equals(other); + + /// + public bool Equals(NetworkEgressType 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolListResult.Serialization.cs new file mode 100644 index 000000000000..10e39012211d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a NodePool list operation. + internal partial class NodePoolListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal NodePoolListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual NodePoolListResult 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 DeserializeNodePoolListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NodePoolListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(NodePoolListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + NodePoolListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static NodePoolListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNodePoolListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(NodePoolListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (NodePoolData 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. + NodePoolListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual NodePoolListResult 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(NodePoolListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNodePoolListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NodePoolListResult DeserializeNodePoolListResult(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(NodePoolData.DeserializeNodePoolData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new NodePoolListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolListResult.cs new file mode 100644 index 000000000000..19a19819a7b3 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a NodePool list operation. + internal partial class NodePoolListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The NodePool items on this page. + internal NodePoolListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The NodePool items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal NodePoolListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The NodePool items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolProperties.Serialization.cs new file mode 100644 index 000000000000..4702b537c7ce --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolProperties.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// NodePool properties. + public partial class NodePoolProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal NodePoolProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual NodePoolProperties 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 DeserializeNodePoolProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NodePoolProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(NodePoolProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + NodePoolProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(NodePoolProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + writer.WritePropertyName("subnetId"u8); + writer.WriteStringValue(SubnetId); + writer.WritePropertyName("vmSize"u8); + writer.WriteStringValue(VmSize.ToString()); + writer.WritePropertyName("maxNodeCount"u8); + writer.WriteNumberValue(MaxNodeCount); + if (Optional.IsDefined(MinNodeCount)) + { + writer.WritePropertyName("minNodeCount"u8); + writer.WriteNumberValue(MinNodeCount.Value); + } + if (Optional.IsDefined(ScaleSetPriority)) + { + writer.WritePropertyName("scaleSetPriority"u8); + writer.WriteStringValue(ScaleSetPriority.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. + NodePoolProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual NodePoolProperties 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(NodePoolProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNodePoolProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NodePoolProperties DeserializeNodePoolProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + ResourceIdentifier subnetId = default; + VmSize vmSize = default; + int maxNodeCount = default; + int? minNodeCount = default; + ScaleSetPriority? scaleSetPriority = 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("subnetId"u8)) + { + subnetId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("vmSize"u8)) + { + vmSize = new VmSize(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("maxNodeCount"u8)) + { + maxNodeCount = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("minNodeCount"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minNodeCount = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("scaleSetPriority"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + scaleSetPriority = new ScaleSetPriority(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new NodePoolProperties( + provisioningState, + subnetId, + vmSize, + maxNodeCount, + minNodeCount, + scaleSetPriority, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolProperties.cs new file mode 100644 index 000000000000..d78dc510dfb0 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/NodePoolProperties.cs @@ -0,0 +1,72 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// NodePool properties. + public partial class NodePoolProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The node pool subnet. + /// The size of the underlying Azure VM. + /// The maximum number of nodes. + /// is null. + public NodePoolProperties(ResourceIdentifier subnetId, VmSize vmSize, int maxNodeCount) + { + Argument.AssertNotNull(subnetId, nameof(subnetId)); + + SubnetId = subnetId; + VmSize = vmSize; + MaxNodeCount = maxNodeCount; + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// The node pool subnet. + /// The size of the underlying Azure VM. + /// The maximum number of nodes. + /// The minimum number of nodes. + /// The Virtual Machine Scale Set priority. If not specified, the default is 'Regular'. + /// Keeps track of any properties unknown to the library. + internal NodePoolProperties(ProvisioningState? provisioningState, ResourceIdentifier subnetId, VmSize vmSize, int maxNodeCount, int? minNodeCount, ScaleSetPriority? scaleSetPriority, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + SubnetId = subnetId; + VmSize = vmSize; + MaxNodeCount = maxNodeCount; + MinNodeCount = minNodeCount; + ScaleSetPriority = scaleSetPriority; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// The node pool subnet. + public ResourceIdentifier SubnetId { get; set; } + + /// The size of the underlying Azure VM. + public VmSize VmSize { get; set; } + + /// The maximum number of nodes. + public int MaxNodeCount { get; set; } + + /// The minimum number of nodes. + public int? MinNodeCount { get; set; } + + /// The Virtual Machine Scale Set priority. If not specified, the default is 'Regular'. + public ScaleSetPriority? ScaleSetPriority { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpoint.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpoint.Serialization.cs new file mode 100644 index 000000000000..c3c9207e9cf0 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpoint.Serialization.cs @@ -0,0 +1,146 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The private endpoint resource. + internal partial class PrivateEndpoint : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PrivateEndpoint 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 DeserializePrivateEndpoint(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrivateEndpoint)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateEndpoint)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + PrivateEndpoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(PrivateEndpoint)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + 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. + PrivateEndpoint IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PrivateEndpoint 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(PrivateEndpoint)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrivateEndpoint(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PrivateEndpoint DeserializePrivateEndpoint(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + 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 (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PrivateEndpoint(id, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpoint.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpoint.cs new file mode 100644 index 000000000000..348add626d7f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpoint.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The private endpoint resource. + internal partial class PrivateEndpoint + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public PrivateEndpoint() + { + } + + /// Initializes a new instance of . + /// The resource identifier of the private endpoint. + /// Keeps track of any properties unknown to the library. + internal PrivateEndpoint(ResourceIdentifier id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The resource identifier of the private endpoint. + public ResourceIdentifier Id { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs new file mode 100644 index 000000000000..3c41b18db3c3 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs @@ -0,0 +1,210 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Properties of the private endpoint connection. + public partial class PrivateEndpointConnectionProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PrivateEndpointConnectionProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PrivateEndpointConnectionProperties 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 DeserializePrivateEndpointConnectionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + PrivateEndpointConnectionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(PrivateEndpointConnectionProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsCollectionDefined(GroupIds)) + { + writer.WritePropertyName("groupIds"u8); + writer.WriteStartArray(); + foreach (string item in GroupIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PrivateEndpoint)) + { + writer.WritePropertyName("privateEndpoint"u8); + writer.WriteObjectValue(PrivateEndpoint, options); + } + writer.WritePropertyName("privateLinkServiceConnectionState"u8); + writer.WriteObjectValue(PrivateLinkServiceConnectionState, options); + 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. + PrivateEndpointConnectionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PrivateEndpointConnectionProperties 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(PrivateEndpointConnectionProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrivateEndpointConnectionProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PrivateEndpointConnectionProperties DeserializePrivateEndpointConnectionProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList groupIds = default; + PrivateEndpoint privateEndpoint = default; + DiscoveryPrivateLinkServiceConnectionState privateLinkServiceConnectionState = default; + DiscoveryPrivateEndpointConnectionProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("groupIds"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + groupIds = array; + continue; + } + if (prop.NameEquals("privateEndpoint"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateEndpoint = PrivateEndpoint.DeserializePrivateEndpoint(prop.Value, options); + continue; + } + if (prop.NameEquals("privateLinkServiceConnectionState"u8)) + { + privateLinkServiceConnectionState = DiscoveryPrivateLinkServiceConnectionState.DeserializeDiscoveryPrivateLinkServiceConnectionState(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new DiscoveryPrivateEndpointConnectionProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PrivateEndpointConnectionProperties(groupIds ?? new ChangeTrackingList(), privateEndpoint, privateLinkServiceConnectionState, provisioningState, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpointConnectionProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpointConnectionProperties.cs new file mode 100644 index 000000000000..b6c06c401c00 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PrivateEndpointConnectionProperties.cs @@ -0,0 +1,68 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Properties of the private endpoint connection. + public partial class PrivateEndpointConnectionProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A collection of information about the state of the connection between service consumer and provider. + /// is null. + public PrivateEndpointConnectionProperties(DiscoveryPrivateLinkServiceConnectionState privateLinkServiceConnectionState) + { + Argument.AssertNotNull(privateLinkServiceConnectionState, nameof(privateLinkServiceConnectionState)); + + GroupIds = new ChangeTrackingList(); + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + } + + /// Initializes a new instance of . + /// The group ids for the private endpoint resource. + /// The private endpoint resource. + /// A collection of information about the state of the connection between service consumer and provider. + /// The provisioning state of the private endpoint connection resource. + /// Keeps track of any properties unknown to the library. + internal PrivateEndpointConnectionProperties(IReadOnlyList groupIds, PrivateEndpoint privateEndpoint, DiscoveryPrivateLinkServiceConnectionState privateLinkServiceConnectionState, DiscoveryPrivateEndpointConnectionProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + GroupIds = groupIds; + PrivateEndpoint = privateEndpoint; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The group ids for the private endpoint resource. + public IReadOnlyList GroupIds { get; } + + /// The private endpoint resource. + internal PrivateEndpoint PrivateEndpoint { get; set; } + + /// A collection of information about the state of the connection between service consumer and provider. + public DiscoveryPrivateLinkServiceConnectionState PrivateLinkServiceConnectionState { get; set; } + + /// The provisioning state of the private endpoint connection resource. + public DiscoveryPrivateEndpointConnectionProvisioningState? ProvisioningState { get; } + + /// The resource identifier of the private endpoint. + public ResourceIdentifier PrivateEndpointId + { + get + { + return PrivateEndpoint is null ? default : PrivateEndpoint.Id; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectListResult.Serialization.cs new file mode 100644 index 000000000000..fe92765761cd --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Project list operation. + internal partial class ProjectListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ProjectListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProjectListResult 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 DeserializeProjectListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ProjectListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ProjectListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ProjectListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProjectListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(ProjectListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (ProjectData 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. + ProjectListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProjectListResult 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(ProjectListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProjectListResult DeserializeProjectListResult(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(ProjectData.DeserializeProjectData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProjectListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectListResult.cs new file mode 100644 index 000000000000..d30195fe679e --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Project list operation. + internal partial class ProjectListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Project items on this page. + internal ProjectListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Project items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal ProjectListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Project items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectProperties.Serialization.cs new file mode 100644 index 000000000000..fb2230eb00fa --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectProperties.Serialization.cs @@ -0,0 +1,213 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Project properties. + public partial class ProjectProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProjectProperties 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 DeserializeProjectProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ProjectProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ProjectProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(ProjectProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(FoundryProjectEndpoint)) + { + writer.WritePropertyName("foundryProjectEndpoint"u8); + writer.WriteStringValue(FoundryProjectEndpoint.AbsoluteUri); + } + if (Optional.IsCollectionDefined(StorageContainerIds)) + { + writer.WritePropertyName("storageContainerIds"u8); + writer.WriteStartArray(); + foreach (ResourceIdentifier item in StorageContainerIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Settings)) + { + writer.WritePropertyName("settings"u8); + writer.WriteObjectValue(Settings, options); + } + 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. + ProjectProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProjectProperties 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(ProjectProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProjectProperties DeserializeProjectProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + Uri foundryProjectEndpoint = default; + IList storageContainerIds = default; + ProjectSettings settings = 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("foundryProjectEndpoint"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + foundryProjectEndpoint = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (prop.NameEquals("storageContainerIds"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + storageContainerIds = array; + continue; + } + if (prop.NameEquals("settings"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + settings = ProjectSettings.DeserializeProjectSettings(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProjectProperties(provisioningState, foundryProjectEndpoint, storageContainerIds ?? new ChangeTrackingList(), settings, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectProperties.cs new file mode 100644 index 000000000000..1eacea6b163d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectProperties.cs @@ -0,0 +1,71 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Project properties. + public partial class ProjectProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ProjectProperties() + { + StorageContainerIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// Foundry project endpoint URI. + /// Allowed StorageContainers (Control plane resource references). + /// Settings for the project. + /// Keeps track of any properties unknown to the library. + internal ProjectProperties(ProvisioningState? provisioningState, Uri foundryProjectEndpoint, IList storageContainerIds, ProjectSettings settings, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + FoundryProjectEndpoint = foundryProjectEndpoint; + StorageContainerIds = storageContainerIds; + Settings = settings; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// Foundry project endpoint URI. + public Uri FoundryProjectEndpoint { get; } + + /// Allowed StorageContainers (Control plane resource references). + public IList StorageContainerIds { get; } + + /// Settings for the project. + internal ProjectSettings Settings { get; set; } + + /// Default preferences to guide AI behaviors in this project. + public string BehaviorPreferences + { + get + { + return Settings is null ? default : Settings.BehaviorPreferences; + } + set + { + if (Settings is null) + { + Settings = new ProjectSettings(); + } + Settings.BehaviorPreferences = value; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectSettings.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectSettings.Serialization.cs new file mode 100644 index 000000000000..95e8ab0bf7be --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectSettings.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Settings schema for the project. + internal partial class ProjectSettings : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProjectSettings 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 DeserializeProjectSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectSettings)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ProjectSettings)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ProjectSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(ProjectSettings)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(BehaviorPreferences)) + { + writer.WritePropertyName("behaviorPreferences"u8); + writer.WriteStringValue(BehaviorPreferences); + } + 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. + ProjectSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProjectSettings 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(ProjectSettings)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectSettings(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProjectSettings DeserializeProjectSettings(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string behaviorPreferences = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("behaviorPreferences"u8)) + { + behaviorPreferences = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProjectSettings(behaviorPreferences, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectSettings.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectSettings.cs new file mode 100644 index 000000000000..db8a3213e18d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProjectSettings.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.Discovery.Models +{ + /// Settings schema for the project. + internal partial class ProjectSettings + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ProjectSettings() + { + } + + /// Initializes a new instance of . + /// Default preferences to guide AI behaviors in this project. + /// Keeps track of any properties unknown to the library. + internal ProjectSettings(string behaviorPreferences, IDictionary additionalBinaryDataProperties) + { + BehaviorPreferences = behaviorPreferences; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Default preferences to guide AI behaviors in this project. + public string BehaviorPreferences { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProvisioningState.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..e1ff561b6c8a --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The resource provisioning state. + 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"; + /// The resource create request has been accepted. + private const string AcceptedValue = "Accepted"; + /// The resource is being provisioned. + private const string ProvisioningValue = "Provisioning"; + /// The resource is updating. + private const string UpdatingValue = "Updating"; + /// The resource is being deleted. + private const string DeletingValue = "Deleting"; + + /// 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); + + /// The resource create request has been accepted. + public static ProvisioningState Accepted { get; } = new ProvisioningState(AcceptedValue); + + /// The resource is being provisioned. + public static ProvisioningState Provisioning { get; } = new ProvisioningState(ProvisioningValue); + + /// The resource is updating. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + + /// The resource is being deleted. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + + /// 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PublicNetworkAccess.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PublicNetworkAccess.cs new file mode 100644 index 000000000000..a593802d3396 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/PublicNetworkAccess.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// State of public network access. + public readonly partial struct PublicNetworkAccess : IEquatable + { + private readonly string _value; + /// Public network access is enabled. + private const string EnabledValue = "Enabled"; + /// Public network access is disabled. + private const string DisabledValue = "Disabled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public PublicNetworkAccess(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Public network access is enabled. + public static PublicNetworkAccess Enabled { get; } = new PublicNetworkAccess(EnabledValue); + + /// Public network access is disabled. + public static PublicNetworkAccess Disabled { get; } = new PublicNetworkAccess(DisabledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(PublicNetworkAccess left, PublicNetworkAccess 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 !=(PublicNetworkAccess left, PublicNetworkAccess right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator PublicNetworkAccess(string value) => new PublicNetworkAccess(value); + + /// Converts a string to a . + /// The value. + public static implicit operator PublicNetworkAccess?(string value) => value == null ? null : new PublicNetworkAccess(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PublicNetworkAccess other && Equals(other); + + /// + public bool Equals(PublicNetworkAccess 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ScaleSetPriority.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ScaleSetPriority.cs new file mode 100644 index 000000000000..fba909f0ed18 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ScaleSetPriority.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Supported Virtual Machine Scale Set priorities. + public readonly partial struct ScaleSetPriority : IEquatable + { + private readonly string _value; + /// Regular priority Virtual Machine Scale Set. + private const string RegularValue = "Regular"; + /// Spot priority Virtual Machine Scale Set. + private const string SpotValue = "Spot"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ScaleSetPriority(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Regular priority Virtual Machine Scale Set. + public static ScaleSetPriority Regular { get; } = new ScaleSetPriority(RegularValue); + + /// Spot priority Virtual Machine Scale Set. + public static ScaleSetPriority Spot { get; } = new ScaleSetPriority(SpotValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ScaleSetPriority left, ScaleSetPriority 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 !=(ScaleSetPriority left, ScaleSetPriority right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ScaleSetPriority(string value) => new ScaleSetPriority(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ScaleSetPriority?(string value) => value == null ? null : new ScaleSetPriority(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ScaleSetPriority other && Equals(other); + + /// + public bool Equals(ScaleSetPriority 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetListResult.Serialization.cs new file mode 100644 index 000000000000..a05ef561c603 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a StorageAsset list operation. + internal partial class StorageAssetListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal StorageAssetListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StorageAssetListResult 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 DeserializeStorageAssetListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageAssetListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(StorageAssetListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + StorageAssetListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static StorageAssetListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStorageAssetListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(StorageAssetListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (StorageAssetData 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. + StorageAssetListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StorageAssetListResult 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(StorageAssetListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageAssetListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StorageAssetListResult DeserializeStorageAssetListResult(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(StorageAssetData.DeserializeStorageAssetData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StorageAssetListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetListResult.cs new file mode 100644 index 000000000000..25f7964a0660 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a StorageAsset list operation. + internal partial class StorageAssetListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The StorageAsset items on this page. + internal StorageAssetListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The StorageAsset items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal StorageAssetListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The StorageAsset items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetProperties.Serialization.cs new file mode 100644 index 000000000000..f3a629a7e738 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetProperties.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.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Storage Asset properties. + public partial class StorageAssetProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal StorageAssetProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StorageAssetProperties 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 DeserializeStorageAssetProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageAssetProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(StorageAssetProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + StorageAssetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(StorageAssetProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(Path)) + { + writer.WritePropertyName("path"u8); + writer.WriteStringValue(Path); + } + 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. + StorageAssetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StorageAssetProperties 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(StorageAssetProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageAssetProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StorageAssetProperties DeserializeStorageAssetProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + ProvisioningState? provisioningState = default; + string path = 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 (prop.NameEquals("path"u8)) + { + path = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StorageAssetProperties(description, provisioningState, path, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetProperties.cs new file mode 100644 index 000000000000..e6edf31c3e75 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageAssetProperties.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Storage Asset properties. + public partial class StorageAssetProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The description. + /// is null. + public StorageAssetProperties(string description) + { + Argument.AssertNotNull(description, nameof(description)); + + Description = description; + } + + /// Initializes a new instance of . + /// The description. + /// The status of the last operation. + /// The path to the data within its parent container. This should be relative to the root of the parent container. + /// Keeps track of any properties unknown to the library. + internal StorageAssetProperties(string description, ProvisioningState? provisioningState, string path, IDictionary additionalBinaryDataProperties) + { + Description = description; + ProvisioningState = provisioningState; + Path = path; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The description. + public string Description { get; set; } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// The path to the data within its parent container. This should be relative to the root of the parent container. + public string Path { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerListResult.Serialization.cs new file mode 100644 index 000000000000..c4d2e04860a1 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a StorageContainer list operation. + internal partial class StorageContainerListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal StorageContainerListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StorageContainerListResult 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 DeserializeStorageContainerListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageContainerListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(StorageContainerListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + StorageContainerListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static StorageContainerListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStorageContainerListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(StorageContainerListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (StorageContainerData 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. + StorageContainerListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StorageContainerListResult 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(StorageContainerListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageContainerListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StorageContainerListResult DeserializeStorageContainerListResult(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(StorageContainerData.DeserializeStorageContainerData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StorageContainerListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerListResult.cs new file mode 100644 index 000000000000..b54e52d3a103 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a StorageContainer list operation. + internal partial class StorageContainerListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The StorageContainer items on this page. + internal StorageContainerListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The StorageContainer items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal StorageContainerListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The StorageContainer items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerProperties.Serialization.cs new file mode 100644 index 000000000000..44c265fec479 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerProperties.Serialization.cs @@ -0,0 +1,158 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Storage Container properties. + public partial class StorageContainerProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal StorageContainerProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StorageContainerProperties 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 DeserializeStorageContainerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageContainerProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(StorageContainerProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + StorageContainerProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(StorageContainerProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + writer.WritePropertyName("storageStore"u8); + writer.WriteObjectValue(StorageStore, options); + 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. + StorageContainerProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StorageContainerProperties 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(StorageContainerProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageContainerProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StorageContainerProperties DeserializeStorageContainerProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + StorageStore storageStore = 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("storageStore"u8)) + { + storageStore = StorageStore.DeserializeStorageStore(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StorageContainerProperties(provisioningState, storageStore, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerProperties.cs new file mode 100644 index 000000000000..e274150a9719 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageContainerProperties.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Storage Container properties. + public partial class StorageContainerProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Storage store properties. + /// is null. + public StorageContainerProperties(StorageStore storageStore) + { + Argument.AssertNotNull(storageStore, nameof(storageStore)); + + StorageStore = storageStore; + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// Storage store properties. + /// Keeps track of any properties unknown to the library. + internal StorageContainerProperties(ProvisioningState? provisioningState, StorageStore storageStore, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + StorageStore = storageStore; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// Storage store properties. + public StorageStore StorageStore { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageStore.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageStore.Serialization.cs new file mode 100644 index 000000000000..11e21405faca --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageStore.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// + /// An abstract representation of storage store kind. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + [PersistableModelProxy(typeof(UnknownStorageStore))] + public abstract partial class StorageStore : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal StorageStore() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StorageStore 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 DeserializeStorageStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageStore)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(StorageStore)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + StorageStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(StorageStore)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.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. + StorageStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StorageStore 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(StorageStore)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageStore(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StorageStore DeserializeStorageStore(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "AzureStorageBlob": + return AzureStorageBlobStore.DeserializeAzureStorageBlobStore(element, options); + case "AzureNetAppFiles": + return AzureNetAppFilesStore.DeserializeAzureNetAppFilesStore(element, options); + } + } + return UnknownStorageStore.DeserializeUnknownStorageStore(element, options); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageStore.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageStore.cs new file mode 100644 index 000000000000..67a91c428e92 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageStore.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.Discovery.Models +{ + /// + /// An abstract representation of storage store kind. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + public abstract partial class StorageStore + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The storage store kind. + private protected StorageStore(StorageStoreType kind) + { + Kind = kind; + } + + /// Initializes a new instance of . + /// The storage store kind. + /// Keeps track of any properties unknown to the library. + internal StorageStore(StorageStoreType kind, IDictionary additionalBinaryDataProperties) + { + Kind = kind; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The storage store kind. + internal StorageStoreType Kind { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageStoreType.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageStoreType.cs new file mode 100644 index 000000000000..b689783dcbbc --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/StorageStoreType.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The kind of the backing storage store. + internal readonly partial struct StorageStoreType : IEquatable + { + private readonly string _value; + /// The Azure storage blob kind. + private const string AzureStorageBlobValue = "AzureStorageBlob"; + /// The Azure NetApp Files kind. + private const string AzureNetAppFilesValue = "AzureNetAppFiles"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public StorageStoreType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// The Azure storage blob kind. + public static StorageStoreType AzureStorageBlob { get; } = new StorageStoreType(AzureStorageBlobValue); + + /// The Azure NetApp Files kind. + public static StorageStoreType AzureNetAppFiles { get; } = new StorageStoreType(AzureNetAppFilesValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(StorageStoreType left, StorageStoreType 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 !=(StorageStoreType left, StorageStoreType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator StorageStoreType(string value) => new StorageStoreType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator StorageStoreType?(string value) => value == null ? null : new StorageStoreType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StorageStoreType other && Equals(other); + + /// + public bool Equals(StorageStoreType 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerIdentities.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerIdentities.Serialization.cs new file mode 100644 index 000000000000..595c96ef1a44 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerIdentities.Serialization.cs @@ -0,0 +1,191 @@ +// 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.ResourceManager.Discovery; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Dictionary of identity properties for the Supercomputer. + public partial class SupercomputerIdentities : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SupercomputerIdentities() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SupercomputerIdentities 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 DeserializeSupercomputerIdentities(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SupercomputerIdentities)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(SupercomputerIdentities)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SupercomputerIdentities IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(SupercomputerIdentities)} does not support writing '{format}' format."); + } + writer.WritePropertyName("clusterIdentity"u8); + writer.WriteObjectValue(ClusterIdentity, options); + writer.WritePropertyName("kubeletIdentity"u8); + writer.WriteObjectValue(KubeletIdentity, options); + if (Optional.IsCollectionDefined(WorkloadIdentities)) + { + writer.WritePropertyName("workloadIdentities"u8); + writer.WriteStartObject(); + foreach (var item in WorkloadIdentities) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + ((IJsonModel)item.Value).Write(writer, options); + } + writer.WriteEndObject(); + } + 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. + SupercomputerIdentities IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SupercomputerIdentities 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(SupercomputerIdentities)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSupercomputerIdentities(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SupercomputerIdentities DeserializeSupercomputerIdentities(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Identity clusterIdentity = default; + Identity kubeletIdentity = default; + IDictionary workloadIdentities = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("clusterIdentity"u8)) + { + clusterIdentity = Identity.DeserializeIdentity(prop.Value, options); + continue; + } + if (prop.NameEquals("kubeletIdentity"u8)) + { + kubeletIdentity = Identity.DeserializeIdentity(prop.Value, options); + continue; + } + if (prop.NameEquals("workloadIdentities"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, ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDiscoveryContext.Default)); + } + } + workloadIdentities = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SupercomputerIdentities(clusterIdentity, kubeletIdentity, workloadIdentities ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerIdentities.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerIdentities.cs new file mode 100644 index 000000000000..bd8770216952 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerIdentities.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Discovery; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Dictionary of identity properties for the Supercomputer. + public partial class SupercomputerIdentities + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Cluster identity ID. + /// + /// Kubelet identity ID used by the supercomputer. + /// This identity is used by the supercomputer at node level to access Azure resources. + /// This identity must have ManagedIdentityOperator role on the clusterIdentity. + /// + /// or is null. + public SupercomputerIdentities(Identity clusterIdentity, Identity kubeletIdentity) + { + Argument.AssertNotNull(clusterIdentity, nameof(clusterIdentity)); + Argument.AssertNotNull(kubeletIdentity, nameof(kubeletIdentity)); + + ClusterIdentity = clusterIdentity; + KubeletIdentity = kubeletIdentity; + WorkloadIdentities = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Cluster identity ID. + /// + /// Kubelet identity ID used by the supercomputer. + /// This identity is used by the supercomputer at node level to access Azure resources. + /// This identity must have ManagedIdentityOperator role on the clusterIdentity. + /// + /// User assigned identity IDs to be used by workloads as federated credentials running on supercomputer. The key value must be the resource ID of the identity resource. + /// Keeps track of any properties unknown to the library. + internal SupercomputerIdentities(Identity clusterIdentity, Identity kubeletIdentity, IDictionary workloadIdentities, IDictionary additionalBinaryDataProperties) + { + ClusterIdentity = clusterIdentity; + KubeletIdentity = kubeletIdentity; + WorkloadIdentities = workloadIdentities; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Cluster identity ID. + public Identity ClusterIdentity { get; set; } + + /// + /// Kubelet identity ID used by the supercomputer. + /// This identity is used by the supercomputer at node level to access Azure resources. + /// This identity must have ManagedIdentityOperator role on the clusterIdentity. + /// + public Identity KubeletIdentity { get; set; } + + /// User assigned identity IDs to be used by workloads as federated credentials running on supercomputer. The key value must be the resource ID of the identity resource. + public IDictionary WorkloadIdentities { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerListResult.Serialization.cs new file mode 100644 index 000000000000..6cccf3e75b05 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Supercomputer list operation. + internal partial class SupercomputerListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SupercomputerListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SupercomputerListResult 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 DeserializeSupercomputerListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SupercomputerListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(SupercomputerListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SupercomputerListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static SupercomputerListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSupercomputerListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(SupercomputerListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (SupercomputerData 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. + SupercomputerListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SupercomputerListResult 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(SupercomputerListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSupercomputerListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SupercomputerListResult DeserializeSupercomputerListResult(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(SupercomputerData.DeserializeSupercomputerData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SupercomputerListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerListResult.cs new file mode 100644 index 000000000000..86c708a0c1dc --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Supercomputer list operation. + internal partial class SupercomputerListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Supercomputer items on this page. + internal SupercomputerListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Supercomputer items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal SupercomputerListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Supercomputer items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerProperties.Serialization.cs new file mode 100644 index 000000000000..b93b7f1b4aff --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerProperties.Serialization.cs @@ -0,0 +1,295 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Supercomputer properties. + public partial class SupercomputerProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SupercomputerProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SupercomputerProperties 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 DeserializeSupercomputerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SupercomputerProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(SupercomputerProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SupercomputerProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(SupercomputerProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + writer.WritePropertyName("subnetId"u8); + writer.WriteStringValue(SubnetId); + if (Optional.IsDefined(ManagementSubnetId)) + { + writer.WritePropertyName("managementSubnetId"u8); + writer.WriteStringValue(ManagementSubnetId); + } + if (Optional.IsDefined(OutboundType)) + { + writer.WritePropertyName("outboundType"u8); + writer.WriteStringValue(OutboundType.Value.ToString()); + } + if (Optional.IsDefined(SystemSku)) + { + writer.WritePropertyName("systemSku"u8); + writer.WriteStringValue(SystemSku.Value.ToString()); + } + writer.WritePropertyName("identities"u8); + writer.WriteObjectValue(Identities, options); + if (Optional.IsDefined(CustomerManagedKeys)) + { + writer.WritePropertyName("customerManagedKeys"u8); + writer.WriteStringValue(CustomerManagedKeys.Value.ToString()); + } + if (Optional.IsDefined(DiskEncryptionSetId)) + { + writer.WritePropertyName("diskEncryptionSetId"u8); + writer.WriteStringValue(DiskEncryptionSetId); + } + if (Optional.IsDefined(LogAnalyticsClusterId)) + { + writer.WritePropertyName("logAnalyticsClusterId"u8); + writer.WriteStringValue(LogAnalyticsClusterId); + } + if (options.Format != "W" && Optional.IsDefined(ManagedResourceGroup)) + { + writer.WritePropertyName("managedResourceGroup"u8); + writer.WriteStringValue(ManagedResourceGroup); + } + if (options.Format != "W" && Optional.IsDefined(ManagedOnBehalfOfConfiguration)) + { + writer.WritePropertyName("managedOnBehalfOfConfiguration"u8); + writer.WriteObjectValue(ManagedOnBehalfOfConfiguration, options); + } + 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. + SupercomputerProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SupercomputerProperties 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(SupercomputerProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSupercomputerProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SupercomputerProperties DeserializeSupercomputerProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + ResourceIdentifier subnetId = default; + ResourceIdentifier managementSubnetId = default; + NetworkEgressType? outboundType = default; + SystemSku? systemSku = default; + SupercomputerIdentities identities = default; + CustomerManagedKeys? customerManagedKeys = default; + ResourceIdentifier diskEncryptionSetId = default; + ResourceIdentifier logAnalyticsClusterId = default; + string managedResourceGroup = default; + WithMoboBrokerResources managedOnBehalfOfConfiguration = 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("subnetId"u8)) + { + subnetId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("managementSubnetId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managementSubnetId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("outboundType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outboundType = new NetworkEgressType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("systemSku"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemSku = new SystemSku(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("identities"u8)) + { + identities = SupercomputerIdentities.DeserializeSupercomputerIdentities(prop.Value, options); + continue; + } + if (prop.NameEquals("customerManagedKeys"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + customerManagedKeys = new CustomerManagedKeys(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("diskEncryptionSetId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diskEncryptionSetId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("logAnalyticsClusterId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logAnalyticsClusterId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("managedResourceGroup"u8)) + { + managedResourceGroup = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("managedOnBehalfOfConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managedOnBehalfOfConfiguration = WithMoboBrokerResources.DeserializeWithMoboBrokerResources(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SupercomputerProperties( + provisioningState, + subnetId, + managementSubnetId, + outboundType, + systemSku, + identities, + customerManagedKeys, + diskEncryptionSetId, + logAnalyticsClusterId, + managedResourceGroup, + managedOnBehalfOfConfiguration, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerProperties.cs new file mode 100644 index 000000000000..4e112cc43f84 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SupercomputerProperties.cs @@ -0,0 +1,128 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Supercomputer properties. + public partial class SupercomputerProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// System Subnet ID associated with managed NodePool for system resources. + /// It should have connectivity to the child NodePool subnets. + /// + /// Dictionary of identity properties. + /// or is null. + public SupercomputerProperties(ResourceIdentifier subnetId, SupercomputerIdentities identities) + { + Argument.AssertNotNull(subnetId, nameof(subnetId)); + Argument.AssertNotNull(identities, nameof(identities)); + + SubnetId = subnetId; + Identities = identities; + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// + /// System Subnet ID associated with managed NodePool for system resources. + /// It should have connectivity to the child NodePool subnets. + /// + /// + /// System Subnet ID associated with AKS apiserver. Must be delegated to Microsoft.ContainerService/managedClusters. + /// It should have connectivity to the system subnet and nodepool subnets. + /// + /// + /// Network egress type provisioned for the supercomputer workloads. + /// Defaults to LoadBalancer if not specified. + /// If None is specified, the customer is responsible for providing outbound connectivity for Supercomputer functionality. + /// + /// The SKU to use for the system node pool. + /// Dictionary of identity properties. + /// Whether or not to use a customer managed key when encrypting data at rest. + /// Disk Encryption Set ID to use for Customer Managed Keys encryption. Required if Customer Managed Keys is enabled. + /// The Log Analytics Cluster to use for debug logs. This is required when Customer Managed Keys are enabled. + /// The resource group for resources managed on behalf of customer. + /// Managed-On-Behalf-Of configuration properties. This configuration exists for the resources where a resource provider manages those resources on behalf of the resource owner. + /// Keeps track of any properties unknown to the library. + internal SupercomputerProperties(ProvisioningState? provisioningState, ResourceIdentifier subnetId, ResourceIdentifier managementSubnetId, NetworkEgressType? outboundType, SystemSku? systemSku, SupercomputerIdentities identities, CustomerManagedKeys? customerManagedKeys, ResourceIdentifier diskEncryptionSetId, ResourceIdentifier logAnalyticsClusterId, string managedResourceGroup, WithMoboBrokerResources managedOnBehalfOfConfiguration, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + SubnetId = subnetId; + ManagementSubnetId = managementSubnetId; + OutboundType = outboundType; + SystemSku = systemSku; + Identities = identities; + CustomerManagedKeys = customerManagedKeys; + DiskEncryptionSetId = diskEncryptionSetId; + LogAnalyticsClusterId = logAnalyticsClusterId; + ManagedResourceGroup = managedResourceGroup; + ManagedOnBehalfOfConfiguration = managedOnBehalfOfConfiguration; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// + /// System Subnet ID associated with managed NodePool for system resources. + /// It should have connectivity to the child NodePool subnets. + /// + public ResourceIdentifier SubnetId { get; set; } + + /// + /// System Subnet ID associated with AKS apiserver. Must be delegated to Microsoft.ContainerService/managedClusters. + /// It should have connectivity to the system subnet and nodepool subnets. + /// + public ResourceIdentifier ManagementSubnetId { get; set; } + + /// + /// Network egress type provisioned for the supercomputer workloads. + /// Defaults to LoadBalancer if not specified. + /// If None is specified, the customer is responsible for providing outbound connectivity for Supercomputer functionality. + /// + public NetworkEgressType? OutboundType { get; set; } + + /// The SKU to use for the system node pool. + public SystemSku? SystemSku { get; set; } + + /// Dictionary of identity properties. + public SupercomputerIdentities Identities { get; set; } + + /// Whether or not to use a customer managed key when encrypting data at rest. + public CustomerManagedKeys? CustomerManagedKeys { get; set; } + + /// Disk Encryption Set ID to use for Customer Managed Keys encryption. Required if Customer Managed Keys is enabled. + public ResourceIdentifier DiskEncryptionSetId { get; set; } + + /// The Log Analytics Cluster to use for debug logs. This is required when Customer Managed Keys are enabled. + public ResourceIdentifier LogAnalyticsClusterId { get; set; } + + /// The resource group for resources managed on behalf of customer. + public string ManagedResourceGroup { get; } + + /// Managed-On-Behalf-Of configuration properties. This configuration exists for the resources where a resource provider manages those resources on behalf of the resource owner. + internal WithMoboBrokerResources ManagedOnBehalfOfConfiguration { get; } + + /// Managed-On-Behalf-Of broker resources. + public IReadOnlyList ManagedOnBehalfOfMoboBrokerResources + { + get + { + return ManagedOnBehalfOfConfiguration.MoboBrokerResources; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SystemSku.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SystemSku.cs new file mode 100644 index 000000000000..03aba2f43d8d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/SystemSku.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Supported System SKU Sizes. + public readonly partial struct SystemSku : IEquatable + { + private readonly string _value; + /// Standard_D4s_v6 basic compute VM (default). + private const string StandardD4sV6Value = "Standard_D4s_v6"; + /// Standard_D4s_v5 SKU. + private const string StandardD4sV5Value = "Standard_D4s_v5"; + /// Standard_D4s_v4 SKU. + private const string StandardD4sV4Value = "Standard_D4s_v4"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public SystemSku(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Standard_D4s_v6 basic compute VM (default). + public static SystemSku StandardD4sV6 { get; } = new SystemSku(StandardD4sV6Value); + + /// Standard_D4s_v5 SKU. + public static SystemSku StandardD4sV5 { get; } = new SystemSku(StandardD4sV5Value); + + /// Standard_D4s_v4 SKU. + public static SystemSku StandardD4sV4 { get; } = new SystemSku(StandardD4sV4Value); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(SystemSku left, SystemSku 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 !=(SystemSku left, SystemSku right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator SystemSku(string value) => new SystemSku(value); + + /// Converts a string to a . + /// The value. + public static implicit operator SystemSku?(string value) => value == null ? null : new SystemSku(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SystemSku other && Equals(other); + + /// + public bool Equals(SystemSku 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolListResult.Serialization.cs new file mode 100644 index 000000000000..5a7973f4cd07 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Tool list operation. + internal partial class ToolListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ToolListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ToolListResult 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 DeserializeToolListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ToolListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ToolListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ToolListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(ToolListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (ToolData 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. + ToolListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ToolListResult 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(ToolListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ToolListResult DeserializeToolListResult(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(ToolData.DeserializeToolData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ToolListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolListResult.cs new file mode 100644 index 000000000000..b6fb4d39ba81 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Tool list operation. + internal partial class ToolListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Tool items on this page. + internal ToolListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Tool items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal ToolListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Tool items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolProperties.Serialization.cs new file mode 100644 index 000000000000..51804baac858 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolProperties.Serialization.cs @@ -0,0 +1,234 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Discovery Tool list item properties. + public partial class ToolProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ToolProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ToolProperties 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 DeserializeToolProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ToolProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ToolProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(ToolProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + if (Optional.IsCollectionDefined(EnvironmentVariables)) + { + writer.WritePropertyName("environmentVariables"u8); + writer.WriteStartObject(); + foreach (var item in EnvironmentVariables) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("definitionContent"u8); + writer.WriteStartObject(); + foreach (var item in DefinitionContent) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + 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. + ToolProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ToolProperties 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(ToolProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ToolProperties DeserializeToolProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + string version = default; + IDictionary environmentVariables = default; + IDictionary definitionContent = 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("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("environmentVariables"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()); + } + } + environmentVariables = dictionary; + continue; + } + if (prop.NameEquals("definitionContent"u8)) + { + 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, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + definitionContent = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ToolProperties(provisioningState, version, environmentVariables ?? new ChangeTrackingDictionary(), definitionContent, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolProperties.cs new file mode 100644 index 000000000000..17a62cd5ed79 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/ToolProperties.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Discovery Tool list item properties. + public partial class ToolProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The version of a resource definition. + /// The JSON content for defining a resource. + /// or is null. + public ToolProperties(string version, IDictionary definitionContent) + { + Argument.AssertNotNull(version, nameof(version)); + Argument.AssertNotNull(definitionContent, nameof(definitionContent)); + + Version = version; + EnvironmentVariables = new ChangeTrackingDictionary(); + DefinitionContent = definitionContent; + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// The version of a resource definition. + /// Environment variables to make available. + /// The JSON content for defining a resource. + /// Keeps track of any properties unknown to the library. + internal ToolProperties(ProvisioningState? provisioningState, string version, IDictionary environmentVariables, IDictionary definitionContent, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + Version = version; + EnvironmentVariables = environmentVariables; + DefinitionContent = definitionContent; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// The version of a resource definition. + public string Version { get; set; } + + /// Environment variables to make available. + public IDictionary EnvironmentVariables { get; } + + /// + /// The JSON content for defining a resource + /// To assign an object to the value of this property use . + /// To assign an already formatted json string to this property use . + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IDictionary DefinitionContent { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/UnknownStorageStore.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/UnknownStorageStore.Serialization.cs new file mode 100644 index 000000000000..40267188e7d9 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/UnknownStorageStore.Serialization.cs @@ -0,0 +1,126 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + internal partial class UnknownStorageStore : StorageStore, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownStorageStore() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected override StorageStore 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 DeserializeStorageStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageStore)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(StorageStore)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + StorageStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(StorageStore)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + StorageStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override StorageStore 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(StorageStore)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageStore(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownStorageStore DeserializeUnknownStorageStore(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageStoreType kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new StorageStoreType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownStorageStore(kind, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/UnknownStorageStore.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/UnknownStorageStore.cs new file mode 100644 index 000000000000..58126bd31e80 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/UnknownStorageStore.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Discovery.Models +{ + internal partial class UnknownStorageStore : StorageStore + { + /// Initializes a new instance of . + /// The storage store kind. + /// Keeps track of any properties unknown to the library. + internal UnknownStorageStore(StorageStoreType kind, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/VmSize.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/VmSize.cs new file mode 100644 index 000000000000..fa58235703ae --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/VmSize.cs @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Supported Azure VM Sizes. + public readonly partial struct VmSize : IEquatable + { + private readonly string _value; + /// Standard_NC24ads_A100_v4 GPU-optimized Azure VM Size. + private const string StandardNC24adsA100V4Value = "Standard_NC24ads_A100_v4"; + /// Standard_NC48ads_A100_v4 GPU-optimized Azure VM Size. + private const string StandardNC48adsA100V4Value = "Standard_NC48ads_A100_v4"; + /// Standard_NC96ads_A100_v4 GPU-optimized Azure VM Size. + private const string StandardNC96adsA100V4Value = "Standard_NC96ads_A100_v4"; + /// Standard_NC4as_T4_v3 GPU-optimized Azure VM Size. + private const string StandardNC4asT4V3Value = "Standard_NC4as_T4_v3"; + /// Standard_NC8as_T4_v3 GPU-optimized Azure VM Size. + private const string StandardNC8asT4V3Value = "Standard_NC8as_T4_v3"; + /// Standard_NC16as_T4_v3 GPU-optimized Azure VM Size. + private const string StandardNC16asT4V3Value = "Standard_NC16as_T4_v3"; + /// Standard_NC64as_T4_v3 GPU-optimized Azure VM Size. + private const string StandardNC64asT4V3Value = "Standard_NC64as_T4_v3"; + /// Standard_NV6ads_A10_v5 GPU-optimized Azure VM Size. + private const string StandardNV6adsA10V5Value = "Standard_NV6ads_A10_v5"; + /// Standard_NV12ads_A10_v5 GPU-optimized Azure VM Size. + private const string StandardNV12adsA10V5Value = "Standard_NV12ads_A10_v5"; + /// Standard_NV24ads_A10_v5 GPU-optimized Azure VM Size. + private const string StandardNV24adsA10V5Value = "Standard_NV24ads_A10_v5"; + /// Standard_NV36ads_A10_v5 GPU-optimized Azure VM Size. + private const string StandardNV36adsA10V5Value = "Standard_NV36ads_A10_v5"; + /// Standard_NV36ads_A10_v5 GPU-optimized Azure VM Size. + private const string StandardNV36admsA10V5Value = "Standard_NV36adms_A10_v5"; + /// Standard_NV36ads_A10_v5 GPU-optimized Azure VM Size. + private const string StandardNV72adsA10V5Value = "Standard_NV72ads_A10_v5"; + /// Standard_ND40rs_v2 GPU-optimized Azure VM Size. + private const string StandardND40rsV2Value = "Standard_ND40rs_v2"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public VmSize(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Standard_NC24ads_A100_v4 GPU-optimized Azure VM Size. + public static VmSize StandardNC24adsA100V4 { get; } = new VmSize(StandardNC24adsA100V4Value); + + /// Standard_NC48ads_A100_v4 GPU-optimized Azure VM Size. + public static VmSize StandardNC48adsA100V4 { get; } = new VmSize(StandardNC48adsA100V4Value); + + /// Standard_NC96ads_A100_v4 GPU-optimized Azure VM Size. + public static VmSize StandardNC96adsA100V4 { get; } = new VmSize(StandardNC96adsA100V4Value); + + /// Standard_NC4as_T4_v3 GPU-optimized Azure VM Size. + public static VmSize StandardNC4asT4V3 { get; } = new VmSize(StandardNC4asT4V3Value); + + /// Standard_NC8as_T4_v3 GPU-optimized Azure VM Size. + public static VmSize StandardNC8asT4V3 { get; } = new VmSize(StandardNC8asT4V3Value); + + /// Standard_NC16as_T4_v3 GPU-optimized Azure VM Size. + public static VmSize StandardNC16asT4V3 { get; } = new VmSize(StandardNC16asT4V3Value); + + /// Standard_NC64as_T4_v3 GPU-optimized Azure VM Size. + public static VmSize StandardNC64asT4V3 { get; } = new VmSize(StandardNC64asT4V3Value); + + /// Standard_NV6ads_A10_v5 GPU-optimized Azure VM Size. + public static VmSize StandardNV6adsA10V5 { get; } = new VmSize(StandardNV6adsA10V5Value); + + /// Standard_NV12ads_A10_v5 GPU-optimized Azure VM Size. + public static VmSize StandardNV12adsA10V5 { get; } = new VmSize(StandardNV12adsA10V5Value); + + /// Standard_NV24ads_A10_v5 GPU-optimized Azure VM Size. + public static VmSize StandardNV24adsA10V5 { get; } = new VmSize(StandardNV24adsA10V5Value); + + /// Standard_NV36ads_A10_v5 GPU-optimized Azure VM Size. + public static VmSize StandardNV36adsA10V5 { get; } = new VmSize(StandardNV36adsA10V5Value); + + /// Standard_NV36ads_A10_v5 GPU-optimized Azure VM Size. + public static VmSize StandardNV36admsA10V5 { get; } = new VmSize(StandardNV36admsA10V5Value); + + /// Standard_NV36ads_A10_v5 GPU-optimized Azure VM Size. + public static VmSize StandardNV72adsA10V5 { get; } = new VmSize(StandardNV72adsA10V5Value); + + /// Standard_ND40rs_v2 GPU-optimized Azure VM Size. + public static VmSize StandardND40rsV2 { get; } = new VmSize(StandardND40rsV2Value); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(VmSize left, VmSize 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 !=(VmSize left, VmSize right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator VmSize(string value) => new VmSize(value); + + /// Converts a string to a . + /// The value. + public static implicit operator VmSize?(string value) => value == null ? null : new VmSize(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VmSize other && Equals(other); + + /// + public bool Equals(VmSize 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WithMoboBrokerResources.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WithMoboBrokerResources.Serialization.cs new file mode 100644 index 000000000000..18f0a3fd80d6 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WithMoboBrokerResources.Serialization.cs @@ -0,0 +1,155 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// For tracking mobo resources. + internal partial class WithMoboBrokerResources : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WithMoboBrokerResources 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 DeserializeWithMoboBrokerResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WithMoboBrokerResources)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(WithMoboBrokerResources)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + WithMoboBrokerResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(WithMoboBrokerResources)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsCollectionDefined(MoboBrokerResources)) + { + writer.WritePropertyName("moboBrokerResources"u8); + writer.WriteStartArray(); + foreach (MoboBrokerResource item in MoboBrokerResources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + 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. + WithMoboBrokerResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WithMoboBrokerResources 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(WithMoboBrokerResources)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWithMoboBrokerResources(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WithMoboBrokerResources DeserializeWithMoboBrokerResources(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList moboBrokerResources = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("moboBrokerResources"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(MoboBrokerResource.DeserializeMoboBrokerResource(item, options)); + } + moboBrokerResources = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WithMoboBrokerResources(moboBrokerResources ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WithMoboBrokerResources.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WithMoboBrokerResources.cs new file mode 100644 index 000000000000..6d77175ec53f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WithMoboBrokerResources.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; +using Azure.ResourceManager.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// For tracking mobo resources. + internal partial class WithMoboBrokerResources + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal WithMoboBrokerResources() + { + MoboBrokerResources = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Managed-On-Behalf-Of broker resources. + /// Keeps track of any properties unknown to the library. + internal WithMoboBrokerResources(IReadOnlyList moboBrokerResources, IDictionary additionalBinaryDataProperties) + { + MoboBrokerResources = moboBrokerResources; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Managed-On-Behalf-Of broker resources. + public IReadOnlyList MoboBrokerResources { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceListResult.Serialization.cs new file mode 100644 index 000000000000..6840ce770ea2 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Workspace list operation. + internal partial class WorkspaceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WorkspaceListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WorkspaceListResult 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 DeserializeWorkspaceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkspaceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(WorkspaceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + WorkspaceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static WorkspaceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkspaceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(WorkspaceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (WorkspaceData 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. + WorkspaceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WorkspaceListResult 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(WorkspaceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkspaceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WorkspaceListResult DeserializeWorkspaceListResult(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(WorkspaceData.DeserializeWorkspaceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WorkspaceListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceListResult.cs new file mode 100644 index 000000000000..b156f7bef509 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a Workspace list operation. + internal partial class WorkspaceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Workspace items on this page. + internal WorkspaceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Workspace items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal WorkspaceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Workspace items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateEndpointConnectionListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateEndpointConnectionListResult.Serialization.cs new file mode 100644 index 000000000000..534ed00ec037 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateEndpointConnectionListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a WorkspacePrivateEndpointConnection list operation. + internal partial class WorkspacePrivateEndpointConnectionListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WorkspacePrivateEndpointConnectionListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WorkspacePrivateEndpointConnectionListResult 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 DeserializeWorkspacePrivateEndpointConnectionListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkspacePrivateEndpointConnectionListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(WorkspacePrivateEndpointConnectionListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + WorkspacePrivateEndpointConnectionListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static WorkspacePrivateEndpointConnectionListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkspacePrivateEndpointConnectionListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(WorkspacePrivateEndpointConnectionListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (WorkspacePrivateEndpointConnectionData 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. + WorkspacePrivateEndpointConnectionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WorkspacePrivateEndpointConnectionListResult 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(WorkspacePrivateEndpointConnectionListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkspacePrivateEndpointConnectionListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WorkspacePrivateEndpointConnectionListResult DeserializeWorkspacePrivateEndpointConnectionListResult(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(WorkspacePrivateEndpointConnectionData.DeserializeWorkspacePrivateEndpointConnectionData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WorkspacePrivateEndpointConnectionListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateEndpointConnectionListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateEndpointConnectionListResult.cs new file mode 100644 index 000000000000..49661b6c37da --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateEndpointConnectionListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a WorkspacePrivateEndpointConnection list operation. + internal partial class WorkspacePrivateEndpointConnectionListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The WorkspacePrivateEndpointConnection items on this page. + internal WorkspacePrivateEndpointConnectionListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The WorkspacePrivateEndpointConnection items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal WorkspacePrivateEndpointConnectionListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The WorkspacePrivateEndpointConnection items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateLinkResourceListResult.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateLinkResourceListResult.Serialization.cs new file mode 100644 index 000000000000..3b41f87cb2a2 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateLinkResourceListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a WorkspacePrivateLinkResource list operation. + internal partial class WorkspacePrivateLinkResourceListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WorkspacePrivateLinkResourceListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WorkspacePrivateLinkResourceListResult 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 DeserializeWorkspacePrivateLinkResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkspacePrivateLinkResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(WorkspacePrivateLinkResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + WorkspacePrivateLinkResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static WorkspacePrivateLinkResourceListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkspacePrivateLinkResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(WorkspacePrivateLinkResourceListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (WorkspacePrivateLinkResourceData 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. + WorkspacePrivateLinkResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WorkspacePrivateLinkResourceListResult 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(WorkspacePrivateLinkResourceListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkspacePrivateLinkResourceListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WorkspacePrivateLinkResourceListResult DeserializeWorkspacePrivateLinkResourceListResult(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(WorkspacePrivateLinkResourceData.DeserializeWorkspacePrivateLinkResourceData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WorkspacePrivateLinkResourceListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateLinkResourceListResult.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateLinkResourceListResult.cs new file mode 100644 index 000000000000..766d2b478920 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspacePrivateLinkResourceListResult.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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// The response of a WorkspacePrivateLinkResource list operation. + internal partial class WorkspacePrivateLinkResourceListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The WorkspacePrivateLinkResource items on this page. + internal WorkspacePrivateLinkResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The WorkspacePrivateLinkResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal WorkspacePrivateLinkResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The WorkspacePrivateLinkResource items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceProperties.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceProperties.Serialization.cs new file mode 100644 index 000000000000..4ad8776496e4 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceProperties.Serialization.cs @@ -0,0 +1,398 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Workspace properties. + public partial class WorkspaceProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WorkspaceProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WorkspaceProperties 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 DeserializeWorkspaceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkspaceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(WorkspaceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + WorkspaceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(WorkspaceProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsCollectionDefined(SupercomputerIds)) + { + writer.WritePropertyName("supercomputerIds"u8); + writer.WriteStartArray(); + foreach (ResourceIdentifier item in SupercomputerIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(WorkspaceApiUri)) + { + writer.WritePropertyName("workspaceApiUri"u8); + writer.WriteStringValue(WorkspaceApiUri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(WorkspaceUiUri)) + { + writer.WritePropertyName("workspaceUiUri"u8); + writer.WriteStringValue(WorkspaceUiUri.AbsoluteUri); + } + writer.WritePropertyName("workspaceIdentity"u8); + writer.WriteObjectValue(WorkspaceIdentity, options); + if (Optional.IsDefined(CustomerManagedKeys)) + { + writer.WritePropertyName("customerManagedKeys"u8); + writer.WriteStringValue(CustomerManagedKeys.Value.ToString()); + } + if (Optional.IsDefined(KeyVaultProperties)) + { + writer.WritePropertyName("keyVaultProperties"u8); + writer.WriteObjectValue(KeyVaultProperties, options); + } + if (Optional.IsDefined(LogAnalyticsClusterId)) + { + writer.WritePropertyName("logAnalyticsClusterId"u8); + writer.WriteStringValue(LogAnalyticsClusterId); + } + if (options.Format != "W" && Optional.IsCollectionDefined(PrivateEndpointConnections)) + { + writer.WritePropertyName("privateEndpointConnections"u8); + writer.WriteStartArray(); + foreach (DiscoveryPrivateEndpointConnection item in PrivateEndpointConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PublicNetworkAccess)) + { + writer.WritePropertyName("publicNetworkAccess"u8); + writer.WriteStringValue(PublicNetworkAccess.Value.ToString()); + } + if (Optional.IsDefined(AgentSubnetId)) + { + writer.WritePropertyName("agentSubnetId"u8); + writer.WriteStringValue(AgentSubnetId); + } + if (Optional.IsDefined(PrivateEndpointSubnetId)) + { + writer.WritePropertyName("privateEndpointSubnetId"u8); + writer.WriteStringValue(PrivateEndpointSubnetId); + } + if (Optional.IsDefined(WorkspaceSubnetId)) + { + writer.WritePropertyName("workspaceSubnetId"u8); + writer.WriteStringValue(WorkspaceSubnetId); + } + if (options.Format != "W" && Optional.IsDefined(ManagedResourceGroup)) + { + writer.WritePropertyName("managedResourceGroup"u8); + writer.WriteStringValue(ManagedResourceGroup); + } + if (options.Format != "W" && Optional.IsDefined(ManagedOnBehalfOfConfiguration)) + { + writer.WritePropertyName("managedOnBehalfOfConfiguration"u8); + writer.WriteObjectValue(ManagedOnBehalfOfConfiguration, options); + } + 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. + WorkspaceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WorkspaceProperties 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(WorkspaceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkspaceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WorkspaceProperties DeserializeWorkspaceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + IList supercomputerIds = default; + Uri workspaceApiUri = default; + Uri workspaceUiUri = default; + Identity workspaceIdentity = default; + CustomerManagedKeys? customerManagedKeys = default; + KeyVaultProperties keyVaultProperties = default; + ResourceIdentifier logAnalyticsClusterId = default; + IReadOnlyList privateEndpointConnections = default; + PublicNetworkAccess? publicNetworkAccess = default; + ResourceIdentifier agentSubnetId = default; + ResourceIdentifier privateEndpointSubnetId = default; + ResourceIdentifier workspaceSubnetId = default; + string managedResourceGroup = default; + WithMoboBrokerResources managedOnBehalfOfConfiguration = 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("supercomputerIds"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + supercomputerIds = array; + continue; + } + if (prop.NameEquals("workspaceApiUri"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + workspaceApiUri = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (prop.NameEquals("workspaceUiUri"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + workspaceUiUri = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (prop.NameEquals("workspaceIdentity"u8)) + { + workspaceIdentity = Identity.DeserializeIdentity(prop.Value, options); + continue; + } + if (prop.NameEquals("customerManagedKeys"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + customerManagedKeys = new CustomerManagedKeys(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("keyVaultProperties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keyVaultProperties = KeyVaultProperties.DeserializeKeyVaultProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("logAnalyticsClusterId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logAnalyticsClusterId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("privateEndpointConnections"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DiscoveryPrivateEndpointConnection.DeserializeDiscoveryPrivateEndpointConnection(item, options)); + } + privateEndpointConnections = array; + continue; + } + if (prop.NameEquals("publicNetworkAccess"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicNetworkAccess = new PublicNetworkAccess(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("agentSubnetId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agentSubnetId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("privateEndpointSubnetId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateEndpointSubnetId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("workspaceSubnetId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + workspaceSubnetId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("managedResourceGroup"u8)) + { + managedResourceGroup = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("managedOnBehalfOfConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managedOnBehalfOfConfiguration = WithMoboBrokerResources.DeserializeWithMoboBrokerResources(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WorkspaceProperties( + provisioningState, + supercomputerIds ?? new ChangeTrackingList(), + workspaceApiUri, + workspaceUiUri, + workspaceIdentity, + customerManagedKeys, + keyVaultProperties, + logAnalyticsClusterId, + privateEndpointConnections ?? new ChangeTrackingList(), + publicNetworkAccess, + agentSubnetId, + privateEndpointSubnetId, + workspaceSubnetId, + managedResourceGroup, + managedOnBehalfOfConfiguration, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceProperties.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceProperties.cs new file mode 100644 index 000000000000..00594fcf4548 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/Models/WorkspaceProperties.cs @@ -0,0 +1,124 @@ +// 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.Discovery; + +namespace Azure.ResourceManager.Discovery.Models +{ + /// Workspace properties. + public partial class WorkspaceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Identity IDs used for leveraging Workspace resources. + /// is null. + public WorkspaceProperties(Identity workspaceIdentity) + { + Argument.AssertNotNull(workspaceIdentity, nameof(workspaceIdentity)); + + SupercomputerIds = new ChangeTrackingList(); + WorkspaceIdentity = workspaceIdentity; + PrivateEndpointConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// List of linked SuperComputers. + /// workspace API endpoint Uri. + /// workspace User Interface Uri. + /// Identity IDs used for leveraging Workspace resources. + /// Whether or not to use a customer managed key when encrypting data at rest. + /// The key to use for encrypting data at rest when customer managed keys are enabled. + /// The Log Analytics Cluster to use for debug logs. This is required when Customer Managed Keys are enabled. + /// List of private endpoint connections. + /// Whether or not public network access is allowed for this resource. For security reasons, it is recommended to disable it whenever possible. + /// Agent Subnet ID for agent resources. + /// Private Endpoint Subnet ID for private endpoint connections. + /// Function Subnet ID for workspace resources. + /// The resource group for resources managed on behalf of customer. + /// Managed-On-Behalf-Of configuration properties. This configuration exists for the resources where a resource provider manages those resources on behalf of the resource owner. + /// Keeps track of any properties unknown to the library. + internal WorkspaceProperties(ProvisioningState? provisioningState, IList supercomputerIds, Uri workspaceApiUri, Uri workspaceUiUri, Identity workspaceIdentity, CustomerManagedKeys? customerManagedKeys, KeyVaultProperties keyVaultProperties, ResourceIdentifier logAnalyticsClusterId, IReadOnlyList privateEndpointConnections, PublicNetworkAccess? publicNetworkAccess, ResourceIdentifier agentSubnetId, ResourceIdentifier privateEndpointSubnetId, ResourceIdentifier workspaceSubnetId, string managedResourceGroup, WithMoboBrokerResources managedOnBehalfOfConfiguration, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + SupercomputerIds = supercomputerIds; + WorkspaceApiUri = workspaceApiUri; + WorkspaceUiUri = workspaceUiUri; + WorkspaceIdentity = workspaceIdentity; + CustomerManagedKeys = customerManagedKeys; + KeyVaultProperties = keyVaultProperties; + LogAnalyticsClusterId = logAnalyticsClusterId; + PrivateEndpointConnections = privateEndpointConnections; + PublicNetworkAccess = publicNetworkAccess; + AgentSubnetId = agentSubnetId; + PrivateEndpointSubnetId = privateEndpointSubnetId; + WorkspaceSubnetId = workspaceSubnetId; + ManagedResourceGroup = managedResourceGroup; + ManagedOnBehalfOfConfiguration = managedOnBehalfOfConfiguration; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + + /// List of linked SuperComputers. + public IList SupercomputerIds { get; } + + /// workspace API endpoint Uri. + public Uri WorkspaceApiUri { get; } + + /// workspace User Interface Uri. + public Uri WorkspaceUiUri { get; } + + /// Identity IDs used for leveraging Workspace resources. + public Identity WorkspaceIdentity { get; set; } + + /// Whether or not to use a customer managed key when encrypting data at rest. + public CustomerManagedKeys? CustomerManagedKeys { get; set; } + + /// The key to use for encrypting data at rest when customer managed keys are enabled. + public KeyVaultProperties KeyVaultProperties { get; set; } + + /// The Log Analytics Cluster to use for debug logs. This is required when Customer Managed Keys are enabled. + public ResourceIdentifier LogAnalyticsClusterId { get; set; } + + /// List of private endpoint connections. + public IReadOnlyList PrivateEndpointConnections { get; } + + /// Whether or not public network access is allowed for this resource. For security reasons, it is recommended to disable it whenever possible. + public PublicNetworkAccess? PublicNetworkAccess { get; set; } + + /// Agent Subnet ID for agent resources. + public ResourceIdentifier AgentSubnetId { get; set; } + + /// Private Endpoint Subnet ID for private endpoint connections. + public ResourceIdentifier PrivateEndpointSubnetId { get; set; } + + /// Function Subnet ID for workspace resources. + public ResourceIdentifier WorkspaceSubnetId { get; set; } + + /// The resource group for resources managed on behalf of customer. + public string ManagedResourceGroup { get; } + + /// Managed-On-Behalf-Of configuration properties. This configuration exists for the resources where a resource provider manages those resources on behalf of the resource owner. + internal WithMoboBrokerResources ManagedOnBehalfOfConfiguration { get; } + + /// Managed-On-Behalf-Of broker resources. + public IReadOnlyList ManagedOnBehalfOfMoboBrokerResources + { + get + { + return ManagedOnBehalfOfConfiguration.MoboBrokerResources; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolCollection.cs new file mode 100644 index 000000000000..80b31e853715 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolCollection.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.Discovery +{ + /// + /// 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 GetNodePools method from an instance of . + /// + public partial class NodePoolCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _nodePoolsClientDiagnostics; + private readonly NodePools _nodePoolsRestClient; + + /// Initializes a new instance of NodePoolCollection for mocking. + protected NodePoolCollection() + { + } + + /// 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 NodePoolCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(NodePoolResource.ResourceType, out string nodePoolApiVersion); + _nodePoolsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", NodePoolResource.ResourceType.Namespace, Diagnostics); + _nodePoolsRestClient = new NodePools(_nodePoolsClientDiagnostics, Pipeline, Endpoint, nodePoolApiVersion ?? "2026-02-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != SupercomputerResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, SupercomputerResource.ResourceType), nameof(id)); + } + } + + /// + /// Create a NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 NodePool. + /// 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 nodePoolName, NodePoolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nodePoolName, NodePoolData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new NodePoolOperationSource(Client), + _nodePoolsClientDiagnostics, + 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 NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 NodePool. + /// 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 nodePoolName, NodePoolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nodePoolName, NodePoolData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new NodePoolOperationSource(Client), + _nodePoolsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the NodePool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string nodePoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nodePoolName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(NodePoolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the NodePool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string nodePoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nodePoolName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(NodePoolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List NodePool resources by Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools. + /// + /// + /// Operation Id. + /// NodePools_ListBySupercomputer. + /// + /// + /// Default Api Version. + /// 2026-02-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 NodePoolsGetBySupercomputerAsyncCollectionResultOfT(_nodePoolsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new NodePoolResource(Client, data)); + } + + /// + /// List NodePool resources by Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools. + /// + /// + /// Operation Id. + /// NodePools_ListBySupercomputer. + /// + /// + /// Default Api Version. + /// 2026-02-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 NodePoolsGetBySupercomputerCollectionResultOfT(_nodePoolsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new NodePoolResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the NodePool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string nodePoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nodePoolName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(NodePoolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((NodePoolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the NodePool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string nodePoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nodePoolName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(NodePoolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((NodePoolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the NodePool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string nodePoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nodePoolName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(NodePoolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((NodePoolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the NodePool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string nodePoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, nodePoolName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(NodePoolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((NodePoolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new NodePoolResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolData.Serialization.cs new file mode 100644 index 000000000000..401e654b5327 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// NodePool tracked resource. + public partial class NodePoolData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal NodePoolData() + { + } + + /// 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 DeserializeNodePoolData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NodePoolData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(NodePoolData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + NodePoolData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (NodePoolData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(NodePoolData nodePoolData) + { + if (nodePoolData == null) + { + return null; + } + return RequestContent.Create(nodePoolData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static NodePoolData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNodePoolData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(NodePoolData)} 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. + NodePoolData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (NodePoolData)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(NodePoolData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNodePoolData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NodePoolData DeserializeNodePoolData(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; + NodePoolProperties 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, AzureResourceManagerDiscoveryContext.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 = NodePoolProperties.DeserializeNodePoolProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new NodePoolData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolData.cs new file mode 100644 index 000000000000..99541e4caea4 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// NodePool tracked resource. + public partial class NodePoolData : 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 NodePoolData(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 NodePoolData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, NodePoolProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public NodePoolProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolResource.Serialization.cs new file mode 100644 index 000000000000..6a03411f7571 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolResource.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.Discovery +{ + /// + public partial class NodePoolResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new NodePoolData(); + + /// 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. + NodePoolData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + NodePoolData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolResource.cs new file mode 100644 index 000000000000..78193626b638 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/NodePoolResource.cs @@ -0,0 +1,682 @@ +// 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.Discovery +{ + /// + /// A class representing a NodePool 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 GetNodePools method. + /// + public partial class NodePoolResource : ArmResource + { + private readonly ClientDiagnostics _nodePoolsClientDiagnostics; + private readonly NodePools _nodePoolsRestClient; + private readonly NodePoolData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/supercomputers/nodePools"; + + /// Initializes a new instance of NodePoolResource for mocking. + protected NodePoolResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NodePoolResource(ArmClient client, NodePoolData 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 NodePoolResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string nodePoolApiVersion); + _nodePoolsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _nodePoolsRestClient = new NodePools(_nodePoolsClientDiagnostics, Pipeline, Endpoint, nodePoolApiVersion ?? "2026-02-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 NodePoolData 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 supercomputerName. + /// The nodePoolName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string supercomputerName, string nodePoolName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}"; + 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), nameof(id)); + } + } + + /// + /// Get a NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.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(NodePoolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(NodePoolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, NodePoolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, NodePoolData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new NodePoolOperationSource(Client), + _nodePoolsClientDiagnostics, + 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 NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, NodePoolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, NodePoolData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new NodePoolOperationSource(Client), + _nodePoolsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_nodePoolsClientDiagnostics, 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 NodePool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}/nodePools/{nodePoolName}. + /// + /// + /// Operation Id. + /// NodePools_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _nodePoolsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_nodePoolsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.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 = _nodePoolsRestClient.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(NodePoolData.FromResponse(result), result); + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + NodePoolData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + NodePoolData patch = new NodePoolData(); + 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 = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.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 = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(NodePoolData.FromResponse(result), result); + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + NodePoolData current = Get(cancellationToken: cancellationToken).Value.Data; + NodePoolData patch = new NodePoolData(); + 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 = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.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 = _nodePoolsRestClient.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(NodePoolData.FromResponse(result), result); + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + NodePoolData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + NodePoolData patch = new NodePoolData(); + 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 = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.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 = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(NodePoolData.FromResponse(result), result); + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + NodePoolData current = Get(cancellationToken: cancellationToken).Value.Data; + NodePoolData patch = new NodePoolData(); + 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 = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.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 = _nodePoolsRestClient.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(NodePoolData.FromResponse(result), result); + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + NodePoolData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + NodePoolData patch = new NodePoolData(); + 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 = _nodePoolsClientDiagnostics.CreateScope("NodePoolResource.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 = _nodePoolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(NodePoolData.FromResponse(result), result); + return Response.FromValue(new NodePoolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + NodePoolData current = Get(cancellationToken: cancellationToken).Value.Data; + NodePoolData patch = new NodePoolData(); + 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; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectCollection.cs new file mode 100644 index 000000000000..de29df605836 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectCollection.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.Discovery +{ + /// + /// 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 GetProjects method from an instance of . + /// + public partial class ProjectCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _projectsClientDiagnostics; + private readonly Projects _projectsRestClient; + + /// Initializes a new instance of ProjectCollection for mocking. + protected ProjectCollection() + { + } + + /// 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 ProjectCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ProjectResource.ResourceType, out string projectApiVersion); + _projectsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ProjectResource.ResourceType.Namespace, Diagnostics); + _projectsRestClient = new Projects(_projectsClientDiagnostics, Pipeline, Endpoint, projectApiVersion ?? "2026-02-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != WorkspaceResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, WorkspaceResource.ResourceType), nameof(id)); + } + } + + /// + /// Create a Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Project. + /// 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 projectName, ProjectData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, projectName, ProjectData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ProjectOperationSource(Client), + _projectsClientDiagnostics, + 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 Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Project. + /// 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 projectName, ProjectData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, projectName, ProjectData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ProjectOperationSource(Client), + _projectsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, projectName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ProjectData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, projectName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ProjectData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Project resources by Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects. + /// + /// + /// Operation Id. + /// Projects_ListByWorkspace. + /// + /// + /// Default Api Version. + /// 2026-02-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 ProjectsGetByWorkspaceAsyncCollectionResultOfT(_projectsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new ProjectResource(Client, data)); + } + + /// + /// List Project resources by Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects. + /// + /// + /// Operation Id. + /// Projects_ListByWorkspace. + /// + /// + /// Default Api Version. + /// 2026-02-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 ProjectsGetByWorkspaceCollectionResultOfT(_projectsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new ProjectResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, projectName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ProjectData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ProjectData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, projectName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ProjectData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ProjectData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, projectName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ProjectData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ProjectData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, projectName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ProjectData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ProjectData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ProjectResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectData.Serialization.cs new file mode 100644 index 000000000000..dbd33b077192 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Project tracked resource. + public partial class ProjectData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ProjectData() + { + } + + /// 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 DeserializeProjectData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ProjectData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ProjectData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ProjectData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ProjectData projectData) + { + if (projectData == null) + { + return null; + } + return RequestContent.Create(projectData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static ProjectData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProjectData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(ProjectData)} 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. + ProjectData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ProjectData)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(ProjectData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProjectData DeserializeProjectData(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; + ProjectProperties 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, AzureResourceManagerDiscoveryContext.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 = ProjectProperties.DeserializeProjectProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProjectData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectData.cs new file mode 100644 index 000000000000..af759c781a78 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Project tracked resource. + public partial class ProjectData : 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 ProjectData(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 ProjectData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, ProjectProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public ProjectProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectResource.Serialization.cs new file mode 100644 index 000000000000..87380deaa285 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectResource.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.Discovery +{ + /// + public partial class ProjectResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ProjectData(); + + /// 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. + ProjectData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + ProjectData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectResource.cs new file mode 100644 index 000000000000..45a834fb11de --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProjectResource.cs @@ -0,0 +1,682 @@ +// 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.Discovery +{ + /// + /// A class representing a Project 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 GetProjects method. + /// + public partial class ProjectResource : ArmResource + { + private readonly ClientDiagnostics _projectsClientDiagnostics; + private readonly Projects _projectsRestClient; + private readonly ProjectData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/workspaces/projects"; + + /// Initializes a new instance of ProjectResource for mocking. + protected ProjectResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ProjectResource(ArmClient client, ProjectData 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 ProjectResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string projectApiVersion); + _projectsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _projectsRestClient = new Projects(_projectsClientDiagnostics, Pipeline, Endpoint, projectApiVersion ?? "2026-02-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 ProjectData 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 workspaceName. + /// The projectName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string projectName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}"; + 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), nameof(id)); + } + } + + /// + /// Get a Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.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(ProjectData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ProjectData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, ProjectData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, ProjectData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ProjectOperationSource(Client), + _projectsClientDiagnostics, + 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 Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, ProjectData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _projectsClientDiagnostics.CreateScope("ProjectResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, ProjectData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ProjectOperationSource(Client), + _projectsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _projectsClientDiagnostics.CreateScope("ProjectResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_projectsClientDiagnostics, 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 Project + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/projects/{projectName}. + /// + /// + /// Operation Id. + /// Projects_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _projectsClientDiagnostics.CreateScope("ProjectResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _projectsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_projectsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _projectsClientDiagnostics.CreateScope("ProjectResource.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 = _projectsRestClient.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(ProjectData.FromResponse(result), result); + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ProjectData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ProjectData patch = new ProjectData(); + 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 = _projectsClientDiagnostics.CreateScope("ProjectResource.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 = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ProjectData.FromResponse(result), result); + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ProjectData current = Get(cancellationToken: cancellationToken).Value.Data; + ProjectData patch = new ProjectData(); + 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 = _projectsClientDiagnostics.CreateScope("ProjectResource.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 = _projectsRestClient.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(ProjectData.FromResponse(result), result); + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ProjectData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ProjectData patch = new ProjectData(); + 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 = _projectsClientDiagnostics.CreateScope("ProjectResource.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 = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ProjectData.FromResponse(result), result); + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ProjectData current = Get(cancellationToken: cancellationToken).Value.Data; + ProjectData patch = new ProjectData(); + 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 = _projectsClientDiagnostics.CreateScope("ProjectResource.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 = _projectsRestClient.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(ProjectData.FromResponse(result), result); + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ProjectData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ProjectData patch = new ProjectData(); + 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 = _projectsClientDiagnostics.CreateScope("ProjectResource.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 = _projectsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ProjectData.FromResponse(result), result); + return Response.FromValue(new ProjectResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ProjectData current = Get(cancellationToken: cancellationToken).Value.Data; + ProjectData patch = new ProjectData(); + 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; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProviderConstants.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..8d1658f4d1a1 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/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.Discovery +{ + internal static partial class ProviderConstants + { + /// Gets the DefaultProviderNamespace. + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/BookshelfPrivateEndpointConnectionsRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/BookshelfPrivateEndpointConnectionsRestOperations.cs new file mode 100644 index 000000000000..ded0fc2e8e8d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/BookshelfPrivateEndpointConnectionsRestOperations.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.Discovery +{ + internal partial class BookshelfPrivateEndpointConnections + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of BookshelfPrivateEndpointConnections for mocking. + protected BookshelfPrivateEndpointConnections() + { + } + + /// Initializes a new instance of BookshelfPrivateEndpointConnections. + /// 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 BookshelfPrivateEndpointConnections(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 bookshelfName, string privateEndpointConnectionName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + if (_apiVersion != null) + { + 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, string bookshelfName, string privateEndpointConnectionName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + if (_apiVersion != null) + { + 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 CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string bookshelfName, string privateEndpointConnectionName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + if (_apiVersion != null) + { + 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 CreateGetByBookshelfRequest(Guid subscriptionId, string resourceGroupName, string bookshelfName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + uri.AppendPath("/privateEndpointConnections", false); + if (_apiVersion != null) + { + 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 CreateNextGetByBookshelfRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string bookshelfName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/BookshelfPrivateLinkResourcesRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/BookshelfPrivateLinkResourcesRestOperations.cs new file mode 100644 index 000000000000..ae3b8fb78f28 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/BookshelfPrivateLinkResourcesRestOperations.cs @@ -0,0 +1,114 @@ +// 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.Discovery +{ + internal partial class BookshelfPrivateLinkResources + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of BookshelfPrivateLinkResources for mocking. + protected BookshelfPrivateLinkResources() + { + } + + /// Initializes a new instance of BookshelfPrivateLinkResources. + /// 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 BookshelfPrivateLinkResources(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 bookshelfName, string privateLinkResourceName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + uri.AppendPath("/privateLinkResources/", false); + uri.AppendPath(privateLinkResourceName, true); + if (_apiVersion != null) + { + 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 CreateGetByBookshelfRequest(Guid subscriptionId, string resourceGroupName, string bookshelfName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + uri.AppendPath("/privateLinkResources", false); + if (_apiVersion != null) + { + 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 CreateNextGetByBookshelfRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string bookshelfName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/BookshelvesRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/BookshelvesRestOperations.cs new file mode 100644 index 000000000000..b582151bf507 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/BookshelvesRestOperations.cs @@ -0,0 +1,221 @@ +// 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.Discovery +{ + internal partial class Bookshelves + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Bookshelves for mocking. + protected Bookshelves() + { + } + + /// Initializes a new instance of Bookshelves. + /// 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 Bookshelves(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 bookshelfName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + if (_apiVersion != null) + { + 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, string bookshelfName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + if (_apiVersion != null) + { + 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 bookshelfName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + if (_apiVersion != null) + { + 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 bookshelfName, 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/Microsoft.Discovery/bookshelves/", false); + uri.AppendPath(bookshelfName, true); + if (_apiVersion != null) + { + 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/Microsoft.Discovery/bookshelves", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/Microsoft.Discovery/bookshelves", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/ChatModelDeploymentsRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/ChatModelDeploymentsRestOperations.cs new file mode 100644 index 000000000000..8840fd494545 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/ChatModelDeploymentsRestOperations.cs @@ -0,0 +1,189 @@ +// 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.Discovery +{ + internal partial class ChatModelDeployments + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ChatModelDeployments for mocking. + protected ChatModelDeployments() + { + } + + /// Initializes a new instance of ChatModelDeployments. + /// 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 ChatModelDeployments(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 workspaceName, string chatModelDeploymentName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/chatModelDeployments/", false); + uri.AppendPath(chatModelDeploymentName, true); + if (_apiVersion != null) + { + 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, string workspaceName, string chatModelDeploymentName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/chatModelDeployments/", false); + uri.AppendPath(chatModelDeploymentName, true); + if (_apiVersion != null) + { + 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 workspaceName, string chatModelDeploymentName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/chatModelDeployments/", false); + uri.AppendPath(chatModelDeploymentName, true); + if (_apiVersion != null) + { + 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 workspaceName, string chatModelDeploymentName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/chatModelDeployments/", false); + uri.AppendPath(chatModelDeploymentName, true); + if (_apiVersion != null) + { + 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 CreateGetByWorkspaceRequest(Guid subscriptionId, string resourceGroupName, string workspaceName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/chatModelDeployments", false); + if (_apiVersion != null) + { + 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 CreateNextGetByWorkspaceRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/NodePoolsRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/NodePoolsRestOperations.cs new file mode 100644 index 000000000000..a0e0573949e1 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/NodePoolsRestOperations.cs @@ -0,0 +1,189 @@ +// 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.Discovery +{ + internal partial class NodePools + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NodePools for mocking. + protected NodePools() + { + } + + /// Initializes a new instance of NodePools. + /// 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 NodePools(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 supercomputerName, string nodePoolName, 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/Microsoft.Discovery/supercomputers/", false); + uri.AppendPath(supercomputerName, true); + uri.AppendPath("/nodePools/", false); + uri.AppendPath(nodePoolName, true); + if (_apiVersion != null) + { + 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, string supercomputerName, string nodePoolName, 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/Microsoft.Discovery/supercomputers/", false); + uri.AppendPath(supercomputerName, true); + uri.AppendPath("/nodePools/", false); + uri.AppendPath(nodePoolName, true); + if (_apiVersion != null) + { + 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 supercomputerName, string nodePoolName, 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/Microsoft.Discovery/supercomputers/", false); + uri.AppendPath(supercomputerName, true); + uri.AppendPath("/nodePools/", false); + uri.AppendPath(nodePoolName, true); + if (_apiVersion != null) + { + 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 supercomputerName, string nodePoolName, 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/Microsoft.Discovery/supercomputers/", false); + uri.AppendPath(supercomputerName, true); + uri.AppendPath("/nodePools/", false); + uri.AppendPath(nodePoolName, true); + if (_apiVersion != null) + { + 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 CreateGetBySupercomputerRequest(Guid subscriptionId, string resourceGroupName, string supercomputerName, 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/Microsoft.Discovery/supercomputers/", false); + uri.AppendPath(supercomputerName, true); + uri.AppendPath("/nodePools", false); + if (_apiVersion != null) + { + 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 CreateNextGetBySupercomputerRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string supercomputerName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/ProjectsRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/ProjectsRestOperations.cs new file mode 100644 index 000000000000..c74b0a2f1534 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/ProjectsRestOperations.cs @@ -0,0 +1,189 @@ +// 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.Discovery +{ + internal partial class Projects + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Projects for mocking. + protected Projects() + { + } + + /// Initializes a new instance of Projects. + /// 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 Projects(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 workspaceName, string projectName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/projects/", false); + uri.AppendPath(projectName, true); + if (_apiVersion != null) + { + 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, string workspaceName, string projectName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/projects/", false); + uri.AppendPath(projectName, true); + if (_apiVersion != null) + { + 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 workspaceName, string projectName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/projects/", false); + uri.AppendPath(projectName, true); + if (_apiVersion != null) + { + 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 workspaceName, string projectName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/projects/", false); + uri.AppendPath(projectName, true); + if (_apiVersion != null) + { + 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 CreateGetByWorkspaceRequest(Guid subscriptionId, string resourceGroupName, string workspaceName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/projects", false); + if (_apiVersion != null) + { + 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 CreateNextGetByWorkspaceRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/StorageAssetsRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/StorageAssetsRestOperations.cs new file mode 100644 index 000000000000..e5303cf6b1e0 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/StorageAssetsRestOperations.cs @@ -0,0 +1,189 @@ +// 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.Discovery +{ + internal partial class StorageAssets + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of StorageAssets for mocking. + protected StorageAssets() + { + } + + /// Initializes a new instance of StorageAssets. + /// 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 StorageAssets(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 storageContainerName, string storageAssetName, 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/Microsoft.Discovery/storageContainers/", false); + uri.AppendPath(storageContainerName, true); + uri.AppendPath("/storageAssets/", false); + uri.AppendPath(storageAssetName, true); + if (_apiVersion != null) + { + 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, string storageContainerName, string storageAssetName, 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/Microsoft.Discovery/storageContainers/", false); + uri.AppendPath(storageContainerName, true); + uri.AppendPath("/storageAssets/", false); + uri.AppendPath(storageAssetName, true); + if (_apiVersion != null) + { + 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 storageContainerName, string storageAssetName, 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/Microsoft.Discovery/storageContainers/", false); + uri.AppendPath(storageContainerName, true); + uri.AppendPath("/storageAssets/", false); + uri.AppendPath(storageAssetName, true); + if (_apiVersion != null) + { + 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 storageContainerName, string storageAssetName, 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/Microsoft.Discovery/storageContainers/", false); + uri.AppendPath(storageContainerName, true); + uri.AppendPath("/storageAssets/", false); + uri.AppendPath(storageAssetName, true); + if (_apiVersion != null) + { + 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 CreateGetByStorageContainerRequest(Guid subscriptionId, string resourceGroupName, string storageContainerName, 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/Microsoft.Discovery/storageContainers/", false); + uri.AppendPath(storageContainerName, true); + uri.AppendPath("/storageAssets", false); + if (_apiVersion != null) + { + 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 CreateNextGetByStorageContainerRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string storageContainerName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/StorageContainersRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/StorageContainersRestOperations.cs new file mode 100644 index 000000000000..c7c2a103aeb1 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/StorageContainersRestOperations.cs @@ -0,0 +1,221 @@ +// 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.Discovery +{ + internal partial class StorageContainers + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of StorageContainers for mocking. + protected StorageContainers() + { + } + + /// Initializes a new instance of StorageContainers. + /// 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 StorageContainers(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 storageContainerName, 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/Microsoft.Discovery/storageContainers/", false); + uri.AppendPath(storageContainerName, true); + if (_apiVersion != null) + { + 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, string storageContainerName, 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/Microsoft.Discovery/storageContainers/", false); + uri.AppendPath(storageContainerName, true); + if (_apiVersion != null) + { + 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 storageContainerName, 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/Microsoft.Discovery/storageContainers/", false); + uri.AppendPath(storageContainerName, true); + if (_apiVersion != null) + { + 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 storageContainerName, 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/Microsoft.Discovery/storageContainers/", false); + uri.AppendPath(storageContainerName, true); + if (_apiVersion != null) + { + 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/Microsoft.Discovery/storageContainers", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/Microsoft.Discovery/storageContainers", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/SupercomputersRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/SupercomputersRestOperations.cs new file mode 100644 index 000000000000..3a31abe5287d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/SupercomputersRestOperations.cs @@ -0,0 +1,221 @@ +// 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.Discovery +{ + internal partial class Supercomputers + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Supercomputers for mocking. + protected Supercomputers() + { + } + + /// Initializes a new instance of Supercomputers. + /// 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 Supercomputers(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 supercomputerName, 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/Microsoft.Discovery/supercomputers/", false); + uri.AppendPath(supercomputerName, true); + if (_apiVersion != null) + { + 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, string supercomputerName, 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/Microsoft.Discovery/supercomputers/", false); + uri.AppendPath(supercomputerName, true); + if (_apiVersion != null) + { + 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 supercomputerName, 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/Microsoft.Discovery/supercomputers/", false); + uri.AppendPath(supercomputerName, true); + if (_apiVersion != null) + { + 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 supercomputerName, 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/Microsoft.Discovery/supercomputers/", false); + uri.AppendPath(supercomputerName, true); + if (_apiVersion != null) + { + 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/Microsoft.Discovery/supercomputers", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/Microsoft.Discovery/supercomputers", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/ToolsRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/ToolsRestOperations.cs new file mode 100644 index 000000000000..cc5cfdc2f206 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/ToolsRestOperations.cs @@ -0,0 +1,221 @@ +// 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.Discovery +{ + internal partial class Tools + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Tools for mocking. + protected Tools() + { + } + + /// Initializes a new instance of Tools. + /// 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 Tools(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 toolName, 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/Microsoft.Discovery/tools/", false); + uri.AppendPath(toolName, true); + if (_apiVersion != null) + { + 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, string toolName, 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/Microsoft.Discovery/tools/", false); + uri.AppendPath(toolName, true); + if (_apiVersion != null) + { + 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 toolName, 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/Microsoft.Discovery/tools/", false); + uri.AppendPath(toolName, true); + if (_apiVersion != null) + { + 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 toolName, 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/Microsoft.Discovery/tools/", false); + uri.AppendPath(toolName, true); + if (_apiVersion != null) + { + 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/Microsoft.Discovery/tools", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/Microsoft.Discovery/tools", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/WorkspacePrivateEndpointConnectionsRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/WorkspacePrivateEndpointConnectionsRestOperations.cs new file mode 100644 index 000000000000..f537f929648f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/WorkspacePrivateEndpointConnectionsRestOperations.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.Discovery +{ + internal partial class WorkspacePrivateEndpointConnections + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of WorkspacePrivateEndpointConnections for mocking. + protected WorkspacePrivateEndpointConnections() + { + } + + /// Initializes a new instance of WorkspacePrivateEndpointConnections. + /// 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 WorkspacePrivateEndpointConnections(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 workspaceName, string privateEndpointConnectionName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + if (_apiVersion != null) + { + 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, string workspaceName, string privateEndpointConnectionName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + if (_apiVersion != null) + { + 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 CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + if (_apiVersion != null) + { + 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 CreateGetByWorkspaceRequest(Guid subscriptionId, string resourceGroupName, string workspaceName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/privateEndpointConnections", false); + if (_apiVersion != null) + { + 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 CreateNextGetByWorkspaceRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/WorkspacePrivateLinkResourcesRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/WorkspacePrivateLinkResourcesRestOperations.cs new file mode 100644 index 000000000000..a033e6e2880d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/WorkspacePrivateLinkResourcesRestOperations.cs @@ -0,0 +1,114 @@ +// 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.Discovery +{ + internal partial class WorkspacePrivateLinkResources + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of WorkspacePrivateLinkResources for mocking. + protected WorkspacePrivateLinkResources() + { + } + + /// Initializes a new instance of WorkspacePrivateLinkResources. + /// 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 WorkspacePrivateLinkResources(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 workspaceName, string privateLinkResourceName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/privateLinkResources/", false); + uri.AppendPath(privateLinkResourceName, true); + if (_apiVersion != null) + { + 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 CreateGetByWorkspaceRequest(Guid subscriptionId, string resourceGroupName, string workspaceName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + uri.AppendPath("/privateLinkResources", false); + if (_apiVersion != null) + { + 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 CreateNextGetByWorkspaceRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string workspaceName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/WorkspacesRestOperations.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/WorkspacesRestOperations.cs new file mode 100644 index 000000000000..8a896d15ad8a --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/RestOperations/WorkspacesRestOperations.cs @@ -0,0 +1,221 @@ +// 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.Discovery +{ + internal partial class Workspaces + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Workspaces for mocking. + protected Workspaces() + { + } + + /// Initializes a new instance of Workspaces. + /// 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 Workspaces(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 workspaceName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + if (_apiVersion != null) + { + 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, string workspaceName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + if (_apiVersion != null) + { + 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 workspaceName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + if (_apiVersion != null) + { + 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 workspaceName, 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/Microsoft.Discovery/workspaces/", false); + uri.AppendPath(workspaceName, true); + if (_apiVersion != null) + { + 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/Microsoft.Discovery/workspaces", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/Microsoft.Discovery/workspaces", false); + if (_apiVersion != null) + { + 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(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetCollection.cs new file mode 100644 index 000000000000..966885b3245f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetCollection.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.Discovery +{ + /// + /// 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 GetStorageAssets method from an instance of . + /// + public partial class StorageAssetCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _storageAssetsClientDiagnostics; + private readonly StorageAssets _storageAssetsRestClient; + + /// Initializes a new instance of StorageAssetCollection for mocking. + protected StorageAssetCollection() + { + } + + /// 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 StorageAssetCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(StorageAssetResource.ResourceType, out string storageAssetApiVersion); + _storageAssetsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", StorageAssetResource.ResourceType.Namespace, Diagnostics); + _storageAssetsRestClient = new StorageAssets(_storageAssetsClientDiagnostics, Pipeline, Endpoint, storageAssetApiVersion ?? "2026-02-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != StorageContainerResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, StorageContainerResource.ResourceType), nameof(id)); + } + } + + /// + /// Create a StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 StorageAsset. + /// 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 storageAssetName, StorageAssetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, storageAssetName, StorageAssetData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new StorageAssetOperationSource(Client), + _storageAssetsClientDiagnostics, + 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 StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 StorageAsset. + /// 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 storageAssetName, StorageAssetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, storageAssetName, StorageAssetData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new StorageAssetOperationSource(Client), + _storageAssetsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageAsset. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string storageAssetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, storageAssetName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(StorageAssetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageAsset. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string storageAssetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, storageAssetName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageAssetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List StorageAsset resources by StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets. + /// + /// + /// Operation Id. + /// StorageAssets_ListByStorageContainer. + /// + /// + /// Default Api Version. + /// 2026-02-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 StorageAssetsGetByStorageContainerAsyncCollectionResultOfT(_storageAssetsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new StorageAssetResource(Client, data)); + } + + /// + /// List StorageAsset resources by StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets. + /// + /// + /// Operation Id. + /// StorageAssets_ListByStorageContainer. + /// + /// + /// Default Api Version. + /// 2026-02-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 StorageAssetsGetByStorageContainerCollectionResultOfT(_storageAssetsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new StorageAssetResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageAsset. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string storageAssetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, storageAssetName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(StorageAssetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((StorageAssetData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageAsset. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string storageAssetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, storageAssetName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(StorageAssetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((StorageAssetData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageAsset. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string storageAssetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, storageAssetName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(StorageAssetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((StorageAssetData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageAsset. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string storageAssetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, storageAssetName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(StorageAssetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((StorageAssetData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new StorageAssetResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetData.Serialization.cs new file mode 100644 index 000000000000..81cf21debde9 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Storage Asset tracked resource. + public partial class StorageAssetData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal StorageAssetData() + { + } + + /// 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 DeserializeStorageAssetData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageAssetData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(StorageAssetData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + StorageAssetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StorageAssetData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(StorageAssetData storageAssetData) + { + if (storageAssetData == null) + { + return null; + } + return RequestContent.Create(storageAssetData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static StorageAssetData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStorageAssetData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(StorageAssetData)} 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. + StorageAssetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StorageAssetData)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(StorageAssetData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageAssetData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StorageAssetData DeserializeStorageAssetData(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; + StorageAssetProperties 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, AzureResourceManagerDiscoveryContext.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 = StorageAssetProperties.DeserializeStorageAssetProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StorageAssetData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetData.cs new file mode 100644 index 000000000000..f1d20de0ddba --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Storage Asset tracked resource. + public partial class StorageAssetData : 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 StorageAssetData(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 StorageAssetData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, StorageAssetProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public StorageAssetProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetResource.Serialization.cs new file mode 100644 index 000000000000..a4a554b211bb --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetResource.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.Discovery +{ + /// + public partial class StorageAssetResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new StorageAssetData(); + + /// 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. + StorageAssetData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + StorageAssetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetResource.cs new file mode 100644 index 000000000000..90a4ecfaf7a4 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageAssetResource.cs @@ -0,0 +1,682 @@ +// 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.Discovery +{ + /// + /// A class representing a StorageAsset 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 GetStorageAssets method. + /// + public partial class StorageAssetResource : ArmResource + { + private readonly ClientDiagnostics _storageAssetsClientDiagnostics; + private readonly StorageAssets _storageAssetsRestClient; + private readonly StorageAssetData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/storageContainers/storageAssets"; + + /// Initializes a new instance of StorageAssetResource for mocking. + protected StorageAssetResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal StorageAssetResource(ArmClient client, StorageAssetData 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 StorageAssetResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string storageAssetApiVersion); + _storageAssetsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _storageAssetsRestClient = new StorageAssets(_storageAssetsClientDiagnostics, Pipeline, Endpoint, storageAssetApiVersion ?? "2026-02-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 StorageAssetData 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 storageContainerName. + /// The storageAssetName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string storageContainerName, string storageAssetName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}"; + 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), nameof(id)); + } + } + + /// + /// Get a StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.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(StorageAssetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageAssetData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, StorageAssetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, StorageAssetData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new StorageAssetOperationSource(Client), + _storageAssetsClientDiagnostics, + 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 StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, StorageAssetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, StorageAssetData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new StorageAssetOperationSource(Client), + _storageAssetsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_storageAssetsClientDiagnostics, 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 StorageAsset + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}/storageAssets/{storageAssetName}. + /// + /// + /// Operation Id. + /// StorageAssets_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageAssetsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_storageAssetsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.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 = _storageAssetsRestClient.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(StorageAssetData.FromResponse(result), result); + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageAssetData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + StorageAssetData patch = new StorageAssetData(); + 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 = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.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 = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageAssetData.FromResponse(result), result); + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageAssetData current = Get(cancellationToken: cancellationToken).Value.Data; + StorageAssetData patch = new StorageAssetData(); + 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 = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.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 = _storageAssetsRestClient.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(StorageAssetData.FromResponse(result), result); + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageAssetData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + StorageAssetData patch = new StorageAssetData(); + 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 = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.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 = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageAssetData.FromResponse(result), result); + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageAssetData current = Get(cancellationToken: cancellationToken).Value.Data; + StorageAssetData patch = new StorageAssetData(); + 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 = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.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 = _storageAssetsRestClient.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(StorageAssetData.FromResponse(result), result); + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageAssetData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + StorageAssetData patch = new StorageAssetData(); + 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 = _storageAssetsClientDiagnostics.CreateScope("StorageAssetResource.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 = _storageAssetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageAssetData.FromResponse(result), result); + return Response.FromValue(new StorageAssetResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageAssetData current = Get(cancellationToken: cancellationToken).Value.Data; + StorageAssetData patch = new StorageAssetData(); + 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; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerCollection.cs new file mode 100644 index 000000000000..244a21d9dc1a --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerCollection.cs @@ -0,0 +1,580 @@ +// 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; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Discovery +{ + /// + /// 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 GetStorageContainers method from an instance of . + /// + public partial class StorageContainerCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _storageContainersClientDiagnostics; + private readonly StorageContainers _storageContainersRestClient; + + /// Initializes a new instance of StorageContainerCollection for mocking. + protected StorageContainerCollection() + { + } + + /// 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 StorageContainerCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(StorageContainerResource.ResourceType, out string storageContainerApiVersion); + _storageContainersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", StorageContainerResource.ResourceType.Namespace, Diagnostics); + _storageContainersRestClient = new StorageContainers(_storageContainersClientDiagnostics, Pipeline, Endpoint, storageContainerApiVersion ?? "2026-02-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), nameof(id)); + } + } + + /// + /// Create a StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 StorageContainer. + /// 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 storageContainerName, StorageContainerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, storageContainerName, StorageContainerData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new StorageContainerOperationSource(Client), + _storageContainersClientDiagnostics, + 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 StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 StorageContainer. + /// 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 storageContainerName, StorageContainerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, storageContainerName, StorageContainerData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new StorageContainerOperationSource(Client), + _storageContainersClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, storageContainerName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, storageContainerName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List StorageContainer resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers. + /// + /// + /// Operation Id. + /// StorageContainers_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 StorageContainersGetByResourceGroupAsyncCollectionResultOfT(_storageContainersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new StorageContainerResource(Client, data)); + } + + /// + /// List StorageContainer resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers. + /// + /// + /// Operation Id. + /// StorageContainers_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 StorageContainersGetByResourceGroupCollectionResultOfT(_storageContainersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new StorageContainerResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, storageContainerName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(StorageContainerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((StorageContainerData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, storageContainerName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(StorageContainerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((StorageContainerData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, storageContainerName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(StorageContainerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((StorageContainerData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the StorageContainer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string storageContainerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageContainerName, nameof(storageContainerName)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, storageContainerName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(StorageContainerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((StorageContainerData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new StorageContainerResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerData.Serialization.cs new file mode 100644 index 000000000000..020729520716 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Storage Container tracked resource. + public partial class StorageContainerData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal StorageContainerData() + { + } + + /// 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 DeserializeStorageContainerData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageContainerData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(StorageContainerData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + StorageContainerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (StorageContainerData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(StorageContainerData storageContainerData) + { + if (storageContainerData == null) + { + return null; + } + return RequestContent.Create(storageContainerData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static StorageContainerData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStorageContainerData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(StorageContainerData)} 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. + StorageContainerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (StorageContainerData)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(StorageContainerData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageContainerData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StorageContainerData DeserializeStorageContainerData(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; + StorageContainerProperties 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, AzureResourceManagerDiscoveryContext.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 = StorageContainerProperties.DeserializeStorageContainerProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StorageContainerData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerData.cs new file mode 100644 index 000000000000..86d3170e014a --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Storage Container tracked resource. + public partial class StorageContainerData : 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 StorageContainerData(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 StorageContainerData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, StorageContainerProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public StorageContainerProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerResource.Serialization.cs new file mode 100644 index 000000000000..d5fbbc888f87 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerResource.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.Discovery +{ + /// + public partial class StorageContainerResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new StorageContainerData(); + + /// 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. + StorageContainerData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + StorageContainerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerResource.cs new file mode 100644 index 000000000000..81a8a8103d3b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/StorageContainerResource.cs @@ -0,0 +1,714 @@ +// 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.Discovery +{ + /// + /// A class representing a StorageContainer 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 GetStorageContainers method. + /// + public partial class StorageContainerResource : ArmResource + { + private readonly ClientDiagnostics _storageContainersClientDiagnostics; + private readonly StorageContainers _storageContainersRestClient; + private readonly StorageContainerData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/storageContainers"; + + /// Initializes a new instance of StorageContainerResource for mocking. + protected StorageContainerResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal StorageContainerResource(ArmClient client, StorageContainerData 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 StorageContainerResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string storageContainerApiVersion); + _storageContainersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _storageContainersRestClient = new StorageContainers(_storageContainersClientDiagnostics, Pipeline, Endpoint, storageContainerApiVersion ?? "2026-02-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 StorageContainerData 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 storageContainerName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string storageContainerName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}"; + 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), nameof(id)); + } + } + + /// + /// Get a StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, StorageContainerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, StorageContainerData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new StorageContainerOperationSource(Client), + _storageContainersClientDiagnostics, + 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 StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, StorageContainerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, StorageContainerData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new StorageContainerOperationSource(Client), + _storageContainersClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_storageContainersClientDiagnostics, 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 StorageContainer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/storageContainers/{storageContainerName}. + /// + /// + /// Operation Id. + /// StorageContainers_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _storageContainersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_storageContainersClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.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 = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageContainerData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + StorageContainerData patch = new StorageContainerData(); + 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 = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.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 = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageContainerData current = Get(cancellationToken: cancellationToken).Value.Data; + StorageContainerData patch = new StorageContainerData(); + 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 = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.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 = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageContainerData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + StorageContainerData patch = new StorageContainerData(); + 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 = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.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 = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageContainerData current = Get(cancellationToken: cancellationToken).Value.Data; + StorageContainerData patch = new StorageContainerData(); + 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 = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.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 = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageContainerData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + StorageContainerData patch = new StorageContainerData(); + 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 = _storageContainersClientDiagnostics.CreateScope("StorageContainerResource.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 = _storageContainersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(StorageContainerData.FromResponse(result), result); + return Response.FromValue(new StorageContainerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + StorageContainerData current = Get(cancellationToken: cancellationToken).Value.Data; + StorageContainerData patch = new StorageContainerData(); + 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 StorageAssets in the . + /// An object representing collection of StorageAssets and their operations over a StorageAssetResource. + public virtual StorageAssetCollection GetStorageAssets() + { + return GetCachedClient(client => new StorageAssetCollection(client, Id)); + } + + /// Get a StorageAsset. + /// The name of the StorageAsset. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetStorageAssetAsync(string storageAssetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + + return await GetStorageAssets().GetAsync(storageAssetName, cancellationToken).ConfigureAwait(false); + } + + /// Get a StorageAsset. + /// The name of the StorageAsset. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetStorageAsset(string storageAssetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageAssetName, nameof(storageAssetName)); + + return GetStorageAssets().Get(storageAssetName, cancellationToken); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerCollection.cs new file mode 100644 index 000000000000..cdddc22fe9d5 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerCollection.cs @@ -0,0 +1,580 @@ +// 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; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Discovery +{ + /// + /// 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 GetSupercomputers method from an instance of . + /// + public partial class SupercomputerCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _supercomputersClientDiagnostics; + private readonly Supercomputers _supercomputersRestClient; + + /// Initializes a new instance of SupercomputerCollection for mocking. + protected SupercomputerCollection() + { + } + + /// 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 SupercomputerCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(SupercomputerResource.ResourceType, out string supercomputerApiVersion); + _supercomputersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", SupercomputerResource.ResourceType.Namespace, Diagnostics); + _supercomputersRestClient = new Supercomputers(_supercomputersClientDiagnostics, Pipeline, Endpoint, supercomputerApiVersion ?? "2026-02-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), nameof(id)); + } + } + + /// + /// Create a Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Supercomputer. + /// 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 supercomputerName, SupercomputerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, supercomputerName, SupercomputerData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new SupercomputerOperationSource(Client), + _supercomputersClientDiagnostics, + 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 Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Supercomputer. + /// 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 supercomputerName, SupercomputerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, supercomputerName, SupercomputerData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new SupercomputerOperationSource(Client), + _supercomputersClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, supercomputerName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, supercomputerName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Supercomputer resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers. + /// + /// + /// Operation Id. + /// Supercomputers_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 SupercomputersGetByResourceGroupAsyncCollectionResultOfT(_supercomputersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new SupercomputerResource(Client, data)); + } + + /// + /// List Supercomputer resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers. + /// + /// + /// Operation Id. + /// Supercomputers_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 SupercomputersGetByResourceGroupCollectionResultOfT(_supercomputersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new SupercomputerResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, supercomputerName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SupercomputerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SupercomputerData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, supercomputerName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SupercomputerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SupercomputerData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, supercomputerName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SupercomputerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SupercomputerData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Supercomputer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string supercomputerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supercomputerName, nameof(supercomputerName)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, supercomputerName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SupercomputerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SupercomputerData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new SupercomputerResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerData.Serialization.cs new file mode 100644 index 000000000000..754f21225c7a --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Supercomputer tracked resource. + public partial class SupercomputerData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SupercomputerData() + { + } + + /// 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 DeserializeSupercomputerData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SupercomputerData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(SupercomputerData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SupercomputerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SupercomputerData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(SupercomputerData supercomputerData) + { + if (supercomputerData == null) + { + return null; + } + return RequestContent.Create(supercomputerData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static SupercomputerData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSupercomputerData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(SupercomputerData)} 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. + SupercomputerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SupercomputerData)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(SupercomputerData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSupercomputerData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SupercomputerData DeserializeSupercomputerData(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; + SupercomputerProperties 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, AzureResourceManagerDiscoveryContext.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 = SupercomputerProperties.DeserializeSupercomputerProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SupercomputerData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerData.cs new file mode 100644 index 000000000000..52c9807b7c04 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Supercomputer tracked resource. + public partial class SupercomputerData : 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 SupercomputerData(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 SupercomputerData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, SupercomputerProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public SupercomputerProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerResource.Serialization.cs new file mode 100644 index 000000000000..949cda614dba --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerResource.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.Discovery +{ + /// + public partial class SupercomputerResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new SupercomputerData(); + + /// 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. + SupercomputerData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + SupercomputerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerResource.cs new file mode 100644 index 000000000000..f95796c46cdf --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/SupercomputerResource.cs @@ -0,0 +1,714 @@ +// 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.Discovery +{ + /// + /// A class representing a Supercomputer 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 GetSupercomputers method. + /// + public partial class SupercomputerResource : ArmResource + { + private readonly ClientDiagnostics _supercomputersClientDiagnostics; + private readonly Supercomputers _supercomputersRestClient; + private readonly SupercomputerData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/supercomputers"; + + /// Initializes a new instance of SupercomputerResource for mocking. + protected SupercomputerResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal SupercomputerResource(ArmClient client, SupercomputerData 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 SupercomputerResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string supercomputerApiVersion); + _supercomputersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _supercomputersRestClient = new Supercomputers(_supercomputersClientDiagnostics, Pipeline, Endpoint, supercomputerApiVersion ?? "2026-02-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 SupercomputerData 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 supercomputerName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string supercomputerName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}"; + 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), nameof(id)); + } + } + + /// + /// Get a Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, SupercomputerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, SupercomputerData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new SupercomputerOperationSource(Client), + _supercomputersClientDiagnostics, + 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 Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, SupercomputerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, SupercomputerData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new SupercomputerOperationSource(Client), + _supercomputersClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_supercomputersClientDiagnostics, 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 Supercomputer + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/supercomputers/{supercomputerName}. + /// + /// + /// Operation Id. + /// Supercomputers_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _supercomputersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_supercomputersClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.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 = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + SupercomputerData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + SupercomputerData patch = new SupercomputerData(); + 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 = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.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 = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + SupercomputerData current = Get(cancellationToken: cancellationToken).Value.Data; + SupercomputerData patch = new SupercomputerData(); + 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 = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.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 = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + SupercomputerData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + SupercomputerData patch = new SupercomputerData(); + 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 = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.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 = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + SupercomputerData current = Get(cancellationToken: cancellationToken).Value.Data; + SupercomputerData patch = new SupercomputerData(); + 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 = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.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 = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + SupercomputerData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + SupercomputerData patch = new SupercomputerData(); + 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 = _supercomputersClientDiagnostics.CreateScope("SupercomputerResource.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 = _supercomputersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SupercomputerData.FromResponse(result), result); + return Response.FromValue(new SupercomputerResource(Client, response.Value), response.GetRawResponse()); + } + else + { + SupercomputerData current = Get(cancellationToken: cancellationToken).Value.Data; + SupercomputerData patch = new SupercomputerData(); + 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 NodePools in the . + /// An object representing collection of NodePools and their operations over a NodePoolResource. + public virtual NodePoolCollection GetNodePools() + { + return GetCachedClient(client => new NodePoolCollection(client, Id)); + } + + /// Get a NodePool. + /// The name of the NodePool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNodePoolAsync(string nodePoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + + return await GetNodePools().GetAsync(nodePoolName, cancellationToken).ConfigureAwait(false); + } + + /// Get a NodePool. + /// The name of the NodePool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNodePool(string nodePoolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nodePoolName, nameof(nodePoolName)); + + return GetNodePools().Get(nodePoolName, cancellationToken); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolCollection.cs new file mode 100644 index 000000000000..be1d4d2ba420 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolCollection.cs @@ -0,0 +1,580 @@ +// 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; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Discovery +{ + /// + /// 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 GetTools method from an instance of . + /// + public partial class ToolCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _toolsClientDiagnostics; + private readonly Tools _toolsRestClient; + + /// Initializes a new instance of ToolCollection for mocking. + protected ToolCollection() + { + } + + /// 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 ToolCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ToolResource.ResourceType, out string toolApiVersion); + _toolsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ToolResource.ResourceType.Namespace, Diagnostics); + _toolsRestClient = new Tools(_toolsClientDiagnostics, Pipeline, Endpoint, toolApiVersion ?? "2026-02-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), nameof(id)); + } + } + + /// + /// Create a Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Tool. + /// 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 toolName, ToolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, toolName, ToolData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ToolOperationSource(Client), + _toolsClientDiagnostics, + 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 Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Tool. + /// 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 toolName, ToolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, toolName, ToolData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ToolOperationSource(Client), + _toolsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, toolName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, toolName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Tool resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools. + /// + /// + /// Operation Id. + /// Tools_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 ToolsGetByResourceGroupAsyncCollectionResultOfT(_toolsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new ToolResource(Client, data)); + } + + /// + /// List Tool resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools. + /// + /// + /// Operation Id. + /// Tools_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 ToolsGetByResourceGroupCollectionResultOfT(_toolsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new ToolResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, toolName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ToolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ToolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, toolName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ToolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ToolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, toolName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ToolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ToolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Tool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string toolName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(toolName, nameof(toolName)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, toolName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ToolData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ToolData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new ToolResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolData.Serialization.cs new file mode 100644 index 000000000000..bf6a3b0e777b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Tool tracked resource. + public partial class ToolData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ToolData() + { + } + + /// 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 DeserializeToolData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(ToolData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ToolData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ToolData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ToolData toolData) + { + if (toolData == null) + { + return null; + } + return RequestContent.Create(toolData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static ToolData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(ToolData)} 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. + ToolData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ToolData)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(ToolData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ToolData DeserializeToolData(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; + ToolProperties 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, AzureResourceManagerDiscoveryContext.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 = ToolProperties.DeserializeToolProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ToolData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolData.cs new file mode 100644 index 000000000000..2372e91be518 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Tool tracked resource. + public partial class ToolData : 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 ToolData(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 ToolData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, ToolProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public ToolProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolResource.Serialization.cs new file mode 100644 index 000000000000..b15963160cd0 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolResource.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.Discovery +{ + /// + public partial class ToolResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ToolData(); + + /// 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. + ToolData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + ToolData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolResource.cs new file mode 100644 index 000000000000..4afbc854faa9 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/ToolResource.cs @@ -0,0 +1,681 @@ +// 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.Discovery +{ + /// + /// A class representing a Tool 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 GetTools method. + /// + public partial class ToolResource : ArmResource + { + private readonly ClientDiagnostics _toolsClientDiagnostics; + private readonly Tools _toolsRestClient; + private readonly ToolData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/tools"; + + /// Initializes a new instance of ToolResource for mocking. + protected ToolResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ToolResource(ArmClient client, ToolData 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 ToolResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string toolApiVersion); + _toolsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _toolsRestClient = new Tools(_toolsClientDiagnostics, Pipeline, Endpoint, toolApiVersion ?? "2026-02-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 ToolData 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 toolName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string toolName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}"; + 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), nameof(id)); + } + } + + /// + /// Get a Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, ToolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, ToolData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ToolOperationSource(Client), + _toolsClientDiagnostics, + 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 Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, ToolData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _toolsClientDiagnostics.CreateScope("ToolResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, ToolData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new ToolOperationSource(Client), + _toolsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _toolsClientDiagnostics.CreateScope("ToolResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_toolsClientDiagnostics, 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 Tool + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/tools/{toolName}. + /// + /// + /// Operation Id. + /// Tools_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _toolsClientDiagnostics.CreateScope("ToolResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _toolsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_toolsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _toolsClientDiagnostics.CreateScope("ToolResource.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 = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ToolData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ToolData patch = new ToolData(); + 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 = _toolsClientDiagnostics.CreateScope("ToolResource.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 = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ToolData current = Get(cancellationToken: cancellationToken).Value.Data; + ToolData patch = new ToolData(); + 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 = _toolsClientDiagnostics.CreateScope("ToolResource.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 = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ToolData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ToolData patch = new ToolData(); + 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 = _toolsClientDiagnostics.CreateScope("ToolResource.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 = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ToolData current = Get(cancellationToken: cancellationToken).Value.Data; + ToolData patch = new ToolData(); + 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 = _toolsClientDiagnostics.CreateScope("ToolResource.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 = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ToolData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ToolData patch = new ToolData(); + 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 = _toolsClientDiagnostics.CreateScope("ToolResource.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 = _toolsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ToolData.FromResponse(result), result); + return Response.FromValue(new ToolResource(Client, response.Value), response.GetRawResponse()); + } + else + { + ToolData current = Get(cancellationToken: cancellationToken).Value.Data; + ToolData patch = new ToolData(); + 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; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceCollection.cs new file mode 100644 index 000000000000..08f160195323 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceCollection.cs @@ -0,0 +1,580 @@ +// 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; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Discovery +{ + /// + /// 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 GetWorkspaces method from an instance of . + /// + public partial class WorkspaceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _workspacesClientDiagnostics; + private readonly Workspaces _workspacesRestClient; + + /// Initializes a new instance of WorkspaceCollection for mocking. + protected WorkspaceCollection() + { + } + + /// 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 WorkspaceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(WorkspaceResource.ResourceType, out string workspaceApiVersion); + _workspacesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", WorkspaceResource.ResourceType.Namespace, Diagnostics); + _workspacesRestClient = new Workspaces(_workspacesClientDiagnostics, Pipeline, Endpoint, workspaceApiVersion ?? "2026-02-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), nameof(id)); + } + } + + /// + /// Create a Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Workspace. + /// 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 workspaceName, WorkspaceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, workspaceName, WorkspaceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new WorkspaceOperationSource(Client), + _workspacesClientDiagnostics, + 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 Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 Workspace. + /// 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 workspaceName, WorkspaceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, workspaceName, WorkspaceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new WorkspaceOperationSource(Client), + _workspacesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, workspaceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, workspaceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Workspace resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces. + /// + /// + /// Operation Id. + /// Workspaces_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 WorkspacesGetByResourceGroupAsyncCollectionResultOfT(_workspacesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new WorkspaceResource(Client, data)); + } + + /// + /// List Workspace resources by resource group + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces. + /// + /// + /// Operation Id. + /// Workspaces_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2026-02-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 WorkspacesGetByResourceGroupCollectionResultOfT(_workspacesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new WorkspaceResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, workspaceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspaceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspaceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, workspaceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspaceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspaceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, workspaceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspaceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspaceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the Workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string workspaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(workspaceName, nameof(workspaceName)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, workspaceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspaceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspaceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new WorkspaceResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceData.Serialization.cs new file mode 100644 index 000000000000..c64833ac27bd --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceData.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Workspace tracked resource. + public partial class WorkspaceData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WorkspaceData() + { + } + + /// 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 DeserializeWorkspaceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkspaceData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(WorkspaceData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + WorkspaceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (WorkspaceData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(WorkspaceData workspaceData) + { + if (workspaceData == null) + { + return null; + } + return RequestContent.Create(workspaceData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static WorkspaceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkspaceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(WorkspaceData)} 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. + WorkspaceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (WorkspaceData)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(WorkspaceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkspaceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WorkspaceData DeserializeWorkspaceData(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; + WorkspaceProperties 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, AzureResourceManagerDiscoveryContext.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 = WorkspaceProperties.DeserializeWorkspaceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WorkspaceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceData.cs new file mode 100644 index 000000000000..a763d7a3af72 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// Workspace tracked resource. + public partial class WorkspaceData : 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 WorkspaceData(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 WorkspaceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, WorkspaceProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public WorkspaceProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionCollection.cs new file mode 100644 index 000000000000..366bf4c52931 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionCollection.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.Discovery +{ + /// + /// 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 GetWorkspacePrivateEndpointConnections method from an instance of . + /// + public partial class WorkspacePrivateEndpointConnectionCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _workspacePrivateEndpointConnectionsClientDiagnostics; + private readonly WorkspacePrivateEndpointConnections _workspacePrivateEndpointConnectionsRestClient; + + /// Initializes a new instance of WorkspacePrivateEndpointConnectionCollection for mocking. + protected WorkspacePrivateEndpointConnectionCollection() + { + } + + /// 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 WorkspacePrivateEndpointConnectionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(WorkspacePrivateEndpointConnectionResource.ResourceType, out string workspacePrivateEndpointConnectionApiVersion); + _workspacePrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", WorkspacePrivateEndpointConnectionResource.ResourceType.Namespace, Diagnostics); + _workspacePrivateEndpointConnectionsRestClient = new WorkspacePrivateEndpointConnections(_workspacePrivateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, workspacePrivateEndpointConnectionApiVersion ?? "2026-02-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != WorkspaceResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, WorkspaceResource.ResourceType), nameof(id)); + } + } + + /// + /// Approves or updates the specified private endpoint connection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 private endpoint connection associated with the Azure 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 privateEndpointConnectionName, WorkspacePrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, WorkspacePrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new WorkspacePrivateEndpointConnectionOperationSource(Client), + _workspacePrivateEndpointConnectionsClientDiagnostics, + 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; + } + } + + /// + /// Approves or updates the specified private endpoint connection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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 private endpoint connection associated with the Azure 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 privateEndpointConnectionName, WorkspacePrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, WorkspacePrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new WorkspacePrivateEndpointConnectionOperationSource(Client), + _workspacePrivateEndpointConnectionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private endpoint connection associated with the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WorkspacePrivateEndpointConnectionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private endpoint connection associated with the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WorkspacePrivateEndpointConnectionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all private endpoint connections for a workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_ListByWorkspace. + /// + /// + /// Default Api Version. + /// 2026-02-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 WorkspacePrivateEndpointConnectionsGetByWorkspaceAsyncCollectionResultOfT(_workspacePrivateEndpointConnectionsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new WorkspacePrivateEndpointConnectionResource(Client, data)); + } + + /// + /// Lists all private endpoint connections for a workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_ListByWorkspace. + /// + /// + /// Default Api Version. + /// 2026-02-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 WorkspacePrivateEndpointConnectionsGetByWorkspaceCollectionResultOfT(_workspacePrivateEndpointConnectionsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new WorkspacePrivateEndpointConnectionResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspacePrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspacePrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspacePrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspacePrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspacePrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspacePrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspacePrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspacePrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateEndpointConnectionResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionData.Serialization.cs new file mode 100644 index 000000000000..558b8c4546a1 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionData.Serialization.cs @@ -0,0 +1,194 @@ +// 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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// The Private Endpoint Connection resource for Workspace. + public partial class WorkspacePrivateEndpointConnectionData : ResourceData, IJsonModel + { + /// 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 DeserializeWorkspacePrivateEndpointConnectionData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkspacePrivateEndpointConnectionData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(WorkspacePrivateEndpointConnectionData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + WorkspacePrivateEndpointConnectionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (WorkspacePrivateEndpointConnectionData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(WorkspacePrivateEndpointConnectionData workspacePrivateEndpointConnectionData) + { + if (workspacePrivateEndpointConnectionData == null) + { + return null; + } + return RequestContent.Create(workspacePrivateEndpointConnectionData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static WorkspacePrivateEndpointConnectionData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkspacePrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(WorkspacePrivateEndpointConnectionData)} 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. + WorkspacePrivateEndpointConnectionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (WorkspacePrivateEndpointConnectionData)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(WorkspacePrivateEndpointConnectionData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkspacePrivateEndpointConnectionData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WorkspacePrivateEndpointConnectionData DeserializeWorkspacePrivateEndpointConnectionData(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(); + PrivateEndpointConnectionProperties 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, AzureResourceManagerDiscoveryContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = PrivateEndpointConnectionProperties.DeserializePrivateEndpointConnectionProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WorkspacePrivateEndpointConnectionData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionData.cs new file mode 100644 index 000000000000..9b580cf99e9f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// The Private Endpoint Connection resource for Workspace. + public partial class WorkspacePrivateEndpointConnectionData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public WorkspacePrivateEndpointConnectionData() + { + } + + /// 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 WorkspacePrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, PrivateEndpointConnectionProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public PrivateEndpointConnectionProperties Properties { get; set; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionResource.Serialization.cs new file mode 100644 index 000000000000..80a78cb088da --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionResource.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.Discovery +{ + /// + public partial class WorkspacePrivateEndpointConnectionResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new WorkspacePrivateEndpointConnectionData(); + + /// 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. + WorkspacePrivateEndpointConnectionData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + WorkspacePrivateEndpointConnectionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionResource.cs new file mode 100644 index 000000000000..35e3a979a789 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateEndpointConnectionResource.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.Discovery +{ + /// + /// A class representing a WorkspacePrivateEndpointConnection 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 GetWorkspacePrivateEndpointConnections method. + /// + public partial class WorkspacePrivateEndpointConnectionResource : ArmResource + { + private readonly ClientDiagnostics _workspacePrivateEndpointConnectionsClientDiagnostics; + private readonly WorkspacePrivateEndpointConnections _workspacePrivateEndpointConnectionsRestClient; + private readonly WorkspacePrivateEndpointConnectionData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/workspaces/privateEndpointConnections"; + + /// Initializes a new instance of WorkspacePrivateEndpointConnectionResource for mocking. + protected WorkspacePrivateEndpointConnectionResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal WorkspacePrivateEndpointConnectionResource(ArmClient client, WorkspacePrivateEndpointConnectionData 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 WorkspacePrivateEndpointConnectionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string workspacePrivateEndpointConnectionApiVersion); + _workspacePrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _workspacePrivateEndpointConnectionsRestClient = new WorkspacePrivateEndpointConnections(_workspacePrivateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, workspacePrivateEndpointConnectionApiVersion ?? "2026-02-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 WorkspacePrivateEndpointConnectionData 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 workspaceName. + /// The privateEndpointConnectionName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string privateEndpointConnectionName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"; + 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), nameof(id)); + } + } + + /// + /// Gets the specified private endpoint connection associated with the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.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(WorkspacePrivateEndpointConnectionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private endpoint connection associated with the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WorkspacePrivateEndpointConnectionData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified private endpoint connection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_workspacePrivateEndpointConnectionsClientDiagnostics, 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; + } + } + + /// + /// Deletes the specified private endpoint connection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_workspacePrivateEndpointConnectionsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a WorkspacePrivateEndpointConnection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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, WorkspacePrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, WorkspacePrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new WorkspacePrivateEndpointConnectionOperationSource(Client), + _workspacePrivateEndpointConnectionsClientDiagnostics, + 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; + } + } + + /// + /// Update a WorkspacePrivateEndpointConnection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateEndpointConnections_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2026-02-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, WorkspacePrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _workspacePrivateEndpointConnectionsClientDiagnostics.CreateScope("WorkspacePrivateEndpointConnectionResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateEndpointConnectionsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, WorkspacePrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new WorkspacePrivateEndpointConnectionOperationSource(Client), + _workspacePrivateEndpointConnectionsClientDiagnostics, + 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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResource.Serialization.cs new file mode 100644 index 000000000000..4096401af076 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResource.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.Discovery +{ + /// + public partial class WorkspacePrivateLinkResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new WorkspacePrivateLinkResourceData(); + + /// 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. + WorkspacePrivateLinkResourceData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + WorkspacePrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResource.cs new file mode 100644 index 000000000000..ecfea4b6210d --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResource.cs @@ -0,0 +1,190 @@ +// 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.Discovery +{ + /// + /// A class representing a WorkspacePrivateLinkResource 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 GetWorkspacePrivateLinkResources method. + /// + public partial class WorkspacePrivateLinkResource : ArmResource + { + private readonly ClientDiagnostics _workspacePrivateLinkResourcesClientDiagnostics; + private readonly WorkspacePrivateLinkResources _workspacePrivateLinkResourcesRestClient; + private readonly WorkspacePrivateLinkResourceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/workspaces/privateLinkResources"; + + /// Initializes a new instance of WorkspacePrivateLinkResource for mocking. + protected WorkspacePrivateLinkResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal WorkspacePrivateLinkResource(ArmClient client, WorkspacePrivateLinkResourceData 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 WorkspacePrivateLinkResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string workspacePrivateLinkResourceApiVersion); + _workspacePrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _workspacePrivateLinkResourcesRestClient = new WorkspacePrivateLinkResources(_workspacePrivateLinkResourcesClientDiagnostics, Pipeline, Endpoint, workspacePrivateLinkResourceApiVersion ?? "2026-02-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 WorkspacePrivateLinkResourceData 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 workspaceName. + /// The privateLinkResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName, string privateLinkResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}"; + 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), nameof(id)); + } + } + + /// + /// Gets the specified private link resource for the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _workspacePrivateLinkResourcesClientDiagnostics.CreateScope("WorkspacePrivateLinkResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateLinkResourcesRestClient.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(WorkspacePrivateLinkResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private link resource for the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _workspacePrivateLinkResourcesClientDiagnostics.CreateScope("WorkspacePrivateLinkResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WorkspacePrivateLinkResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResourceCollection.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResourceCollection.cs new file mode 100644 index 000000000000..7a1020c47615 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResourceCollection.cs @@ -0,0 +1,463 @@ +// 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.Discovery +{ + /// + /// 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 GetWorkspacePrivateLinkResources method from an instance of . + /// + public partial class WorkspacePrivateLinkResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _workspacePrivateLinkResourcesClientDiagnostics; + private readonly WorkspacePrivateLinkResources _workspacePrivateLinkResourcesRestClient; + + /// Initializes a new instance of WorkspacePrivateLinkResourceCollection for mocking. + protected WorkspacePrivateLinkResourceCollection() + { + } + + /// 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 WorkspacePrivateLinkResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(WorkspacePrivateLinkResource.ResourceType, out string workspacePrivateLinkResourceApiVersion); + _workspacePrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", WorkspacePrivateLinkResource.ResourceType.Namespace, Diagnostics); + _workspacePrivateLinkResourcesRestClient = new WorkspacePrivateLinkResources(_workspacePrivateLinkResourcesClientDiagnostics, Pipeline, Endpoint, workspacePrivateLinkResourceApiVersion ?? "2026-02-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != WorkspaceResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, WorkspaceResource.ResourceType), nameof(id)); + } + } + + /// + /// Gets the specified private link resource for the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure 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 privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _workspacePrivateLinkResourcesClientDiagnostics.CreateScope("WorkspacePrivateLinkResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WorkspacePrivateLinkResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified private link resource for the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _workspacePrivateLinkResourcesClientDiagnostics.CreateScope("WorkspacePrivateLinkResourceCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WorkspacePrivateLinkResourceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists all private link resources for the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_ListByWorkspace. + /// + /// + /// Default Api Version. + /// 2026-02-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 WorkspacePrivateLinkResourcesGetByWorkspaceAsyncCollectionResultOfT(_workspacePrivateLinkResourcesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new WorkspacePrivateLinkResource(Client, data)); + } + + /// + /// Lists all private link resources for the workspace. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_ListByWorkspace. + /// + /// + /// Default Api Version. + /// 2026-02-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 WorkspacePrivateLinkResourcesGetByWorkspaceCollectionResultOfT(_workspacePrivateLinkResourcesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new WorkspacePrivateLinkResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure 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 privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _workspacePrivateLinkResourcesClientDiagnostics.CreateScope("WorkspacePrivateLinkResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspacePrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspacePrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _workspacePrivateLinkResourcesClientDiagnostics.CreateScope("WorkspacePrivateLinkResourceCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspacePrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspacePrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure 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 privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _workspacePrivateLinkResourcesClientDiagnostics.CreateScope("WorkspacePrivateLinkResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspacePrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspacePrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}. + /// + /// + /// Operation Id. + /// WorkspacePrivateLinkResources_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + using DiagnosticScope scope = _workspacePrivateLinkResourcesClientDiagnostics.CreateScope("WorkspacePrivateLinkResourceCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacePrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, privateLinkResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(WorkspacePrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((WorkspacePrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new WorkspacePrivateLinkResource(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/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResourceData.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResourceData.Serialization.cs new file mode 100644 index 000000000000..915e7c98cfc1 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResourceData.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; +using System.Text.Json; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// A private link resource for Workspace. + public partial class WorkspacePrivateLinkResourceData : ResourceData, IJsonModel + { + /// 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 DeserializeWorkspacePrivateLinkResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkspacePrivateLinkResourceData)} does not support reading '{options.Format}' format."); + } + } + + /// 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, AzureResourceManagerDiscoveryContext.Default); + default: + throw new FormatException($"The model {nameof(WorkspacePrivateLinkResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + WorkspacePrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (WorkspacePrivateLinkResourceData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static WorkspacePrivateLinkResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWorkspacePrivateLinkResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// 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(WorkspacePrivateLinkResourceData)} 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. + WorkspacePrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (WorkspacePrivateLinkResourceData)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(WorkspacePrivateLinkResourceData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkspacePrivateLinkResourceData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WorkspacePrivateLinkResourceData DeserializeWorkspacePrivateLinkResourceData(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(); + DiscoveryPrivateLinkResourceProperties 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, AzureResourceManagerDiscoveryContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = DiscoveryPrivateLinkResourceProperties.DeserializeDiscoveryPrivateLinkResourceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WorkspacePrivateLinkResourceData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResourceData.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResourceData.cs new file mode 100644 index 000000000000..783e8c567045 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspacePrivateLinkResourceData.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.Discovery.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Discovery +{ + /// A private link resource for Workspace. + public partial class WorkspacePrivateLinkResourceData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal WorkspacePrivateLinkResourceData() + { + } + + /// 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 WorkspacePrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DiscoveryPrivateLinkResourceProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public DiscoveryPrivateLinkResourceProperties Properties { get; } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceResource.Serialization.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceResource.Serialization.cs new file mode 100644 index 000000000000..f53ee35b2b9f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceResource.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.Discovery +{ + /// + public partial class WorkspaceResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new WorkspaceData(); + + /// 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. + WorkspaceData 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, AzureResourceManagerDiscoveryContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + WorkspaceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDiscoveryContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceResource.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceResource.cs new file mode 100644 index 000000000000..38346d01bc7b --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Generated/WorkspaceResource.cs @@ -0,0 +1,813 @@ +// 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.Discovery +{ + /// + /// A class representing a Workspace 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 GetWorkspaces method. + /// + public partial class WorkspaceResource : ArmResource + { + private readonly ClientDiagnostics _workspacesClientDiagnostics; + private readonly Workspaces _workspacesRestClient; + private readonly WorkspaceData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Discovery/workspaces"; + + /// Initializes a new instance of WorkspaceResource for mocking. + protected WorkspaceResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal WorkspaceResource(ArmClient client, WorkspaceData 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 WorkspaceResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string workspaceApiVersion); + _workspacesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Discovery", ResourceType.Namespace, Diagnostics); + _workspacesRestClient = new Workspaces(_workspacesClientDiagnostics, Pipeline, Endpoint, workspaceApiVersion ?? "2026-02-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 WorkspaceData 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 workspaceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string workspaceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}"; + 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), nameof(id)); + } + } + + /// + /// Get a Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Get. + /// + /// + /// Default Api Version. + /// 2026-02-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, WorkspaceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, WorkspaceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new WorkspaceOperationSource(Client), + _workspacesClientDiagnostics, + 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 Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Update. + /// + /// + /// Default Api Version. + /// 2026-02-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, WorkspaceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, WorkspaceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation( + new WorkspaceOperationSource(Client), + _workspacesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_workspacesClientDiagnostics, 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 Workspace + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Discovery/workspaces/{workspaceName}. + /// + /// + /// Operation Id. + /// Workspaces_Delete. + /// + /// + /// Default Api Version. + /// 2026-02-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 = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _workspacesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DiscoveryArmOperation operation = new DiscoveryArmOperation(_workspacesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(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 = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.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 = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WorkspaceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + WorkspaceData patch = new WorkspaceData(); + 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 = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.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 = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WorkspaceData current = Get(cancellationToken: cancellationToken).Value.Data; + WorkspaceData patch = new WorkspaceData(); + 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 = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.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 = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WorkspaceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + WorkspaceData patch = new WorkspaceData(); + 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 = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.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 = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WorkspaceData current = Get(cancellationToken: cancellationToken).Value.Data; + WorkspaceData patch = new WorkspaceData(); + 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 = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.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 = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WorkspaceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + WorkspaceData patch = new WorkspaceData(); + 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 = _workspacesClientDiagnostics.CreateScope("WorkspaceResource.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 = _workspacesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(WorkspaceData.FromResponse(result), result); + return Response.FromValue(new WorkspaceResource(Client, response.Value), response.GetRawResponse()); + } + else + { + WorkspaceData current = Get(cancellationToken: cancellationToken).Value.Data; + WorkspaceData patch = new WorkspaceData(); + 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 Projects in the . + /// An object representing collection of Projects and their operations over a ProjectResource. + public virtual ProjectCollection GetProjects() + { + return GetCachedClient(client => new ProjectCollection(client, Id)); + } + + /// Get a Project. + /// The name of the Project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetProjectAsync(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + return await GetProjects().GetAsync(projectName, cancellationToken).ConfigureAwait(false); + } + + /// Get a Project. + /// The name of the Project. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetProject(string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + return GetProjects().Get(projectName, cancellationToken); + } + + /// Gets a collection of WorkspacePrivateEndpointConnections in the . + /// An object representing collection of WorkspacePrivateEndpointConnections and their operations over a WorkspacePrivateEndpointConnectionResource. + public virtual WorkspacePrivateEndpointConnectionCollection GetWorkspacePrivateEndpointConnections() + { + return GetCachedClient(client => new WorkspacePrivateEndpointConnectionCollection(client, Id)); + } + + /// Gets the specified private endpoint connection associated with the workspace. + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetWorkspacePrivateEndpointConnectionAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + return await GetWorkspacePrivateEndpointConnections().GetAsync(privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); + } + + /// Gets the specified private endpoint connection associated with the workspace. + /// The name of the private endpoint connection associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetWorkspacePrivateEndpointConnection(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + return GetWorkspacePrivateEndpointConnections().Get(privateEndpointConnectionName, cancellationToken); + } + + /// Gets a collection of ChatModelDeployments in the . + /// An object representing collection of ChatModelDeployments and their operations over a ChatModelDeploymentResource. + public virtual ChatModelDeploymentCollection GetChatModelDeployments() + { + return GetCachedClient(client => new ChatModelDeploymentCollection(client, Id)); + } + + /// Get a ChatModelDeployment. + /// The name of the ChatModelDeployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetChatModelDeploymentAsync(string chatModelDeploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + + return await GetChatModelDeployments().GetAsync(chatModelDeploymentName, cancellationToken).ConfigureAwait(false); + } + + /// Get a ChatModelDeployment. + /// The name of the ChatModelDeployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetChatModelDeployment(string chatModelDeploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(chatModelDeploymentName, nameof(chatModelDeploymentName)); + + return GetChatModelDeployments().Get(chatModelDeploymentName, cancellationToken); + } + + /// Gets a collection of WorkspacePrivateLinkResources in the . + /// An object representing collection of WorkspacePrivateLinkResources and their operations over a WorkspacePrivateLinkResource. + public virtual WorkspacePrivateLinkResourceCollection GetWorkspacePrivateLinkResources() + { + return GetCachedClient(client => new WorkspacePrivateLinkResourceCollection(client, Id)); + } + + /// Gets the specified private link resource for the workspace. + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetWorkspacePrivateLinkResourceAsync(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + return await GetWorkspacePrivateLinkResources().GetAsync(privateLinkResourceName, cancellationToken).ConfigureAwait(false); + } + + /// Gets the specified private link resource for the workspace. + /// The name of the private link associated with the Azure resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetWorkspacePrivateLinkResource(string privateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateLinkResourceName, nameof(privateLinkResourceName)); + + return GetWorkspacePrivateLinkResources().Get(privateLinkResourceName, cancellationToken); + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/src/Properties/AssemblyInfo.cs b/sdk/discovery/Azure.ResourceManager.Discovery/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..ff3b13052d80 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/src/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Discovery")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.Discovery.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/tests/Azure.ResourceManager.Discovery.Tests.csproj b/sdk/discovery/Azure.ResourceManager.Discovery/tests/Azure.ResourceManager.Discovery.Tests.csproj new file mode 100644 index 000000000000..5be559c9dcd6 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/tests/Azure.ResourceManager.Discovery.Tests.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/tests/DiscoveryManagementTestBase.cs b/sdk/discovery/Azure.ResourceManager.Discovery/tests/DiscoveryManagementTestBase.cs new file mode 100644 index 000000000000..84ab71f432f7 --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/tests/DiscoveryManagementTestBase.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Discovery.Tests +{ + public class DiscoveryManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected DiscoveryManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected DiscoveryManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/tests/DiscoveryManagementTestEnvironment.cs b/sdk/discovery/Azure.ResourceManager.Discovery/tests/DiscoveryManagementTestEnvironment.cs new file mode 100644 index 000000000000..4d7f8ef1767e --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/tests/DiscoveryManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Discovery.Tests +{ + public class DiscoveryManagementTestEnvironment : TestEnvironment + { + } +} diff --git a/sdk/discovery/Azure.ResourceManager.Discovery/tsp-location.yaml b/sdk/discovery/Azure.ResourceManager.Discovery/tsp-location.yaml new file mode 100644 index 000000000000..26a44bdb2e4f --- /dev/null +++ b/sdk/discovery/Azure.ResourceManager.Discovery/tsp-location.yaml @@ -0,0 +1,10 @@ +directory: specification/discovery/Discovery.Management +commit: 74cc90c49189a079b3cc93fde9c9ad76742f0184 +repo: Azure/azure-rest-api-specs +additionalDirectories: +- specification/discovery/Discovery.Management.Shared +- specification/discovery/Discovery.Bookshelf.Management +- specification/discovery/Discovery.Supercomputer.Management +- specification/discovery/Discovery.Workspace.Management + +emitterPackageJsonPath: eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json \ No newline at end of file diff --git a/sdk/discovery/ci.mgmt.yml b/sdk/discovery/ci.mgmt.yml new file mode 100644 index 000000000000..114f6a4cd8b6 --- /dev/null +++ b/sdk/discovery/ci.mgmt.yml @@ -0,0 +1,12 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: discovery + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.Discovery + safeName: AzureResourceManagerDiscovery