diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/Azure.ResourceManager.ContainerOrchestratorRuntime.sln b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/Azure.ResourceManager.ContainerOrchestratorRuntime.sln new file mode 100644 index 000000000000..a982d94cc93d --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/Azure.ResourceManager.ContainerOrchestratorRuntime.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.ContainerOrchestratorRuntime", "src\Azure.ResourceManager.ContainerOrchestratorRuntime.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.ContainerOrchestratorRuntime.Tests", "tests\Azure.ResourceManager.ContainerOrchestratorRuntime.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/CHANGELOG.md b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/CHANGELOG.md new file mode 100644 index 000000000000..13dd08af78ab --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/Directory.Build.props b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/README.md b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/README.md new file mode 100644 index 000000000000..9674091e3f86 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/README.md @@ -0,0 +1,86 @@ +# Azure.ResourceManager.ContainerOrchestratorRuntime client library for .NET + +Azure.ResourceManager.ContainerOrchestratorRuntime is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.ResourceManager.ContainerOrchestratorRuntime --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/README.png) diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerCollection.cs new file mode 100644 index 000000000000..0733af5a93cf --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerCollection.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Samples +{ + public partial class Sample_ConnectedClusterBgpPeerCollection + { + // BgpPeers_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_BgpPeersGet() + { + // Generated from example definition: 2024-03-01/BgpPeers_Get.json + // this example is just showing the usage of "BgpPeers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterBgpPeerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); + + // invoke the operation + string bgpPeerName = "testpeer"; + ConnectedClusterBgpPeerResource result = await collection.GetAsync(bgpPeerName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterBgpPeerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // BgpPeers_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_BgpPeersGet() + { + // Generated from example definition: 2024-03-01/BgpPeers_Get.json + // this example is just showing the usage of "BgpPeers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterBgpPeerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); + + // invoke the operation + string bgpPeerName = "testpeer"; + bool result = await collection.ExistsAsync(bgpPeerName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // BgpPeers_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_BgpPeersGet() + { + // Generated from example definition: 2024-03-01/BgpPeers_Get.json + // this example is just showing the usage of "BgpPeers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterBgpPeerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); + + // invoke the operation + string bgpPeerName = "testpeer"; + NullableResponse response = await collection.GetIfExistsAsync(bgpPeerName); + ConnectedClusterBgpPeerResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterBgpPeerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // BgpPeers_CreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_BgpPeersCreateOrUpdate() + { + // Generated from example definition: 2024-03-01/BgpPeers_CreateOrUpdate.json + // this example is just showing the usage of "BgpPeers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterBgpPeerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); + + // invoke the operation + string bgpPeerName = "testpeer"; + ConnectedClusterBgpPeerData data = new ConnectedClusterBgpPeerData() + { + Properties = new ConnectedClusterBgpPeerProperties(64500, 64501, "10.0.0.1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bgpPeerName, data); + ConnectedClusterBgpPeerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterBgpPeerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // BgpPeers_List + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_BgpPeersList() + { + // Generated from example definition: 2024-03-01/BgpPeers_List.json + // this example is just showing the usage of "BgpPeer_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterBgpPeerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); + + // invoke the operation and iterate over the result + await foreach (ConnectedClusterBgpPeerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterBgpPeerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerResource.cs new file mode 100644 index 000000000000..9e194a2f3a82 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerResource.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Samples +{ + public partial class Sample_ConnectedClusterBgpPeerResource + { + // BgpPeers_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_BgpPeersGet() + { + // Generated from example definition: 2024-03-01/BgpPeers_Get.json + // this example is just showing the usage of "BgpPeers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterBgpPeerResource created on azure + // for more information of creating ConnectedClusterBgpPeerResource, please refer to the document of ConnectedClusterBgpPeerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string bgpPeerName = "testpeer"; + ResourceIdentifier connectedClusterBgpPeerResourceId = ConnectedClusterBgpPeerResource.CreateResourceIdentifier(resourceUri, bgpPeerName); + ConnectedClusterBgpPeerResource connectedClusterBgpPeer = client.GetConnectedClusterBgpPeerResource(connectedClusterBgpPeerResourceId); + + // invoke the operation + ConnectedClusterBgpPeerResource result = await connectedClusterBgpPeer.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterBgpPeerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // BgpPeers_CreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_BgpPeersCreateOrUpdate() + { + // Generated from example definition: 2024-03-01/BgpPeers_CreateOrUpdate.json + // this example is just showing the usage of "BgpPeers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterBgpPeerResource created on azure + // for more information of creating ConnectedClusterBgpPeerResource, please refer to the document of ConnectedClusterBgpPeerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string bgpPeerName = "testpeer"; + ResourceIdentifier connectedClusterBgpPeerResourceId = ConnectedClusterBgpPeerResource.CreateResourceIdentifier(resourceUri, bgpPeerName); + ConnectedClusterBgpPeerResource connectedClusterBgpPeer = client.GetConnectedClusterBgpPeerResource(connectedClusterBgpPeerResourceId); + + // invoke the operation + ConnectedClusterBgpPeerData data = new ConnectedClusterBgpPeerData() + { + Properties = new ConnectedClusterBgpPeerProperties(64500, 64501, "10.0.0.1"), + }; + ArmOperation lro = await connectedClusterBgpPeer.UpdateAsync(WaitUntil.Completed, data); + ConnectedClusterBgpPeerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterBgpPeerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // BgpPeers_Delete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_BgpPeersDelete() + { + // Generated from example definition: 2024-03-01/BgpPeers_Delete.json + // this example is just showing the usage of "BgpPeers_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterBgpPeerResource created on azure + // for more information of creating ConnectedClusterBgpPeerResource, please refer to the document of ConnectedClusterBgpPeerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string bgpPeerName = "testpeer"; + ResourceIdentifier connectedClusterBgpPeerResourceId = ConnectedClusterBgpPeerResource.CreateResourceIdentifier(resourceUri, bgpPeerName); + ConnectedClusterBgpPeerResource connectedClusterBgpPeer = client.GetConnectedClusterBgpPeerResource(connectedClusterBgpPeerResourceId); + + // invoke the operation + await connectedClusterBgpPeer.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerCollection.cs new file mode 100644 index 000000000000..1c4e2af1d9a0 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerCollection.cs @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Samples +{ + public partial class Sample_ConnectedClusterLoadBalancerCollection + { + // LoadBalancers_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_LoadBalancersGet() + { + // Generated from example definition: 2024-03-01/LoadBalancers_Get.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterLoadBalancerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + + // invoke the operation + string loadBalancerName = "testlb"; + ConnectedClusterLoadBalancerResource result = await collection.GetAsync(loadBalancerName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterLoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // LoadBalancers_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_LoadBalancersGet() + { + // Generated from example definition: 2024-03-01/LoadBalancers_Get.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterLoadBalancerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + + // invoke the operation + string loadBalancerName = "testlb"; + bool result = await collection.ExistsAsync(loadBalancerName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // LoadBalancers_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_LoadBalancersGet() + { + // Generated from example definition: 2024-03-01/LoadBalancers_Get.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterLoadBalancerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + + // invoke the operation + string loadBalancerName = "testlb"; + NullableResponse response = await collection.GetIfExistsAsync(loadBalancerName); + ConnectedClusterLoadBalancerResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterLoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // LoadBalancers_CreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_LoadBalancersCreateOrUpdate() + { + // Generated from example definition: 2024-03-01/LoadBalancers_CreateOrUpdate.json + // this example is just showing the usage of "LoadBalancers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterLoadBalancerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + + // invoke the operation + string loadBalancerName = "testlb"; + ConnectedClusterLoadBalancerData data = new ConnectedClusterLoadBalancerData() + { + Properties = new ConnectedClusterLoadBalancerProperties(new string[] + { +"192.168.50.1/24","192.168.51.2-192.168.51.10" + }, AdvertiseMode.Arp) + { + ServiceSelector = +{ +["app"] = "frontend", +}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); + ConnectedClusterLoadBalancerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterLoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // LoadBalancers_List + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_LoadBalancersList() + { + // Generated from example definition: 2024-03-01/LoadBalancers_List.json + // this example is just showing the usage of "LoadBalancer_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterLoadBalancerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + + // invoke the operation and iterate over the result + await foreach (ConnectedClusterLoadBalancerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterLoadBalancerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerResource.cs new file mode 100644 index 000000000000..aa214027c2a9 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerResource.cs @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Samples +{ + public partial class Sample_ConnectedClusterLoadBalancerResource + { + // LoadBalancers_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_LoadBalancersGet() + { + // Generated from example definition: 2024-03-01/LoadBalancers_Get.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterLoadBalancerResource created on azure + // for more information of creating ConnectedClusterLoadBalancerResource, please refer to the document of ConnectedClusterLoadBalancerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string loadBalancerName = "testlb"; + ResourceIdentifier connectedClusterLoadBalancerResourceId = ConnectedClusterLoadBalancerResource.CreateResourceIdentifier(resourceUri, loadBalancerName); + ConnectedClusterLoadBalancerResource connectedClusterLoadBalancer = client.GetConnectedClusterLoadBalancerResource(connectedClusterLoadBalancerResourceId); + + // invoke the operation + ConnectedClusterLoadBalancerResource result = await connectedClusterLoadBalancer.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterLoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // LoadBalancers_CreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_LoadBalancersCreateOrUpdate() + { + // Generated from example definition: 2024-03-01/LoadBalancers_CreateOrUpdate.json + // this example is just showing the usage of "LoadBalancers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterLoadBalancerResource created on azure + // for more information of creating ConnectedClusterLoadBalancerResource, please refer to the document of ConnectedClusterLoadBalancerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string loadBalancerName = "testlb"; + ResourceIdentifier connectedClusterLoadBalancerResourceId = ConnectedClusterLoadBalancerResource.CreateResourceIdentifier(resourceUri, loadBalancerName); + ConnectedClusterLoadBalancerResource connectedClusterLoadBalancer = client.GetConnectedClusterLoadBalancerResource(connectedClusterLoadBalancerResourceId); + + // invoke the operation + ConnectedClusterLoadBalancerData data = new ConnectedClusterLoadBalancerData() + { + Properties = new ConnectedClusterLoadBalancerProperties(new string[] + { +"192.168.50.1/24","192.168.51.2-192.168.51.10" + }, AdvertiseMode.Arp) + { + ServiceSelector = +{ +["app"] = "frontend", +}, + }, + }; + ArmOperation lro = await connectedClusterLoadBalancer.UpdateAsync(WaitUntil.Completed, data); + ConnectedClusterLoadBalancerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterLoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // LoadBalancers_Delete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_LoadBalancersDelete() + { + // Generated from example definition: 2024-03-01/LoadBalancers_Delete.json + // this example is just showing the usage of "LoadBalancers_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterLoadBalancerResource created on azure + // for more information of creating ConnectedClusterLoadBalancerResource, please refer to the document of ConnectedClusterLoadBalancerResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string loadBalancerName = "testlb"; + ResourceIdentifier connectedClusterLoadBalancerResourceId = ConnectedClusterLoadBalancerResource.CreateResourceIdentifier(resourceUri, loadBalancerName); + ConnectedClusterLoadBalancerResource connectedClusterLoadBalancer = client.GetConnectedClusterLoadBalancerResource(connectedClusterLoadBalancerResourceId); + + // invoke the operation + await connectedClusterLoadBalancer.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceCollection.cs new file mode 100644 index 000000000000..228345822375 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceCollection.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Samples +{ + public partial class Sample_ConnectedClusterServiceCollection + { + // Services_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServicesGet() + { + // Generated from example definition: 2024-03-01/Services_Get.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterServiceResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); + + // invoke the operation + string serviceName = "storageclass"; + ConnectedClusterServiceResource result = await collection.GetAsync(serviceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Services_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ServicesGet() + { + // Generated from example definition: 2024-03-01/Services_Get.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterServiceResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); + + // invoke the operation + string serviceName = "storageclass"; + bool result = await collection.ExistsAsync(serviceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // Services_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_ServicesGet() + { + // Generated from example definition: 2024-03-01/Services_Get.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterServiceResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); + + // invoke the operation + string serviceName = "storageclass"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + ConnectedClusterServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // Services_CreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_ServicesCreateOrUpdate() + { + // Generated from example definition: 2024-03-01/Services_CreateOrUpdate.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterServiceResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); + + // invoke the operation + string serviceName = "storageclass"; + ConnectedClusterServiceData data = new ConnectedClusterServiceData() + { + Properties = new ConnectedClusterServiceProperties(), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); + ConnectedClusterServiceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Services_List + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ServicesList() + { + // Generated from example definition: 2024-03-01/Services_List.json + // this example is just showing the usage of "ServiceResource_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterServiceResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); + + // invoke the operation and iterate over the result + await foreach (ConnectedClusterServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceResource.cs new file mode 100644 index 000000000000..f17f338e508b --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceResource.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Samples +{ + public partial class Sample_ConnectedClusterServiceResource + { + // Services_Get + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ServicesGet() + { + // Generated from example definition: 2024-03-01/Services_Get.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterServiceResource created on azure + // for more information of creating ConnectedClusterServiceResource, please refer to the document of ConnectedClusterServiceResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string serviceName = "storageclass"; + ResourceIdentifier connectedClusterServiceResourceId = ConnectedClusterServiceResource.CreateResourceIdentifier(resourceUri, serviceName); + ConnectedClusterServiceResource connectedClusterService = client.GetConnectedClusterServiceResource(connectedClusterServiceResourceId); + + // invoke the operation + ConnectedClusterServiceResource result = await connectedClusterService.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Services_CreateOrUpdate + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_ServicesCreateOrUpdate() + { + // Generated from example definition: 2024-03-01/Services_CreateOrUpdate.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterServiceResource created on azure + // for more information of creating ConnectedClusterServiceResource, please refer to the document of ConnectedClusterServiceResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string serviceName = "storageclass"; + ResourceIdentifier connectedClusterServiceResourceId = ConnectedClusterServiceResource.CreateResourceIdentifier(resourceUri, serviceName); + ConnectedClusterServiceResource connectedClusterService = client.GetConnectedClusterServiceResource(connectedClusterServiceResourceId); + + // invoke the operation + ConnectedClusterServiceData data = new ConnectedClusterServiceData() + { + Properties = new ConnectedClusterServiceProperties(), + }; + ArmOperation lro = await connectedClusterService.UpdateAsync(WaitUntil.Completed, data); + ConnectedClusterServiceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // Services_Delete + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_ServicesDelete() + { + // Generated from example definition: 2024-03-01/Services_Delete.json + // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterServiceResource created on azure + // for more information of creating ConnectedClusterServiceResource, please refer to the document of ConnectedClusterServiceResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string serviceName = "storageclass"; + ResourceIdentifier connectedClusterServiceResourceId = ConnectedClusterServiceResource.CreateResourceIdentifier(resourceUri, serviceName); + ConnectedClusterServiceResource connectedClusterService = client.GetConnectedClusterServiceResource(connectedClusterServiceResourceId); + + // invoke the operation + await connectedClusterService.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassCollection.cs new file mode 100644 index 000000000000..ed2fd49c78f9 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassCollection.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Samples +{ + public partial class Sample_ConnectedClusterStorageClassCollection + { + // StorageClass_Get_0 + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_StorageClassGet0() + { + // Generated from example definition: 2024-03-01/StorageClass_Get.json + // this example is just showing the usage of "StorageClass_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterStorageClassResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); + + // invoke the operation + string storageClassName = "testrwx"; + ConnectedClusterStorageClassResource result = await collection.GetAsync(storageClassName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterStorageClassData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // StorageClass_Get_0 + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_StorageClassGet0() + { + // Generated from example definition: 2024-03-01/StorageClass_Get.json + // this example is just showing the usage of "StorageClass_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterStorageClassResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); + + // invoke the operation + string storageClassName = "testrwx"; + bool result = await collection.ExistsAsync(storageClassName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // StorageClass_Get_0 + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_StorageClassGet0() + { + // Generated from example definition: 2024-03-01/StorageClass_Get.json + // this example is just showing the usage of "StorageClass_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterStorageClassResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); + + // invoke the operation + string storageClassName = "testrwx"; + NullableResponse response = await collection.GetIfExistsAsync(storageClassName); + ConnectedClusterStorageClassResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine($"Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterStorageClassData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // StorageClass_CreateOrUpdate_0 + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_StorageClassCreateOrUpdate0() + { + // Generated from example definition: 2024-03-01/StorageClass_CreateOrUpdate.json + // this example is just showing the usage of "StorageClass_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterStorageClassResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); + + // invoke the operation + string storageClassName = "testrwx"; + ConnectedClusterStorageClassData data = new ConnectedClusterStorageClassData() + { + Properties = new ConnectedClusterStorageClassProperties(new RwxStorageClassTypeProperties("default")), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageClassName, data); + ConnectedClusterStorageClassResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterStorageClassData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // StorageClass_List_0 + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_StorageClassList0() + { + // Generated from example definition: 2024-03-01/StorageClass_List.json + // this example is just showing the usage of "StorageClassResource_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArmResource created on azure + // for more information of creating ArmResource, please refer to the document of ArmResource + + // get the collection of this ConnectedClusterStorageClassResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); + + // invoke the operation and iterate over the result + await foreach (ConnectedClusterStorageClassResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterStorageClassData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassResource.cs new file mode 100644 index 000000000000..2e2866223353 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassResource.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Samples +{ + public partial class Sample_ConnectedClusterStorageClassResource + { + // StorageClass_Get_0 + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_StorageClassGet0() + { + // Generated from example definition: 2024-03-01/StorageClass_Get.json + // this example is just showing the usage of "StorageClass_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterStorageClassResource created on azure + // for more information of creating ConnectedClusterStorageClassResource, please refer to the document of ConnectedClusterStorageClassResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string storageClassName = "testrwx"; + ResourceIdentifier connectedClusterStorageClassResourceId = ConnectedClusterStorageClassResource.CreateResourceIdentifier(resourceUri, storageClassName); + ConnectedClusterStorageClassResource connectedClusterStorageClass = client.GetConnectedClusterStorageClassResource(connectedClusterStorageClassResourceId); + + // invoke the operation + ConnectedClusterStorageClassResource result = await connectedClusterStorageClass.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterStorageClassData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // StorageClass_Update_0 + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_StorageClassUpdate0() + { + // Generated from example definition: 2024-03-01/StorageClass_Update.json + // this example is just showing the usage of "StorageClass_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterStorageClassResource created on azure + // for more information of creating ConnectedClusterStorageClassResource, please refer to the document of ConnectedClusterStorageClassResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string storageClassName = "testrwx"; + ResourceIdentifier connectedClusterStorageClassResourceId = ConnectedClusterStorageClassResource.CreateResourceIdentifier(resourceUri, storageClassName); + ConnectedClusterStorageClassResource connectedClusterStorageClass = client.GetConnectedClusterStorageClassResource(connectedClusterStorageClassResourceId); + + // invoke the operation + ConnectedClusterStorageClassPatch patch = new ConnectedClusterStorageClassPatch() + { + Properties = new StorageClassPropertiesUpdate() + { + TypeProperties = new StorageClassTypePropertiesUpdate() + { + BackingStorageClassName = "default", + }, + }, + }; + ArmOperation lro = await connectedClusterStorageClass.UpdateAsync(WaitUntil.Completed, patch); + ConnectedClusterStorageClassResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterStorageClassData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // StorageClass_Delete_0 + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_StorageClassDelete0() + { + // Generated from example definition: 2024-03-01/StorageClass_Delete.json + // this example is just showing the usage of "StorageClass_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ConnectedClusterStorageClassResource created on azure + // for more information of creating ConnectedClusterStorageClassResource, please refer to the document of ConnectedClusterStorageClassResource + string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; + string storageClassName = "testrwx"; + ResourceIdentifier connectedClusterStorageClassResourceId = ConnectedClusterStorageClassResource.CreateResourceIdentifier(resourceUri, storageClassName); + ConnectedClusterStorageClassResource connectedClusterStorageClass = client.GetConnectedClusterStorageClassResource(connectedClusterStorageClassResourceId); + + // invoke the operation + await connectedClusterStorageClass.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Azure.ResourceManager.ContainerOrchestratorRuntime.csproj b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Azure.ResourceManager.ContainerOrchestratorRuntime.csproj new file mode 100644 index 000000000000..73e9831f85f0 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Azure.ResourceManager.ContainerOrchestratorRuntime.csproj @@ -0,0 +1,10 @@ + + + This is the Azure.ResourceManager.ContainerOrchestratorRuntime client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.ResourceManager.ContainerOrchestratorRuntime for Azure Data Plane + 1.0.0-beta.1 + Azure.ResourceManager.ContainerOrchestratorRuntime + $(RequiredTargetFrameworks) + true + + diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ArmContainerOrchestratorRuntimeModelFactory.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ArmContainerOrchestratorRuntimeModelFactory.cs new file mode 100644 index 000000000000..f33ab58d1c2e --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ArmContainerOrchestratorRuntimeModelFactory.cs @@ -0,0 +1,173 @@ +// 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.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Model factory for models. + public static partial class ArmContainerOrchestratorRuntimeModelFactory + { + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ConnectedClusterServiceData ConnectedClusterServiceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ConnectedClusterServiceProperties properties = null) + { + return new ConnectedClusterServiceData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The object id of the service principal of the RP provisioned in the tenant. + /// Resource provision state. + /// A new instance for mocking. + public static ConnectedClusterServiceProperties ConnectedClusterServiceProperties(Guid? rpObjectId = null, ContainerOrchestratorProvisioningState? provisioningState = null) + { + return new ConnectedClusterServiceProperties(rpObjectId, provisioningState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ConnectedClusterBgpPeerData ConnectedClusterBgpPeerData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ConnectedClusterBgpPeerProperties properties = null) + { + return new ConnectedClusterBgpPeerData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// My ASN. + /// Peer ASN. + /// Peer Address. + /// Resource provision state. + /// A new instance for mocking. + public static ConnectedClusterBgpPeerProperties ConnectedClusterBgpPeerProperties(int myAsn = default, int peerAsn = default, string peerAddress = null, ContainerOrchestratorProvisioningState? provisioningState = null) + { + return new ConnectedClusterBgpPeerProperties(myAsn, peerAsn, peerAddress, provisioningState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ConnectedClusterLoadBalancerData ConnectedClusterLoadBalancerData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ConnectedClusterLoadBalancerProperties properties = null) + { + return new ConnectedClusterLoadBalancerData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// IP Range. + /// A dynamic label mapping to select related services. For instance, if you want to create a load balancer only for services with label "a=b", then please specify {"a": "b"} in the field. + /// Advertise Mode. + /// The list of BGP peers it should advertise to. Null or empty means to advertise to all peers. + /// Resource provision state. + /// A new instance for mocking. + public static ConnectedClusterLoadBalancerProperties ConnectedClusterLoadBalancerProperties(IEnumerable addresses = null, IDictionary serviceSelector = null, AdvertiseMode advertiseMode = default, IEnumerable bgpPeers = null, ContainerOrchestratorProvisioningState? provisioningState = null) + { + addresses ??= new List(); + serviceSelector ??= new Dictionary(); + bgpPeers ??= new List(); + + return new ConnectedClusterLoadBalancerProperties( + addresses?.ToList(), + serviceSelector, + advertiseMode, + bgpPeers?.ToList(), + provisioningState, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ConnectedClusterStorageClassData ConnectedClusterStorageClassData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ConnectedClusterStorageClassProperties properties = null) + { + return new ConnectedClusterStorageClassData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Volume can be expanded or not. + /// Additional mount options. + /// Provisioner name. + /// Binding mode of volumes: Immediate, WaitForFirstConsumer. + /// The access mode: [ReadWriteOnce, ReadWriteMany] or [ReadWriteOnce]. + /// Allow single data node failure. + /// Failover speed: NA, Slow, Fast. + /// Limitations of the storage class. + /// Performance tier. + /// Selection priority when multiple storage classes meet the criteria. 0: Highest, -1: Never use. + /// + /// Properties of the StorageClass + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Resource provision state. + /// A new instance for mocking. + public static ConnectedClusterStorageClassProperties ConnectedClusterStorageClassProperties(VolumeExpansion? allowVolumeExpansion = null, IEnumerable mountOptions = null, string provisioner = null, VolumeBindingMode? volumeBindingMode = null, IEnumerable accessModes = null, DataResilienceTier? dataResilience = null, FailoverTier? failoverSpeed = null, IEnumerable limitations = null, PerformanceTier? performance = null, long? priority = null, StorageClassTypeProperties typeProperties = null, ContainerOrchestratorProvisioningState? provisioningState = null) + { + mountOptions ??= new List(); + accessModes ??= new List(); + limitations ??= new List(); + + return new ConnectedClusterStorageClassProperties( + allowVolumeExpansion, + mountOptions?.ToList(), + provisioner, + volumeBindingMode, + accessModes?.ToList(), + dataResilience, + failoverSpeed, + limitations?.ToList(), + performance, + priority, + typeProperties, + provisioningState, + serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerCollection.cs new file mode 100644 index 000000000000..67264f01a56f --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerCollection.cs @@ -0,0 +1,483 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// 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 GetConnectedClusterBgpPeers method from an instance of . + /// + public partial class ConnectedClusterBgpPeerCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _connectedClusterBgpPeerBgpPeersClientDiagnostics; + private readonly BgpPeersRestOperations _connectedClusterBgpPeerBgpPeersRestClient; + + /// Initializes a new instance of the class for mocking. + protected ConnectedClusterBgpPeerCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal ConnectedClusterBgpPeerCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _connectedClusterBgpPeerBgpPeersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerOrchestratorRuntime", ConnectedClusterBgpPeerResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ConnectedClusterBgpPeerResource.ResourceType, out string connectedClusterBgpPeerBgpPeersApiVersion); + _connectedClusterBgpPeerBgpPeersRestClient = new BgpPeersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, connectedClusterBgpPeerBgpPeersApiVersion); + } + + /// + /// Create a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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 name of the BgpPeer. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string bgpPeerName, ConnectedClusterBgpPeerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _connectedClusterBgpPeerBgpPeersRestClient.CreateOrUpdateAsync(Id, bgpPeerName, data, cancellationToken).ConfigureAwait(false); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterBgpPeerOperationSource(Client), _connectedClusterBgpPeerBgpPeersClientDiagnostics, Pipeline, _connectedClusterBgpPeerBgpPeersRestClient.CreateCreateOrUpdateRequest(Id, bgpPeerName, data).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 BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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 name of the BgpPeer. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string bgpPeerName, ConnectedClusterBgpPeerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _connectedClusterBgpPeerBgpPeersRestClient.CreateOrUpdate(Id, bgpPeerName, data, cancellationToken); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterBgpPeerOperationSource(Client), _connectedClusterBgpPeerBgpPeersClientDiagnostics, Pipeline, _connectedClusterBgpPeerBgpPeersRestClient.CreateCreateOrUpdateRequest(Id, bgpPeerName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the BgpPeer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerCollection.Get"); + scope.Start(); + try + { + var response = await _connectedClusterBgpPeerBgpPeersRestClient.GetAsync(Id, bgpPeerName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterBgpPeerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the BgpPeer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerCollection.Get"); + scope.Start(); + try + { + var response = _connectedClusterBgpPeerBgpPeersRestClient.Get(Id, bgpPeerName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterBgpPeerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List BgpPeer resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers + /// + /// + /// Operation Id + /// BgpPeer_List + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _connectedClusterBgpPeerBgpPeersRestClient.CreateListRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _connectedClusterBgpPeerBgpPeersRestClient.CreateListNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ConnectedClusterBgpPeerResource(Client, ConnectedClusterBgpPeerData.DeserializeConnectedClusterBgpPeerData(e)), _connectedClusterBgpPeerBgpPeersClientDiagnostics, Pipeline, "ConnectedClusterBgpPeerCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List BgpPeer resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers + /// + /// + /// Operation Id + /// BgpPeer_List + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _connectedClusterBgpPeerBgpPeersRestClient.CreateListRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _connectedClusterBgpPeerBgpPeersRestClient.CreateListNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ConnectedClusterBgpPeerResource(Client, ConnectedClusterBgpPeerData.DeserializeConnectedClusterBgpPeerData(e)), _connectedClusterBgpPeerBgpPeersClientDiagnostics, Pipeline, "ConnectedClusterBgpPeerCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the BgpPeer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerCollection.Exists"); + scope.Start(); + try + { + var response = await _connectedClusterBgpPeerBgpPeersRestClient.GetAsync(Id, bgpPeerName, cancellationToken: cancellationToken).ConfigureAwait(false); + 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 + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the BgpPeer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerCollection.Exists"); + scope.Start(); + try + { + var response = _connectedClusterBgpPeerBgpPeersRestClient.Get(Id, bgpPeerName, cancellationToken: cancellationToken); + 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 + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the BgpPeer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _connectedClusterBgpPeerBgpPeersRestClient.GetAsync(Id, bgpPeerName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterBgpPeerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the BgpPeer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerCollection.GetIfExists"); + scope.Start(); + try + { + var response = _connectedClusterBgpPeerBgpPeersRestClient.Get(Id, bgpPeerName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterBgpPeerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerData.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerData.Serialization.cs new file mode 100644 index 000000000000..31d9f261812b --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerData.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.Core; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + public partial class ConnectedClusterBgpPeerData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterBgpPeerData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + ConnectedClusterBgpPeerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterBgpPeerData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedClusterBgpPeerData(document.RootElement, options); + } + + internal static ConnectedClusterBgpPeerData DeserializeConnectedClusterBgpPeerData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ConnectedClusterBgpPeerProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ConnectedClusterBgpPeerProperties.DeserializeConnectedClusterBgpPeerProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedClusterBgpPeerData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedClusterBgpPeerData)} does not support writing '{options.Format}' format."); + } + } + + ConnectedClusterBgpPeerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeConnectedClusterBgpPeerData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedClusterBgpPeerData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerData.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerData.cs new file mode 100644 index 000000000000..e8ec52c25c3a --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerData.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; +using Azure.Core; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// A class representing the ConnectedClusterBgpPeer data model. + /// A BgpPeer resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + /// + public partial class ConnectedClusterBgpPeerData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ConnectedClusterBgpPeerData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal ConnectedClusterBgpPeerData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ConnectedClusterBgpPeerProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public ConnectedClusterBgpPeerProperties Properties { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerResource.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerResource.Serialization.cs new file mode 100644 index 000000000000..c9b1f1e68a34 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.ContainerOrchestratorRuntime +{ + public partial class ConnectedClusterBgpPeerResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + ConnectedClusterBgpPeerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + ConnectedClusterBgpPeerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerResource.cs new file mode 100644 index 000000000000..39df17ebc2f4 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterBgpPeerResource.cs @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// A Class representing a ConnectedClusterBgpPeer 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 GetConnectedClusterBgpPeerResource method. + /// Otherwise you can get one from its parent resource using the GetConnectedClusterBgpPeer method. + /// + public partial class ConnectedClusterBgpPeerResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The resourceUri. + /// The bgpPeerName. + public static ResourceIdentifier CreateResourceIdentifier(string resourceUri, string bgpPeerName) + { + var resourceId = $"{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _connectedClusterBgpPeerBgpPeersClientDiagnostics; + private readonly BgpPeersRestOperations _connectedClusterBgpPeerBgpPeersRestClient; + private readonly ConnectedClusterBgpPeerData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.KubernetesRuntime/bgpPeers"; + + /// Initializes a new instance of the class for mocking. + protected ConnectedClusterBgpPeerResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ConnectedClusterBgpPeerResource(ArmClient client, ConnectedClusterBgpPeerData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ConnectedClusterBgpPeerResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _connectedClusterBgpPeerBgpPeersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerOrchestratorRuntime", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string connectedClusterBgpPeerBgpPeersApiVersion); + _connectedClusterBgpPeerBgpPeersRestClient = new BgpPeersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, connectedClusterBgpPeerBgpPeersApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual ConnectedClusterBgpPeerData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerResource.Get"); + scope.Start(); + try + { + var response = await _connectedClusterBgpPeerBgpPeersRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterBgpPeerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerResource.Get"); + scope.Start(); + try + { + var response = _connectedClusterBgpPeerBgpPeersRestClient.Get(Id.Parent, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterBgpPeerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Delete + /// + /// + /// Default Api Version + /// 2024-03-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 var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerResource.Delete"); + scope.Start(); + try + { + var response = await _connectedClusterBgpPeerBgpPeersRestClient.DeleteAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _connectedClusterBgpPeerBgpPeersRestClient.CreateDeleteRequestUri(Id.Parent, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Delete + /// + /// + /// Default Api Version + /// 2024-03-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 var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerResource.Delete"); + scope.Start(); + try + { + var response = _connectedClusterBgpPeerBgpPeersRestClient.Delete(Id.Parent, Id.Name, cancellationToken); + var uri = _connectedClusterBgpPeerBgpPeersRestClient.CreateDeleteRequestUri(Id.Parent, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ConnectedClusterBgpPeerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerResource.Update"); + scope.Start(); + try + { + var response = await _connectedClusterBgpPeerBgpPeersRestClient.CreateOrUpdateAsync(Id.Parent, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterBgpPeerOperationSource(Client), _connectedClusterBgpPeerBgpPeersClientDiagnostics, Pipeline, _connectedClusterBgpPeerBgpPeersRestClient.CreateCreateOrUpdateRequest(Id.Parent, Id.Name, data).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 BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ConnectedClusterBgpPeerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterBgpPeerBgpPeersClientDiagnostics.CreateScope("ConnectedClusterBgpPeerResource.Update"); + scope.Start(); + try + { + var response = _connectedClusterBgpPeerBgpPeersRestClient.CreateOrUpdate(Id.Parent, Id.Name, data, cancellationToken); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterBgpPeerOperationSource(Client), _connectedClusterBgpPeerBgpPeersClientDiagnostics, Pipeline, _connectedClusterBgpPeerBgpPeersRestClient.CreateCreateOrUpdateRequest(Id.Parent, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerCollection.cs new file mode 100644 index 000000000000..a724f2f76bd1 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerCollection.cs @@ -0,0 +1,483 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// 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 GetConnectedClusterLoadBalancers method from an instance of . + /// + public partial class ConnectedClusterLoadBalancerCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _connectedClusterLoadBalancerLoadBalancersClientDiagnostics; + private readonly LoadBalancersRestOperations _connectedClusterLoadBalancerLoadBalancersRestClient; + + /// Initializes a new instance of the class for mocking. + protected ConnectedClusterLoadBalancerCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal ConnectedClusterLoadBalancerCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _connectedClusterLoadBalancerLoadBalancersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerOrchestratorRuntime", ConnectedClusterLoadBalancerResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ConnectedClusterLoadBalancerResource.ResourceType, out string connectedClusterLoadBalancerLoadBalancersApiVersion); + _connectedClusterLoadBalancerLoadBalancersRestClient = new LoadBalancersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, connectedClusterLoadBalancerLoadBalancersApiVersion); + } + + /// + /// Create a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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 name of the LoadBalancer. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string loadBalancerName, ConnectedClusterLoadBalancerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _connectedClusterLoadBalancerLoadBalancersRestClient.CreateOrUpdateAsync(Id, loadBalancerName, data, cancellationToken).ConfigureAwait(false); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterLoadBalancerOperationSource(Client), _connectedClusterLoadBalancerLoadBalancersClientDiagnostics, Pipeline, _connectedClusterLoadBalancerLoadBalancersRestClient.CreateCreateOrUpdateRequest(Id, loadBalancerName, data).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 LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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 name of the LoadBalancer. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string loadBalancerName, ConnectedClusterLoadBalancerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _connectedClusterLoadBalancerLoadBalancersRestClient.CreateOrUpdate(Id, loadBalancerName, data, cancellationToken); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterLoadBalancerOperationSource(Client), _connectedClusterLoadBalancerLoadBalancersClientDiagnostics, Pipeline, _connectedClusterLoadBalancerLoadBalancersRestClient.CreateCreateOrUpdateRequest(Id, loadBalancerName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerCollection.Get"); + scope.Start(); + try + { + var response = await _connectedClusterLoadBalancerLoadBalancersRestClient.GetAsync(Id, loadBalancerName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterLoadBalancerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerCollection.Get"); + scope.Start(); + try + { + var response = _connectedClusterLoadBalancerLoadBalancersRestClient.Get(Id, loadBalancerName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterLoadBalancerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List LoadBalancer resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers + /// + /// + /// Operation Id + /// LoadBalancer_List + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _connectedClusterLoadBalancerLoadBalancersRestClient.CreateListRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _connectedClusterLoadBalancerLoadBalancersRestClient.CreateListNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ConnectedClusterLoadBalancerResource(Client, ConnectedClusterLoadBalancerData.DeserializeConnectedClusterLoadBalancerData(e)), _connectedClusterLoadBalancerLoadBalancersClientDiagnostics, Pipeline, "ConnectedClusterLoadBalancerCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List LoadBalancer resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers + /// + /// + /// Operation Id + /// LoadBalancer_List + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _connectedClusterLoadBalancerLoadBalancersRestClient.CreateListRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _connectedClusterLoadBalancerLoadBalancersRestClient.CreateListNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ConnectedClusterLoadBalancerResource(Client, ConnectedClusterLoadBalancerData.DeserializeConnectedClusterLoadBalancerData(e)), _connectedClusterLoadBalancerLoadBalancersClientDiagnostics, Pipeline, "ConnectedClusterLoadBalancerCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerCollection.Exists"); + scope.Start(); + try + { + var response = await _connectedClusterLoadBalancerLoadBalancersRestClient.GetAsync(Id, loadBalancerName, cancellationToken: cancellationToken).ConfigureAwait(false); + 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 + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerCollection.Exists"); + scope.Start(); + try + { + var response = _connectedClusterLoadBalancerLoadBalancersRestClient.Get(Id, loadBalancerName, cancellationToken: cancellationToken); + 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 + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _connectedClusterLoadBalancerLoadBalancersRestClient.GetAsync(Id, loadBalancerName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterLoadBalancerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerCollection.GetIfExists"); + scope.Start(); + try + { + var response = _connectedClusterLoadBalancerLoadBalancersRestClient.Get(Id, loadBalancerName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterLoadBalancerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerData.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerData.Serialization.cs new file mode 100644 index 000000000000..ee1281295541 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerData.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.Core; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + public partial class ConnectedClusterLoadBalancerData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterLoadBalancerData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + ConnectedClusterLoadBalancerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterLoadBalancerData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedClusterLoadBalancerData(document.RootElement, options); + } + + internal static ConnectedClusterLoadBalancerData DeserializeConnectedClusterLoadBalancerData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ConnectedClusterLoadBalancerProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ConnectedClusterLoadBalancerProperties.DeserializeConnectedClusterLoadBalancerProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedClusterLoadBalancerData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedClusterLoadBalancerData)} does not support writing '{options.Format}' format."); + } + } + + ConnectedClusterLoadBalancerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeConnectedClusterLoadBalancerData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedClusterLoadBalancerData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerData.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerData.cs new file mode 100644 index 000000000000..a60a5c3712ba --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerData.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; +using Azure.Core; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// A class representing the ConnectedClusterLoadBalancer data model. + /// A LoadBalancer resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + /// + public partial class ConnectedClusterLoadBalancerData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ConnectedClusterLoadBalancerData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal ConnectedClusterLoadBalancerData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ConnectedClusterLoadBalancerProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public ConnectedClusterLoadBalancerProperties Properties { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerResource.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerResource.Serialization.cs new file mode 100644 index 000000000000..336ca9b2de4e --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.ContainerOrchestratorRuntime +{ + public partial class ConnectedClusterLoadBalancerResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + ConnectedClusterLoadBalancerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + ConnectedClusterLoadBalancerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerResource.cs new file mode 100644 index 000000000000..feb298313a85 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterLoadBalancerResource.cs @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// A Class representing a ConnectedClusterLoadBalancer 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 GetConnectedClusterLoadBalancerResource method. + /// Otherwise you can get one from its parent resource using the GetConnectedClusterLoadBalancer method. + /// + public partial class ConnectedClusterLoadBalancerResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The resourceUri. + /// The loadBalancerName. + public static ResourceIdentifier CreateResourceIdentifier(string resourceUri, string loadBalancerName) + { + var resourceId = $"{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _connectedClusterLoadBalancerLoadBalancersClientDiagnostics; + private readonly LoadBalancersRestOperations _connectedClusterLoadBalancerLoadBalancersRestClient; + private readonly ConnectedClusterLoadBalancerData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.KubernetesRuntime/loadBalancers"; + + /// Initializes a new instance of the class for mocking. + protected ConnectedClusterLoadBalancerResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ConnectedClusterLoadBalancerResource(ArmClient client, ConnectedClusterLoadBalancerData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ConnectedClusterLoadBalancerResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _connectedClusterLoadBalancerLoadBalancersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerOrchestratorRuntime", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string connectedClusterLoadBalancerLoadBalancersApiVersion); + _connectedClusterLoadBalancerLoadBalancersRestClient = new LoadBalancersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, connectedClusterLoadBalancerLoadBalancersApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual ConnectedClusterLoadBalancerData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerResource.Get"); + scope.Start(); + try + { + var response = await _connectedClusterLoadBalancerLoadBalancersRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterLoadBalancerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerResource.Get"); + scope.Start(); + try + { + var response = _connectedClusterLoadBalancerLoadBalancersRestClient.Get(Id.Parent, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterLoadBalancerResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Delete + /// + /// + /// Default Api Version + /// 2024-03-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 var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerResource.Delete"); + scope.Start(); + try + { + var response = await _connectedClusterLoadBalancerLoadBalancersRestClient.DeleteAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _connectedClusterLoadBalancerLoadBalancersRestClient.CreateDeleteRequestUri(Id.Parent, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Delete + /// + /// + /// Default Api Version + /// 2024-03-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 var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerResource.Delete"); + scope.Start(); + try + { + var response = _connectedClusterLoadBalancerLoadBalancersRestClient.Delete(Id.Parent, Id.Name, cancellationToken); + var uri = _connectedClusterLoadBalancerLoadBalancersRestClient.CreateDeleteRequestUri(Id.Parent, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ConnectedClusterLoadBalancerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerResource.Update"); + scope.Start(); + try + { + var response = await _connectedClusterLoadBalancerLoadBalancersRestClient.CreateOrUpdateAsync(Id.Parent, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterLoadBalancerOperationSource(Client), _connectedClusterLoadBalancerLoadBalancersClientDiagnostics, Pipeline, _connectedClusterLoadBalancerLoadBalancersRestClient.CreateCreateOrUpdateRequest(Id.Parent, Id.Name, data).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 LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ConnectedClusterLoadBalancerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterLoadBalancerLoadBalancersClientDiagnostics.CreateScope("ConnectedClusterLoadBalancerResource.Update"); + scope.Start(); + try + { + var response = _connectedClusterLoadBalancerLoadBalancersRestClient.CreateOrUpdate(Id.Parent, Id.Name, data, cancellationToken); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterLoadBalancerOperationSource(Client), _connectedClusterLoadBalancerLoadBalancersClientDiagnostics, Pipeline, _connectedClusterLoadBalancerLoadBalancersRestClient.CreateCreateOrUpdateRequest(Id.Parent, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceCollection.cs new file mode 100644 index 000000000000..6e23faa75c37 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceCollection.cs @@ -0,0 +1,487 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// 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 GetConnectedClusterServices method from an instance of . + /// + public partial class ConnectedClusterServiceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _connectedClusterServiceServicesClientDiagnostics; + private readonly ServicesRestOperations _connectedClusterServiceServicesRestClient; + + /// Initializes a new instance of the class for mocking. + protected ConnectedClusterServiceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal ConnectedClusterServiceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _connectedClusterServiceServicesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerOrchestratorRuntime", ConnectedClusterServiceResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ConnectedClusterServiceResource.ResourceType, out string connectedClusterServiceServicesApiVersion); + _connectedClusterServiceServicesRestClient = new ServicesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, connectedClusterServiceServicesApiVersion); + } + + /// + /// Create a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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 name of the the service. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string serviceName, ConnectedClusterServiceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _connectedClusterServiceServicesRestClient.CreateOrUpdateAsync(Id, serviceName, data, cancellationToken).ConfigureAwait(false); + var uri = _connectedClusterServiceServicesRestClient.CreateCreateOrUpdateRequestUri(Id, serviceName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(Response.FromValue(new ConnectedClusterServiceResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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 name of the the service. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string serviceName, ConnectedClusterServiceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _connectedClusterServiceServicesRestClient.CreateOrUpdate(Id, serviceName, data, cancellationToken); + var uri = _connectedClusterServiceServicesRestClient.CreateCreateOrUpdateRequestUri(Id, serviceName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(Response.FromValue(new ConnectedClusterServiceResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the service. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceCollection.Get"); + scope.Start(); + try + { + var response = await _connectedClusterServiceServicesRestClient.GetAsync(Id, serviceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterServiceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the service. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceCollection.Get"); + scope.Start(); + try + { + var response = _connectedClusterServiceServicesRestClient.Get(Id, serviceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterServiceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List ServiceResource resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services + /// + /// + /// Operation Id + /// ServiceResource_List + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _connectedClusterServiceServicesRestClient.CreateListRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _connectedClusterServiceServicesRestClient.CreateListNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ConnectedClusterServiceResource(Client, ConnectedClusterServiceData.DeserializeConnectedClusterServiceData(e)), _connectedClusterServiceServicesClientDiagnostics, Pipeline, "ConnectedClusterServiceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List ServiceResource resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services + /// + /// + /// Operation Id + /// ServiceResource_List + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _connectedClusterServiceServicesRestClient.CreateListRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _connectedClusterServiceServicesRestClient.CreateListNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ConnectedClusterServiceResource(Client, ConnectedClusterServiceData.DeserializeConnectedClusterServiceData(e)), _connectedClusterServiceServicesClientDiagnostics, Pipeline, "ConnectedClusterServiceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the service. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceCollection.Exists"); + scope.Start(); + try + { + var response = await _connectedClusterServiceServicesRestClient.GetAsync(Id, serviceName, cancellationToken: cancellationToken).ConfigureAwait(false); + 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 + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the service. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceCollection.Exists"); + scope.Start(); + try + { + var response = _connectedClusterServiceServicesRestClient.Get(Id, serviceName, cancellationToken: cancellationToken); + 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 + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the service. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _connectedClusterServiceServicesRestClient.GetAsync(Id, serviceName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterServiceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the service. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _connectedClusterServiceServicesRestClient.Get(Id, serviceName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterServiceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceData.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceData.Serialization.cs new file mode 100644 index 000000000000..a057f3831122 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceData.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.Core; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + public partial class ConnectedClusterServiceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterServiceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + ConnectedClusterServiceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterServiceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedClusterServiceData(document.RootElement, options); + } + + internal static ConnectedClusterServiceData DeserializeConnectedClusterServiceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ConnectedClusterServiceProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ConnectedClusterServiceProperties.DeserializeConnectedClusterServiceProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedClusterServiceData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedClusterServiceData)} does not support writing '{options.Format}' format."); + } + } + + ConnectedClusterServiceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeConnectedClusterServiceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedClusterServiceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceData.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceData.cs new file mode 100644 index 000000000000..cc86f87ed5d5 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceData.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; +using Azure.Core; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// A class representing the ConnectedClusterService data model. + /// A Service resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + /// + public partial class ConnectedClusterServiceData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ConnectedClusterServiceData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal ConnectedClusterServiceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ConnectedClusterServiceProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public ConnectedClusterServiceProperties Properties { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceResource.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceResource.Serialization.cs new file mode 100644 index 000000000000..9d6e34cb7fd6 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.ContainerOrchestratorRuntime +{ + public partial class ConnectedClusterServiceResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + ConnectedClusterServiceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + ConnectedClusterServiceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceResource.cs new file mode 100644 index 000000000000..a329e88f01e8 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterServiceResource.cs @@ -0,0 +1,353 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// A Class representing a ConnectedClusterService 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 GetConnectedClusterServiceResource method. + /// Otherwise you can get one from its parent resource using the GetConnectedClusterService method. + /// + public partial class ConnectedClusterServiceResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The resourceUri. + /// The serviceName. + public static ResourceIdentifier CreateResourceIdentifier(string resourceUri, string serviceName) + { + var resourceId = $"{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _connectedClusterServiceServicesClientDiagnostics; + private readonly ServicesRestOperations _connectedClusterServiceServicesRestClient; + private readonly ConnectedClusterServiceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.KubernetesRuntime/services"; + + /// Initializes a new instance of the class for mocking. + protected ConnectedClusterServiceResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ConnectedClusterServiceResource(ArmClient client, ConnectedClusterServiceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ConnectedClusterServiceResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _connectedClusterServiceServicesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerOrchestratorRuntime", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string connectedClusterServiceServicesApiVersion); + _connectedClusterServiceServicesRestClient = new ServicesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, connectedClusterServiceServicesApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual ConnectedClusterServiceData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceResource.Get"); + scope.Start(); + try + { + var response = await _connectedClusterServiceServicesRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterServiceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceResource.Get"); + scope.Start(); + try + { + var response = _connectedClusterServiceServicesRestClient.Get(Id.Parent, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterServiceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Delete + /// + /// + /// Default Api Version + /// 2024-03-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 var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceResource.Delete"); + scope.Start(); + try + { + var response = await _connectedClusterServiceServicesRestClient.DeleteAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _connectedClusterServiceServicesRestClient.CreateDeleteRequestUri(Id.Parent, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Delete + /// + /// + /// Default Api Version + /// 2024-03-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 var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceResource.Delete"); + scope.Start(); + try + { + var response = _connectedClusterServiceServicesRestClient.Delete(Id.Parent, Id.Name, cancellationToken); + var uri = _connectedClusterServiceServicesRestClient.CreateDeleteRequestUri(Id.Parent, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ConnectedClusterServiceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceResource.Update"); + scope.Start(); + try + { + var response = await _connectedClusterServiceServicesRestClient.CreateOrUpdateAsync(Id.Parent, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _connectedClusterServiceServicesRestClient.CreateCreateOrUpdateRequestUri(Id.Parent, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(Response.FromValue(new ConnectedClusterServiceResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ConnectedClusterServiceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterServiceServicesClientDiagnostics.CreateScope("ConnectedClusterServiceResource.Update"); + scope.Start(); + try + { + var response = _connectedClusterServiceServicesRestClient.CreateOrUpdate(Id.Parent, Id.Name, data, cancellationToken); + var uri = _connectedClusterServiceServicesRestClient.CreateCreateOrUpdateRequestUri(Id.Parent, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ContainerOrchestratorRuntimeArmOperation(Response.FromValue(new ConnectedClusterServiceResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassCollection.cs new file mode 100644 index 000000000000..3c5aa7d35373 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassCollection.cs @@ -0,0 +1,483 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// 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 GetConnectedClusterStorageClasses method from an instance of . + /// + public partial class ConnectedClusterStorageClassCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _connectedClusterStorageClassStorageClassClientDiagnostics; + private readonly StorageClassRestOperations _connectedClusterStorageClassStorageClassRestClient; + + /// Initializes a new instance of the class for mocking. + protected ConnectedClusterStorageClassCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal ConnectedClusterStorageClassCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _connectedClusterStorageClassStorageClassClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerOrchestratorRuntime", ConnectedClusterStorageClassResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ConnectedClusterStorageClassResource.ResourceType, out string connectedClusterStorageClassStorageClassApiVersion); + _connectedClusterStorageClassStorageClassRestClient = new StorageClassRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, connectedClusterStorageClassStorageClassApiVersion); + } + + /// + /// Create a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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 name of the the storage class. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string storageClassName, ConnectedClusterStorageClassData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _connectedClusterStorageClassStorageClassRestClient.CreateOrUpdateAsync(Id, storageClassName, data, cancellationToken).ConfigureAwait(false); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterStorageClassOperationSource(Client), _connectedClusterStorageClassStorageClassClientDiagnostics, Pipeline, _connectedClusterStorageClassStorageClassRestClient.CreateCreateOrUpdateRequest(Id, storageClassName, data).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 StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-03-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 name of the the storage class. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string storageClassName, ConnectedClusterStorageClassData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _connectedClusterStorageClassStorageClassRestClient.CreateOrUpdate(Id, storageClassName, data, cancellationToken); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterStorageClassOperationSource(Client), _connectedClusterStorageClassStorageClassClientDiagnostics, Pipeline, _connectedClusterStorageClassStorageClassRestClient.CreateCreateOrUpdateRequest(Id, storageClassName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the storage class. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassCollection.Get"); + scope.Start(); + try + { + var response = await _connectedClusterStorageClassStorageClassRestClient.GetAsync(Id, storageClassName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterStorageClassResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the storage class. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassCollection.Get"); + scope.Start(); + try + { + var response = _connectedClusterStorageClassStorageClassRestClient.Get(Id, storageClassName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterStorageClassResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List StorageClassResource resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses + /// + /// + /// Operation Id + /// StorageClassResource_List + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _connectedClusterStorageClassStorageClassRestClient.CreateListRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _connectedClusterStorageClassStorageClassRestClient.CreateListNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ConnectedClusterStorageClassResource(Client, ConnectedClusterStorageClassData.DeserializeConnectedClusterStorageClassData(e)), _connectedClusterStorageClassStorageClassClientDiagnostics, Pipeline, "ConnectedClusterStorageClassCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List StorageClassResource resources by parent + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses + /// + /// + /// Operation Id + /// StorageClassResource_List + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _connectedClusterStorageClassStorageClassRestClient.CreateListRequest(Id); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _connectedClusterStorageClassStorageClassRestClient.CreateListNextPageRequest(nextLink, Id); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ConnectedClusterStorageClassResource(Client, ConnectedClusterStorageClassData.DeserializeConnectedClusterStorageClassData(e)), _connectedClusterStorageClassStorageClassClientDiagnostics, Pipeline, "ConnectedClusterStorageClassCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the storage class. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassCollection.Exists"); + scope.Start(); + try + { + var response = await _connectedClusterStorageClassStorageClassRestClient.GetAsync(Id, storageClassName, cancellationToken: cancellationToken).ConfigureAwait(false); + 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 + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the storage class. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassCollection.Exists"); + scope.Start(); + try + { + var response = _connectedClusterStorageClassStorageClassRestClient.Get(Id, storageClassName, cancellationToken: cancellationToken); + 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 + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the storage class. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _connectedClusterStorageClassStorageClassRestClient.GetAsync(Id, storageClassName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterStorageClassResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the the storage class. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassCollection.GetIfExists"); + scope.Start(); + try + { + var response = _connectedClusterStorageClassStorageClassRestClient.Get(Id, storageClassName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterStorageClassResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassData.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassData.Serialization.cs new file mode 100644 index 000000000000..0a775d108c05 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassData.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.Core; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + public partial class ConnectedClusterStorageClassData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + ConnectedClusterStorageClassData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedClusterStorageClassData(document.RootElement, options); + } + + internal static ConnectedClusterStorageClassData DeserializeConnectedClusterStorageClassData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ConnectedClusterStorageClassProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ConnectedClusterStorageClassProperties.DeserializeConnectedClusterStorageClassProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedClusterStorageClassData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassData)} does not support writing '{options.Format}' format."); + } + } + + ConnectedClusterStorageClassData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeConnectedClusterStorageClassData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassData.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassData.cs new file mode 100644 index 000000000000..681dfac412f0 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassData.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; +using Azure.Core; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// A class representing the ConnectedClusterStorageClass data model. + /// A StorageClass resource for an Arc connected cluster (Microsoft.Kubernetes/connectedClusters) + /// + public partial class ConnectedClusterStorageClassData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ConnectedClusterStorageClassData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal ConnectedClusterStorageClassData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ConnectedClusterStorageClassProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public ConnectedClusterStorageClassProperties Properties { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassResource.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassResource.Serialization.cs new file mode 100644 index 000000000000..6eb02c25c194 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassResource.Serialization.cs @@ -0,0 +1,26 @@ +// 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.ContainerOrchestratorRuntime +{ + public partial class ConnectedClusterStorageClassResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + ConnectedClusterStorageClassData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + ConnectedClusterStorageClassData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassResource.cs new file mode 100644 index 000000000000..c9858413d246 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ConnectedClusterStorageClassResource.cs @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// + /// A Class representing a ConnectedClusterStorageClass 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 GetConnectedClusterStorageClassResource method. + /// Otherwise you can get one from its parent resource using the GetConnectedClusterStorageClass method. + /// + public partial class ConnectedClusterStorageClassResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The resourceUri. + /// The storageClassName. + public static ResourceIdentifier CreateResourceIdentifier(string resourceUri, string storageClassName) + { + var resourceId = $"{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _connectedClusterStorageClassStorageClassClientDiagnostics; + private readonly StorageClassRestOperations _connectedClusterStorageClassStorageClassRestClient; + private readonly ConnectedClusterStorageClassData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.KubernetesRuntime/storageClasses"; + + /// Initializes a new instance of the class for mocking. + protected ConnectedClusterStorageClassResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ConnectedClusterStorageClassResource(ArmClient client, ConnectedClusterStorageClassData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ConnectedClusterStorageClassResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _connectedClusterStorageClassStorageClassClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ContainerOrchestratorRuntime", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string connectedClusterStorageClassStorageClassApiVersion); + _connectedClusterStorageClassStorageClassRestClient = new StorageClassRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, connectedClusterStorageClassStorageClassApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual ConnectedClusterStorageClassData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassResource.Get"); + scope.Start(); + try + { + var response = await _connectedClusterStorageClassStorageClassRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterStorageClassResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassResource.Get"); + scope.Start(); + try + { + var response = _connectedClusterStorageClassStorageClassRestClient.Get(Id.Parent, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ConnectedClusterStorageClassResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Delete + /// + /// + /// Default Api Version + /// 2024-03-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 var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassResource.Delete"); + scope.Start(); + try + { + var response = await _connectedClusterStorageClassStorageClassRestClient.DeleteAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new ContainerOrchestratorRuntimeArmOperation(_connectedClusterStorageClassStorageClassClientDiagnostics, Pipeline, _connectedClusterStorageClassStorageClassRestClient.CreateDeleteRequest(Id.Parent, Id.Name).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 StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Delete + /// + /// + /// Default Api Version + /// 2024-03-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 var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassResource.Delete"); + scope.Start(); + try + { + var response = _connectedClusterStorageClassStorageClassRestClient.Delete(Id.Parent, Id.Name, cancellationToken); + var operation = new ContainerOrchestratorRuntimeArmOperation(_connectedClusterStorageClassStorageClassClientDiagnostics, Pipeline, _connectedClusterStorageClassStorageClassRestClient.CreateDeleteRequest(Id.Parent, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Update + /// + /// + /// Default Api Version + /// 2024-03-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 resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ConnectedClusterStorageClassPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassResource.Update"); + scope.Start(); + try + { + var response = await _connectedClusterStorageClassStorageClassRestClient.UpdateAsync(Id.Parent, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterStorageClassOperationSource(Client), _connectedClusterStorageClassStorageClassClientDiagnostics, Pipeline, _connectedClusterStorageClassStorageClassRestClient.CreateUpdateRequest(Id.Parent, Id.Name, patch).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 StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Update + /// + /// + /// Default Api Version + /// 2024-03-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 resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ConnectedClusterStorageClassPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _connectedClusterStorageClassStorageClassClientDiagnostics.CreateScope("ConnectedClusterStorageClassResource.Update"); + scope.Start(); + try + { + var response = _connectedClusterStorageClassStorageClassRestClient.Update(Id.Parent, Id.Name, patch, cancellationToken); + var operation = new ContainerOrchestratorRuntimeArmOperation(new ConnectedClusterStorageClassOperationSource(Client), _connectedClusterStorageClassStorageClassClientDiagnostics, Pipeline, _connectedClusterStorageClassStorageClassRestClient.CreateUpdateRequest(Id.Parent, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Extensions/ContainerOrchestratorRuntimeExtensions.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Extensions/ContainerOrchestratorRuntimeExtensions.cs new file mode 100644 index 000000000000..493e4ab2687b --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Extensions/ContainerOrchestratorRuntimeExtensions.cs @@ -0,0 +1,484 @@ +// 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.Core; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Mocking; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + /// A class to add extension methods to Azure.ResourceManager.ContainerOrchestratorRuntime. + public static partial class ContainerOrchestratorRuntimeExtensions + { + private static MockableContainerOrchestratorRuntimeArmClient GetMockableContainerOrchestratorRuntimeArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableContainerOrchestratorRuntimeArmClient(client0)); + } + + /// + /// Gets a collection of ConnectedClusterStorageClassResources in the ArmClient. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// is null. + /// An object representing collection of ConnectedClusterStorageClassResources and their operations over a ConnectedClusterStorageClassResource. + public static ConnectedClusterStorageClassCollection GetConnectedClusterStorageClasses(this ArmClient client, ResourceIdentifier scope) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterStorageClasses(scope); + } + + /// + /// Get a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the the storage class. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetConnectedClusterStorageClassAsync(this ArmClient client, ResourceIdentifier scope, string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return await GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterStorageClassAsync(scope, storageClassName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the the storage class. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetConnectedClusterStorageClass(this ArmClient client, ResourceIdentifier scope, string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterStorageClass(scope, storageClassName, cancellationToken); + } + + /// + /// Gets a collection of ConnectedClusterLoadBalancerResources in the ArmClient. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// is null. + /// An object representing collection of ConnectedClusterLoadBalancerResources and their operations over a ConnectedClusterLoadBalancerResource. + public static ConnectedClusterLoadBalancerCollection GetConnectedClusterLoadBalancers(this ArmClient client, ResourceIdentifier scope) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterLoadBalancers(scope); + } + + /// + /// Get a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetConnectedClusterLoadBalancerAsync(this ArmClient client, ResourceIdentifier scope, string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return await GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterLoadBalancerAsync(scope, loadBalancerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetConnectedClusterLoadBalancer(this ArmClient client, ResourceIdentifier scope, string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterLoadBalancer(scope, loadBalancerName, cancellationToken); + } + + /// + /// Gets a collection of ConnectedClusterBgpPeerResources in the ArmClient. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// is null. + /// An object representing collection of ConnectedClusterBgpPeerResources and their operations over a ConnectedClusterBgpPeerResource. + public static ConnectedClusterBgpPeerCollection GetConnectedClusterBgpPeers(this ArmClient client, ResourceIdentifier scope) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterBgpPeers(scope); + } + + /// + /// Get a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the BgpPeer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetConnectedClusterBgpPeerAsync(this ArmClient client, ResourceIdentifier scope, string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return await GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterBgpPeerAsync(scope, bgpPeerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the BgpPeer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetConnectedClusterBgpPeer(this ArmClient client, ResourceIdentifier scope, string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterBgpPeer(scope, bgpPeerName, cancellationToken); + } + + /// + /// Gets a collection of ConnectedClusterServiceResources in the ArmClient. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// is null. + /// An object representing collection of ConnectedClusterServiceResources and their operations over a ConnectedClusterServiceResource. + public static ConnectedClusterServiceCollection GetConnectedClusterServices(this ArmClient client, ResourceIdentifier scope) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterServices(scope); + } + + /// + /// Get a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the the service. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetConnectedClusterServiceAsync(this ArmClient client, ResourceIdentifier scope, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return await GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterServiceAsync(scope, serviceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the the service. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetConnectedClusterService(this ArmClient client, ResourceIdentifier scope, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterService(scope, serviceName, cancellationToken); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ConnectedClusterStorageClassResource GetConnectedClusterStorageClassResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterStorageClassResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ConnectedClusterLoadBalancerResource GetConnectedClusterLoadBalancerResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterLoadBalancerResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ConnectedClusterBgpPeerResource GetConnectedClusterBgpPeerResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterBgpPeerResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ConnectedClusterServiceResource GetConnectedClusterServiceResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableContainerOrchestratorRuntimeArmClient(client).GetConnectedClusterServiceResource(id); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Extensions/MockableContainerOrchestratorRuntimeArmClient.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Extensions/MockableContainerOrchestratorRuntimeArmClient.cs new file mode 100644 index 000000000000..e116a985d93d --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Extensions/MockableContainerOrchestratorRuntimeArmClient.cs @@ -0,0 +1,376 @@ +// 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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableContainerOrchestratorRuntimeArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableContainerOrchestratorRuntimeArmClient() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableContainerOrchestratorRuntimeArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableContainerOrchestratorRuntimeArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of ConnectedClusterStorageClassResources in the ArmClient. + /// The scope that the resource will apply against. + /// An object representing collection of ConnectedClusterStorageClassResources and their operations over a ConnectedClusterStorageClassResource. + public virtual ConnectedClusterStorageClassCollection GetConnectedClusterStorageClasses(ResourceIdentifier scope) + { + return new ConnectedClusterStorageClassCollection(Client, scope); + } + + /// + /// Get a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the the storage class. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetConnectedClusterStorageClassAsync(ResourceIdentifier scope, string storageClassName, CancellationToken cancellationToken = default) + { + return await GetConnectedClusterStorageClasses(scope).GetAsync(storageClassName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a StorageClassResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/storageClasses/{storageClassName} + /// + /// + /// Operation Id + /// StorageClass_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the the storage class. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetConnectedClusterStorageClass(ResourceIdentifier scope, string storageClassName, CancellationToken cancellationToken = default) + { + return GetConnectedClusterStorageClasses(scope).Get(storageClassName, cancellationToken); + } + + /// Gets a collection of ConnectedClusterLoadBalancerResources in the ArmClient. + /// The scope that the resource will apply against. + /// An object representing collection of ConnectedClusterLoadBalancerResources and their operations over a ConnectedClusterLoadBalancerResource. + public virtual ConnectedClusterLoadBalancerCollection GetConnectedClusterLoadBalancers(ResourceIdentifier scope) + { + return new ConnectedClusterLoadBalancerCollection(Client, scope); + } + + /// + /// Get a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetConnectedClusterLoadBalancerAsync(ResourceIdentifier scope, string loadBalancerName, CancellationToken cancellationToken = default) + { + return await GetConnectedClusterLoadBalancers(scope).GetAsync(loadBalancerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a LoadBalancer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/loadBalancers/{loadBalancerName} + /// + /// + /// Operation Id + /// LoadBalancers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetConnectedClusterLoadBalancer(ResourceIdentifier scope, string loadBalancerName, CancellationToken cancellationToken = default) + { + return GetConnectedClusterLoadBalancers(scope).Get(loadBalancerName, cancellationToken); + } + + /// Gets a collection of ConnectedClusterBgpPeerResources in the ArmClient. + /// The scope that the resource will apply against. + /// An object representing collection of ConnectedClusterBgpPeerResources and their operations over a ConnectedClusterBgpPeerResource. + public virtual ConnectedClusterBgpPeerCollection GetConnectedClusterBgpPeers(ResourceIdentifier scope) + { + return new ConnectedClusterBgpPeerCollection(Client, scope); + } + + /// + /// Get a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the BgpPeer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetConnectedClusterBgpPeerAsync(ResourceIdentifier scope, string bgpPeerName, CancellationToken cancellationToken = default) + { + return await GetConnectedClusterBgpPeers(scope).GetAsync(bgpPeerName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a BgpPeer + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/bgpPeers/{bgpPeerName} + /// + /// + /// Operation Id + /// BgpPeers_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the BgpPeer. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetConnectedClusterBgpPeer(ResourceIdentifier scope, string bgpPeerName, CancellationToken cancellationToken = default) + { + return GetConnectedClusterBgpPeers(scope).Get(bgpPeerName, cancellationToken); + } + + /// Gets a collection of ConnectedClusterServiceResources in the ArmClient. + /// The scope that the resource will apply against. + /// An object representing collection of ConnectedClusterServiceResources and their operations over a ConnectedClusterServiceResource. + public virtual ConnectedClusterServiceCollection GetConnectedClusterServices(ResourceIdentifier scope) + { + return new ConnectedClusterServiceCollection(Client, scope); + } + + /// + /// Get a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the the service. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetConnectedClusterServiceAsync(ResourceIdentifier scope, string serviceName, CancellationToken cancellationToken = default) + { + return await GetConnectedClusterServices(scope).GetAsync(serviceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a ServiceResource + /// + /// + /// Request Path + /// /{resourceUri}/providers/Microsoft.KubernetesRuntime/services/{serviceName} + /// + /// + /// Operation Id + /// Services_Get + /// + /// + /// Default Api Version + /// 2024-03-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the the service. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetConnectedClusterService(ResourceIdentifier scope, string serviceName, CancellationToken cancellationToken = default) + { + return GetConnectedClusterServices(scope).Get(serviceName, cancellationToken); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ConnectedClusterStorageClassResource GetConnectedClusterStorageClassResource(ResourceIdentifier id) + { + ConnectedClusterStorageClassResource.ValidateResourceId(id); + return new ConnectedClusterStorageClassResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ConnectedClusterLoadBalancerResource GetConnectedClusterLoadBalancerResource(ResourceIdentifier id) + { + ConnectedClusterLoadBalancerResource.ValidateResourceId(id); + return new ConnectedClusterLoadBalancerResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ConnectedClusterBgpPeerResource GetConnectedClusterBgpPeerResource(ResourceIdentifier id) + { + ConnectedClusterBgpPeerResource.ValidateResourceId(id); + return new ConnectedClusterBgpPeerResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ConnectedClusterServiceResource GetConnectedClusterServiceResource(ResourceIdentifier id) + { + ConnectedClusterServiceResource.ValidateResourceId(id); + return new ConnectedClusterServiceResource(Client, id); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/Argument.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..a65d949f1f69 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// 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.ContainerOrchestratorRuntime +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(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); + } + } + + 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); + } + } + + 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); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", 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."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..523aea7871d3 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// 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.ContainerOrchestratorRuntime +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/ChangeTrackingList.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..99ac7574a0dc --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// 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.ContainerOrchestratorRuntime +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + 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(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..dada287fbfba --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/ModelSerializationExtensions.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.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + 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: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var 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) + { + var 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) + { + var 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 IUtf8JsonSerializable serializable: + serializable.Write(writer); + 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); + } + + internal static 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}. Azure SDK requires 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 ConvertToString(object value, string format = null) => 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 format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/Optional.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..49d47bb50e2e --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/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.ContainerOrchestratorRuntime +{ + internal static 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(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..97b1c41080d1 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ConnectedClusterBgpPeerOperationSource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ConnectedClusterBgpPeerOperationSource.cs new file mode 100644 index 000000000000..65ddf31da073 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ConnectedClusterBgpPeerOperationSource.cs @@ -0,0 +1,38 @@ +// 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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal class ConnectedClusterBgpPeerOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal ConnectedClusterBgpPeerOperationSource(ArmClient client) + { + _client = client; + } + + ConnectedClusterBgpPeerResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = ConnectedClusterBgpPeerData.DeserializeConnectedClusterBgpPeerData(document.RootElement); + return new ConnectedClusterBgpPeerResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = ConnectedClusterBgpPeerData.DeserializeConnectedClusterBgpPeerData(document.RootElement); + return new ConnectedClusterBgpPeerResource(_client, data); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ConnectedClusterLoadBalancerOperationSource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ConnectedClusterLoadBalancerOperationSource.cs new file mode 100644 index 000000000000..89cae47fe4b8 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ConnectedClusterLoadBalancerOperationSource.cs @@ -0,0 +1,38 @@ +// 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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal class ConnectedClusterLoadBalancerOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal ConnectedClusterLoadBalancerOperationSource(ArmClient client) + { + _client = client; + } + + ConnectedClusterLoadBalancerResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = ConnectedClusterLoadBalancerData.DeserializeConnectedClusterLoadBalancerData(document.RootElement); + return new ConnectedClusterLoadBalancerResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = ConnectedClusterLoadBalancerData.DeserializeConnectedClusterLoadBalancerData(document.RootElement); + return new ConnectedClusterLoadBalancerResource(_client, data); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ConnectedClusterStorageClassOperationSource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ConnectedClusterStorageClassOperationSource.cs new file mode 100644 index 000000000000..8c5e94773483 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ConnectedClusterStorageClassOperationSource.cs @@ -0,0 +1,38 @@ +// 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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal class ConnectedClusterStorageClassOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal ConnectedClusterStorageClassOperationSource(ArmClient client) + { + _client = client; + } + + ConnectedClusterStorageClassResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = ConnectedClusterStorageClassData.DeserializeConnectedClusterStorageClassData(document.RootElement); + return new ConnectedClusterStorageClassResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = ConnectedClusterStorageClassData.DeserializeConnectedClusterStorageClassData(document.RootElement); + return new ConnectedClusterStorageClassResource(_client, data); + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ContainerOrchestratorRuntimeArmOperation.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ContainerOrchestratorRuntimeArmOperation.cs new file mode 100644 index 000000000000..8b0670504116 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ContainerOrchestratorRuntimeArmOperation.cs @@ -0,0 +1,94 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ +#pragma warning disable SA1649 // File name should match first type name + internal class ContainerOrchestratorRuntimeArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of ContainerOrchestratorRuntimeArmOperation for mocking. + protected ContainerOrchestratorRuntimeArmOperation() + { + } + + internal ContainerOrchestratorRuntimeArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal ContainerOrchestratorRuntimeArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "ContainerOrchestratorRuntimeArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ContainerOrchestratorRuntimeArmOperationOfT.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ContainerOrchestratorRuntimeArmOperationOfT.cs new file mode 100644 index 000000000000..6caaa91dc6d9 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/LongRunningOperation/ContainerOrchestratorRuntimeArmOperationOfT.cs @@ -0,0 +1,100 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ +#pragma warning disable SA1649 // File name should match first type name + internal class ContainerOrchestratorRuntimeArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of ContainerOrchestratorRuntimeArmOperation for mocking. + protected ContainerOrchestratorRuntimeArmOperation() + { + } + + internal ContainerOrchestratorRuntimeArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal ContainerOrchestratorRuntimeArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _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, "ContainerOrchestratorRuntimeArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override T Value => _operation.Value; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/AdvertiseMode.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/AdvertiseMode.cs new file mode 100644 index 000000000000..1c22641d42ee --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/AdvertiseMode.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Enum of advertise mode. + public readonly partial struct AdvertiseMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AdvertiseMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ArpValue = "ARP"; + private const string BgpValue = "BGP"; + private const string BothValue = "Both"; + + /// ARP advertise mode. + public static AdvertiseMode Arp { get; } = new AdvertiseMode(ArpValue); + /// BGP advertise mode. + public static AdvertiseMode Bgp { get; } = new AdvertiseMode(BgpValue); + /// both ARP and BGP advertise mode. + public static AdvertiseMode Both { get; } = new AdvertiseMode(BothValue); + /// Determines if two values are the same. + public static bool operator ==(AdvertiseMode left, AdvertiseMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AdvertiseMode left, AdvertiseMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AdvertiseMode(string value) => new AdvertiseMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AdvertiseMode other && Equals(other); + /// + public bool Equals(AdvertiseMode 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BgpPeerListResult.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BgpPeerListResult.Serialization.cs new file mode 100644 index 000000000000..61463c25325d --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BgpPeerListResult.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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + internal partial class BgpPeerListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BgpPeerListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + BgpPeerListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BgpPeerListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBgpPeerListResult(document.RootElement, options); + } + + internal static BgpPeerListResult DeserializeBgpPeerListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ConnectedClusterBgpPeerData.DeserializeConnectedClusterBgpPeerData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BgpPeerListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BgpPeerListResult)} does not support writing '{options.Format}' format."); + } + } + + BgpPeerListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBgpPeerListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BgpPeerListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BgpPeerListResult.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BgpPeerListResult.cs new file mode 100644 index 000000000000..78a37cd6a785 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BgpPeerListResult.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 System.Linq; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The response of a BgpPeer list operation. + internal partial class BgpPeerListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The BgpPeer items on this page. + /// is null. + internal BgpPeerListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The BgpPeer items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal BgpPeerListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BgpPeerListResult() + { + } + + /// The BgpPeer items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BlobStorageClassTypeProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BlobStorageClassTypeProperties.Serialization.cs new file mode 100644 index 000000000000..063c0867546f --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BlobStorageClassTypeProperties.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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class BlobStorageClassTypeProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BlobStorageClassTypeProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("azureStorageAccountName"u8); + writer.WriteStringValue(AzureStorageAccountName); + writer.WritePropertyName("azureStorageAccountKey"u8); + writer.WriteStringValue(AzureStorageAccountKey); + } + + BlobStorageClassTypeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BlobStorageClassTypeProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBlobStorageClassTypeProperties(document.RootElement, options); + } + + internal static BlobStorageClassTypeProperties DeserializeBlobStorageClassTypeProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string azureStorageAccountName = default; + string azureStorageAccountKey = default; + StorageClassType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("azureStorageAccountName"u8)) + { + azureStorageAccountName = property.Value.GetString(); + continue; + } + if (property.NameEquals("azureStorageAccountKey"u8)) + { + azureStorageAccountKey = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new StorageClassType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BlobStorageClassTypeProperties(type, serializedAdditionalRawData, azureStorageAccountName, azureStorageAccountKey); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BlobStorageClassTypeProperties)} does not support writing '{options.Format}' format."); + } + } + + BlobStorageClassTypeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBlobStorageClassTypeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BlobStorageClassTypeProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BlobStorageClassTypeProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BlobStorageClassTypeProperties.cs new file mode 100644 index 000000000000..dfef894940b9 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/BlobStorageClassTypeProperties.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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The properties of Blob StorageClass. + public partial class BlobStorageClassTypeProperties : StorageClassTypeProperties + { + /// Initializes a new instance of . + /// Azure Storage Account Name. + /// Azure Storage Account Key. + /// or is null. + public BlobStorageClassTypeProperties(string azureStorageAccountName, string azureStorageAccountKey) + { + Argument.AssertNotNull(azureStorageAccountName, nameof(azureStorageAccountName)); + Argument.AssertNotNull(azureStorageAccountKey, nameof(azureStorageAccountKey)); + + AzureStorageAccountName = azureStorageAccountName; + AzureStorageAccountKey = azureStorageAccountKey; + Type = StorageClassType.Blob; + } + + /// Initializes a new instance of . + /// Type of the storage class. + /// Keeps track of any properties unknown to the library. + /// Azure Storage Account Name. + /// Azure Storage Account Key. + internal BlobStorageClassTypeProperties(StorageClassType type, IDictionary serializedAdditionalRawData, string azureStorageAccountName, string azureStorageAccountKey) : base(type, serializedAdditionalRawData) + { + AzureStorageAccountName = azureStorageAccountName; + AzureStorageAccountKey = azureStorageAccountKey; + Type = type; + } + + /// Initializes a new instance of for deserialization. + internal BlobStorageClassTypeProperties() + { + } + + /// Azure Storage Account Name. + public string AzureStorageAccountName { get; set; } + /// Azure Storage Account Key. + public string AzureStorageAccountKey { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterBgpPeerProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterBgpPeerProperties.Serialization.cs new file mode 100644 index 000000000000..d44c4b53adf0 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterBgpPeerProperties.Serialization.cs @@ -0,0 +1,157 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class ConnectedClusterBgpPeerProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterBgpPeerProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("myAsn"u8); + writer.WriteNumberValue(MyAsn); + writer.WritePropertyName("peerAsn"u8); + writer.WriteNumberValue(PeerAsn); + writer.WritePropertyName("peerAddress"u8); + writer.WriteStringValue(PeerAddress); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + ConnectedClusterBgpPeerProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterBgpPeerProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedClusterBgpPeerProperties(document.RootElement, options); + } + + internal static ConnectedClusterBgpPeerProperties DeserializeConnectedClusterBgpPeerProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int myAsn = default; + int peerAsn = default; + string peerAddress = default; + ContainerOrchestratorProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("myAsn"u8)) + { + myAsn = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("peerAsn"u8)) + { + peerAsn = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("peerAddress"u8)) + { + peerAddress = property.Value.GetString(); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ContainerOrchestratorProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedClusterBgpPeerProperties(myAsn, peerAsn, peerAddress, provisioningState, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedClusterBgpPeerProperties)} does not support writing '{options.Format}' format."); + } + } + + ConnectedClusterBgpPeerProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeConnectedClusterBgpPeerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedClusterBgpPeerProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterBgpPeerProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterBgpPeerProperties.cs new file mode 100644 index 000000000000..7ed798f27d21 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterBgpPeerProperties.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Details of the BgpPeer. + public partial class ConnectedClusterBgpPeerProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// My ASN. + /// Peer ASN. + /// Peer Address. + /// is null. + public ConnectedClusterBgpPeerProperties(int myAsn, int peerAsn, string peerAddress) + { + Argument.AssertNotNull(peerAddress, nameof(peerAddress)); + + MyAsn = myAsn; + PeerAsn = peerAsn; + PeerAddress = peerAddress; + } + + /// Initializes a new instance of . + /// My ASN. + /// Peer ASN. + /// Peer Address. + /// Resource provision state. + /// Keeps track of any properties unknown to the library. + internal ConnectedClusterBgpPeerProperties(int myAsn, int peerAsn, string peerAddress, ContainerOrchestratorProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + MyAsn = myAsn; + PeerAsn = peerAsn; + PeerAddress = peerAddress; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ConnectedClusterBgpPeerProperties() + { + } + + /// My ASN. + public int MyAsn { get; set; } + /// Peer ASN. + public int PeerAsn { get; set; } + /// Peer Address. + public string PeerAddress { get; set; } + /// Resource provision state. + public ContainerOrchestratorProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterLoadBalancerProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterLoadBalancerProperties.Serialization.cs new file mode 100644 index 000000000000..7602382cb022 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterLoadBalancerProperties.Serialization.cs @@ -0,0 +1,216 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class ConnectedClusterLoadBalancerProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterLoadBalancerProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("addresses"u8); + writer.WriteStartArray(); + foreach (var item in Addresses) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(ServiceSelector)) + { + writer.WritePropertyName("serviceSelector"u8); + writer.WriteStartObject(); + foreach (var item in ServiceSelector) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("advertiseMode"u8); + writer.WriteStringValue(AdvertiseMode.ToString()); + if (Optional.IsCollectionDefined(BgpPeers)) + { + writer.WritePropertyName("bgpPeers"u8); + writer.WriteStartArray(); + foreach (var item in BgpPeers) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + ConnectedClusterLoadBalancerProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterLoadBalancerProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedClusterLoadBalancerProperties(document.RootElement, options); + } + + internal static ConnectedClusterLoadBalancerProperties DeserializeConnectedClusterLoadBalancerProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList addresses = default; + IDictionary serviceSelector = default; + AdvertiseMode advertiseMode = default; + IList bgpPeers = default; + ContainerOrchestratorProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("addresses"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + addresses = array; + continue; + } + if (property.NameEquals("serviceSelector"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + serviceSelector = dictionary; + continue; + } + if (property.NameEquals("advertiseMode"u8)) + { + advertiseMode = new AdvertiseMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("bgpPeers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + bgpPeers = array; + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ContainerOrchestratorProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedClusterLoadBalancerProperties( + addresses, + serviceSelector ?? new ChangeTrackingDictionary(), + advertiseMode, + bgpPeers ?? new ChangeTrackingList(), + provisioningState, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedClusterLoadBalancerProperties)} does not support writing '{options.Format}' format."); + } + } + + ConnectedClusterLoadBalancerProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeConnectedClusterLoadBalancerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedClusterLoadBalancerProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterLoadBalancerProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterLoadBalancerProperties.cs new file mode 100644 index 000000000000..97422adba4e1 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterLoadBalancerProperties.cs @@ -0,0 +1,96 @@ +// 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.ContainerOrchestratorRuntime.Models +{ + /// Details of the LoadBalancer. + public partial class ConnectedClusterLoadBalancerProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// IP Range. + /// Advertise Mode. + /// is null. + public ConnectedClusterLoadBalancerProperties(IEnumerable addresses, AdvertiseMode advertiseMode) + { + Argument.AssertNotNull(addresses, nameof(addresses)); + + Addresses = addresses.ToList(); + ServiceSelector = new ChangeTrackingDictionary(); + AdvertiseMode = advertiseMode; + BgpPeers = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// IP Range. + /// A dynamic label mapping to select related services. For instance, if you want to create a load balancer only for services with label "a=b", then please specify {"a": "b"} in the field. + /// Advertise Mode. + /// The list of BGP peers it should advertise to. Null or empty means to advertise to all peers. + /// Resource provision state. + /// Keeps track of any properties unknown to the library. + internal ConnectedClusterLoadBalancerProperties(IList addresses, IDictionary serviceSelector, AdvertiseMode advertiseMode, IList bgpPeers, ContainerOrchestratorProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + Addresses = addresses; + ServiceSelector = serviceSelector; + AdvertiseMode = advertiseMode; + BgpPeers = bgpPeers; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ConnectedClusterLoadBalancerProperties() + { + } + + /// IP Range. + public IList Addresses { get; } + /// A dynamic label mapping to select related services. For instance, if you want to create a load balancer only for services with label "a=b", then please specify {"a": "b"} in the field. + public IDictionary ServiceSelector { get; } + /// Advertise Mode. + public AdvertiseMode AdvertiseMode { get; set; } + /// The list of BGP peers it should advertise to. Null or empty means to advertise to all peers. + public IList BgpPeers { get; } + /// Resource provision state. + public ContainerOrchestratorProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterServiceProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterServiceProperties.Serialization.cs new file mode 100644 index 000000000000..19a211e541f0 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterServiceProperties.Serialization.cs @@ -0,0 +1,148 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class ConnectedClusterServiceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterServiceProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(RpObjectId)) + { + writer.WritePropertyName("rpObjectId"u8); + writer.WriteStringValue(RpObjectId.Value); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + ConnectedClusterServiceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterServiceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedClusterServiceProperties(document.RootElement, options); + } + + internal static ConnectedClusterServiceProperties DeserializeConnectedClusterServiceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Guid? rpObjectId = default; + ContainerOrchestratorProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("rpObjectId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rpObjectId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ContainerOrchestratorProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedClusterServiceProperties(rpObjectId, provisioningState, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedClusterServiceProperties)} does not support writing '{options.Format}' format."); + } + } + + ConnectedClusterServiceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeConnectedClusterServiceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedClusterServiceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterServiceProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterServiceProperties.cs new file mode 100644 index 000000000000..4d8e7debbdcd --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterServiceProperties.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.ContainerOrchestratorRuntime.Models +{ + /// Properties for the service resource. + public partial class ConnectedClusterServiceProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ConnectedClusterServiceProperties() + { + } + + /// Initializes a new instance of . + /// The object id of the service principal of the RP provisioned in the tenant. + /// Resource provision state. + /// Keeps track of any properties unknown to the library. + internal ConnectedClusterServiceProperties(Guid? rpObjectId, ContainerOrchestratorProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + RpObjectId = rpObjectId; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object id of the service principal of the RP provisioned in the tenant. + public Guid? RpObjectId { get; } + /// Resource provision state. + public ContainerOrchestratorProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassPatch.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassPatch.Serialization.cs new file mode 100644 index 000000000000..71da6ee5f3d4 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassPatch.Serialization.cs @@ -0,0 +1,133 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class ConnectedClusterStorageClassPatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassPatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + ConnectedClusterStorageClassPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassPatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedClusterStorageClassPatch(document.RootElement, options); + } + + internal static ConnectedClusterStorageClassPatch DeserializeConnectedClusterStorageClassPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageClassPropertiesUpdate properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = StorageClassPropertiesUpdate.DeserializeStorageClassPropertiesUpdate(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedClusterStorageClassPatch(properties, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassPatch)} does not support writing '{options.Format}' format."); + } + } + + ConnectedClusterStorageClassPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeConnectedClusterStorageClassPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassPatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassPatch.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassPatch.cs new file mode 100644 index 000000000000..fb05d9cbd203 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassPatch.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The model for updating a storageClass. + public partial class ConnectedClusterStorageClassPatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ConnectedClusterStorageClassPatch() + { + } + + /// Initializes a new instance of . + /// The properties of StorageClass. + /// Keeps track of any properties unknown to the library. + internal ConnectedClusterStorageClassPatch(StorageClassPropertiesUpdate properties, IDictionary serializedAdditionalRawData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The properties of StorageClass. + public StorageClassPropertiesUpdate Properties { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassProperties.Serialization.cs new file mode 100644 index 000000000000..85d4caef8688 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassProperties.Serialization.cs @@ -0,0 +1,330 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class ConnectedClusterStorageClassProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AllowVolumeExpansion)) + { + writer.WritePropertyName("allowVolumeExpansion"u8); + writer.WriteStringValue(AllowVolumeExpansion.Value.ToString()); + } + if (Optional.IsCollectionDefined(MountOptions)) + { + writer.WritePropertyName("mountOptions"u8); + writer.WriteStartArray(); + foreach (var item in MountOptions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Provisioner)) + { + writer.WritePropertyName("provisioner"u8); + writer.WriteStringValue(Provisioner); + } + if (Optional.IsDefined(VolumeBindingMode)) + { + writer.WritePropertyName("volumeBindingMode"u8); + writer.WriteStringValue(VolumeBindingMode.Value.ToString()); + } + if (Optional.IsCollectionDefined(AccessModes)) + { + writer.WritePropertyName("accessModes"u8); + writer.WriteStartArray(); + foreach (var item in AccessModes) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(DataResilience)) + { + writer.WritePropertyName("dataResilience"u8); + writer.WriteStringValue(DataResilience.Value.ToString()); + } + if (Optional.IsDefined(FailoverSpeed)) + { + writer.WritePropertyName("failoverSpeed"u8); + writer.WriteStringValue(FailoverSpeed.Value.ToString()); + } + if (Optional.IsCollectionDefined(Limitations)) + { + writer.WritePropertyName("limitations"u8); + writer.WriteStartArray(); + foreach (var item in Limitations) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Performance)) + { + writer.WritePropertyName("performance"u8); + writer.WriteStringValue(Performance.Value.ToString()); + } + if (Optional.IsDefined(Priority)) + { + writer.WritePropertyName("priority"u8); + writer.WriteNumberValue(Priority.Value); + } + writer.WritePropertyName("typeProperties"u8); + writer.WriteObjectValue(TypeProperties, options); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + ConnectedClusterStorageClassProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedClusterStorageClassProperties(document.RootElement, options); + } + + internal static ConnectedClusterStorageClassProperties DeserializeConnectedClusterStorageClassProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VolumeExpansion? allowVolumeExpansion = default; + IList mountOptions = default; + string provisioner = default; + VolumeBindingMode? volumeBindingMode = default; + IList accessModes = default; + DataResilienceTier? dataResilience = default; + FailoverTier? failoverSpeed = default; + IList limitations = default; + PerformanceTier? performance = default; + long? priority = default; + StorageClassTypeProperties typeProperties = default; + ContainerOrchestratorProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("allowVolumeExpansion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + allowVolumeExpansion = new VolumeExpansion(property.Value.GetString()); + continue; + } + if (property.NameEquals("mountOptions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + mountOptions = array; + continue; + } + if (property.NameEquals("provisioner"u8)) + { + provisioner = property.Value.GetString(); + continue; + } + if (property.NameEquals("volumeBindingMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + volumeBindingMode = new VolumeBindingMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("accessModes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new StorageClassAccessMode(item.GetString())); + } + accessModes = array; + continue; + } + if (property.NameEquals("dataResilience"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataResilience = new DataResilienceTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("failoverSpeed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + failoverSpeed = new FailoverTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("limitations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + limitations = array; + continue; + } + if (property.NameEquals("performance"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + performance = new PerformanceTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("priority"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + priority = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("typeProperties"u8)) + { + typeProperties = StorageClassTypeProperties.DeserializeStorageClassTypeProperties(property.Value, options); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ContainerOrchestratorProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedClusterStorageClassProperties( + allowVolumeExpansion, + mountOptions ?? new ChangeTrackingList(), + provisioner, + volumeBindingMode, + accessModes ?? new ChangeTrackingList(), + dataResilience, + failoverSpeed, + limitations ?? new ChangeTrackingList(), + performance, + priority, + typeProperties, + provisioningState, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassProperties)} does not support writing '{options.Format}' format."); + } + } + + ConnectedClusterStorageClassProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeConnectedClusterStorageClassProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedClusterStorageClassProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassProperties.cs new file mode 100644 index 000000000000..38485378322d --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ConnectedClusterStorageClassProperties.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Details of the StorageClass StorageClass. + public partial class ConnectedClusterStorageClassProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// Properties of the StorageClass + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// is null. + public ConnectedClusterStorageClassProperties(StorageClassTypeProperties typeProperties) + { + Argument.AssertNotNull(typeProperties, nameof(typeProperties)); + + MountOptions = new ChangeTrackingList(); + AccessModes = new ChangeTrackingList(); + Limitations = new ChangeTrackingList(); + TypeProperties = typeProperties; + } + + /// Initializes a new instance of . + /// Volume can be expanded or not. + /// Additional mount options. + /// Provisioner name. + /// Binding mode of volumes: Immediate, WaitForFirstConsumer. + /// The access mode: [ReadWriteOnce, ReadWriteMany] or [ReadWriteOnce]. + /// Allow single data node failure. + /// Failover speed: NA, Slow, Fast. + /// Limitations of the storage class. + /// Performance tier. + /// Selection priority when multiple storage classes meet the criteria. 0: Highest, -1: Never use. + /// + /// Properties of the StorageClass + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// Resource provision state. + /// Keeps track of any properties unknown to the library. + internal ConnectedClusterStorageClassProperties(VolumeExpansion? allowVolumeExpansion, IList mountOptions, string provisioner, VolumeBindingMode? volumeBindingMode, IList accessModes, DataResilienceTier? dataResilience, FailoverTier? failoverSpeed, IList limitations, PerformanceTier? performance, long? priority, StorageClassTypeProperties typeProperties, ContainerOrchestratorProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + AllowVolumeExpansion = allowVolumeExpansion; + MountOptions = mountOptions; + Provisioner = provisioner; + VolumeBindingMode = volumeBindingMode; + AccessModes = accessModes; + DataResilience = dataResilience; + FailoverSpeed = failoverSpeed; + Limitations = limitations; + Performance = performance; + Priority = priority; + TypeProperties = typeProperties; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ConnectedClusterStorageClassProperties() + { + } + + /// Volume can be expanded or not. + public VolumeExpansion? AllowVolumeExpansion { get; set; } + /// Additional mount options. + public IList MountOptions { get; } + /// Provisioner name. + public string Provisioner { get; set; } + /// Binding mode of volumes: Immediate, WaitForFirstConsumer. + public VolumeBindingMode? VolumeBindingMode { get; set; } + /// The access mode: [ReadWriteOnce, ReadWriteMany] or [ReadWriteOnce]. + public IList AccessModes { get; } + /// Allow single data node failure. + public DataResilienceTier? DataResilience { get; set; } + /// Failover speed: NA, Slow, Fast. + public FailoverTier? FailoverSpeed { get; set; } + /// Limitations of the storage class. + public IList Limitations { get; } + /// Performance tier. + public PerformanceTier? Performance { get; set; } + /// Selection priority when multiple storage classes meet the criteria. 0: Highest, -1: Never use. + public long? Priority { get; set; } + /// + /// Properties of the StorageClass + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public StorageClassTypeProperties TypeProperties { get; set; } + /// Resource provision state. + public ContainerOrchestratorProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ContainerOrchestratorProvisioningState.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ContainerOrchestratorProvisioningState.cs new file mode 100644 index 000000000000..4fd15f8768c8 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ContainerOrchestratorProvisioningState.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The status of the current operation. + public readonly partial struct ContainerOrchestratorProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ContainerOrchestratorProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string ProvisioningValue = "Provisioning"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string AcceptedValue = "Accepted"; + + /// Resource has been created. + public static ContainerOrchestratorProvisioningState Succeeded { get; } = new ContainerOrchestratorProvisioningState(SucceededValue); + /// Resource creation failed. + public static ContainerOrchestratorProvisioningState Failed { get; } = new ContainerOrchestratorProvisioningState(FailedValue); + /// Resource creation was canceled. + public static ContainerOrchestratorProvisioningState Canceled { get; } = new ContainerOrchestratorProvisioningState(CanceledValue); + /// Initial provisioning in progress. + public static ContainerOrchestratorProvisioningState Provisioning { get; } = new ContainerOrchestratorProvisioningState(ProvisioningValue); + /// Update in progress. + public static ContainerOrchestratorProvisioningState Updating { get; } = new ContainerOrchestratorProvisioningState(UpdatingValue); + /// Deletion in progress. + public static ContainerOrchestratorProvisioningState Deleting { get; } = new ContainerOrchestratorProvisioningState(DeletingValue); + /// Change accepted for processing. + public static ContainerOrchestratorProvisioningState Accepted { get; } = new ContainerOrchestratorProvisioningState(AcceptedValue); + /// Determines if two values are the same. + public static bool operator ==(ContainerOrchestratorProvisioningState left, ContainerOrchestratorProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ContainerOrchestratorProvisioningState left, ContainerOrchestratorProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ContainerOrchestratorProvisioningState(string value) => new ContainerOrchestratorProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContainerOrchestratorProvisioningState other && Equals(other); + /// + public bool Equals(ContainerOrchestratorProvisioningState 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/DataResilienceTier.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/DataResilienceTier.cs new file mode 100644 index 000000000000..cf1e7d79602e --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/DataResilienceTier.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Data resilience tier of a storage class. + public readonly partial struct DataResilienceTier : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataResilienceTier(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotDataResilientValue = "NotDataResilient"; + private const string DataResilientValue = "DataResilient"; + + /// Not data resilient. + public static DataResilienceTier NotDataResilient { get; } = new DataResilienceTier(NotDataResilientValue); + /// Data resilient. + public static DataResilienceTier DataResilient { get; } = new DataResilienceTier(DataResilientValue); + /// Determines if two values are the same. + public static bool operator ==(DataResilienceTier left, DataResilienceTier right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataResilienceTier left, DataResilienceTier right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DataResilienceTier(string value) => new DataResilienceTier(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataResilienceTier other && Equals(other); + /// + public bool Equals(DataResilienceTier 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/FailoverTier.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/FailoverTier.cs new file mode 100644 index 000000000000..33a052ba1c05 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/FailoverTier.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Failover tier of a storage class. + public readonly partial struct FailoverTier : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FailoverTier(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotAvailableValue = "NotAvailable"; + private const string SlowValue = "Slow"; + private const string FastValue = "Fast"; + private const string SuperValue = "Super"; + + /// Not available Failover Tier. + public static FailoverTier NotAvailable { get; } = new FailoverTier(NotAvailableValue); + /// Slow Failover Tier. + public static FailoverTier Slow { get; } = new FailoverTier(SlowValue); + /// Fast Failover Tier. + public static FailoverTier Fast { get; } = new FailoverTier(FastValue); + /// Super Failover Tier. + public static FailoverTier Super { get; } = new FailoverTier(SuperValue); + /// Determines if two values are the same. + public static bool operator ==(FailoverTier left, FailoverTier right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FailoverTier left, FailoverTier right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FailoverTier(string value) => new FailoverTier(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FailoverTier other && Equals(other); + /// + public bool Equals(FailoverTier 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/LoadBalancerListResult.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/LoadBalancerListResult.Serialization.cs new file mode 100644 index 000000000000..7c24e3ae2066 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/LoadBalancerListResult.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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + internal partial class LoadBalancerListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LoadBalancerListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + LoadBalancerListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LoadBalancerListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLoadBalancerListResult(document.RootElement, options); + } + + internal static LoadBalancerListResult DeserializeLoadBalancerListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ConnectedClusterLoadBalancerData.DeserializeConnectedClusterLoadBalancerData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LoadBalancerListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(LoadBalancerListResult)} does not support writing '{options.Format}' format."); + } + } + + LoadBalancerListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeLoadBalancerListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LoadBalancerListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/LoadBalancerListResult.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/LoadBalancerListResult.cs new file mode 100644 index 000000000000..57c5985deef7 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/LoadBalancerListResult.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 System.Linq; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The response of a LoadBalancer list operation. + internal partial class LoadBalancerListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The LoadBalancer items on this page. + /// is null. + internal LoadBalancerListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The LoadBalancer items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal LoadBalancerListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal LoadBalancerListResult() + { + } + + /// The LoadBalancer items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NativeStorageClassTypeProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NativeStorageClassTypeProperties.Serialization.cs new file mode 100644 index 000000000000..67cfac9d571b --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NativeStorageClassTypeProperties.Serialization.cs @@ -0,0 +1,110 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class NativeStorageClassTypeProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NativeStorageClassTypeProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + NativeStorageClassTypeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NativeStorageClassTypeProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNativeStorageClassTypeProperties(document.RootElement, options); + } + + internal static NativeStorageClassTypeProperties DeserializeNativeStorageClassTypeProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageClassType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new StorageClassType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NativeStorageClassTypeProperties(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NativeStorageClassTypeProperties)} does not support writing '{options.Format}' format."); + } + } + + NativeStorageClassTypeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNativeStorageClassTypeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NativeStorageClassTypeProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NativeStorageClassTypeProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NativeStorageClassTypeProperties.cs new file mode 100644 index 000000000000..77801f1345e7 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NativeStorageClassTypeProperties.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The properties of Native StorageClass. + public partial class NativeStorageClassTypeProperties : StorageClassTypeProperties + { + /// Initializes a new instance of . + public NativeStorageClassTypeProperties() + { + Type = StorageClassType.Native; + } + + /// Initializes a new instance of . + /// Type of the storage class. + /// Keeps track of any properties unknown to the library. + internal NativeStorageClassTypeProperties(StorageClassType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + Type = type; + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NfsDirectoryActionOnVolumeDeletion.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NfsDirectoryActionOnVolumeDeletion.cs new file mode 100644 index 000000000000..050175aeb6fb --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NfsDirectoryActionOnVolumeDeletion.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The action to take when a NFS volume is deleted. + public readonly partial struct NfsDirectoryActionOnVolumeDeletion : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NfsDirectoryActionOnVolumeDeletion(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DeleteValue = "Delete"; + private const string RetainValue = "Retain"; + + /// When the volume is deleted, delete the directory. + public static NfsDirectoryActionOnVolumeDeletion Delete { get; } = new NfsDirectoryActionOnVolumeDeletion(DeleteValue); + /// When the volume is deleted, retain the directory. + public static NfsDirectoryActionOnVolumeDeletion Retain { get; } = new NfsDirectoryActionOnVolumeDeletion(RetainValue); + /// Determines if two values are the same. + public static bool operator ==(NfsDirectoryActionOnVolumeDeletion left, NfsDirectoryActionOnVolumeDeletion right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NfsDirectoryActionOnVolumeDeletion left, NfsDirectoryActionOnVolumeDeletion right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NfsDirectoryActionOnVolumeDeletion(string value) => new NfsDirectoryActionOnVolumeDeletion(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NfsDirectoryActionOnVolumeDeletion other && Equals(other); + /// + public bool Equals(NfsDirectoryActionOnVolumeDeletion 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NfsStorageClassTypeProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NfsStorageClassTypeProperties.Serialization.cs new file mode 100644 index 000000000000..084d515f71fa --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NfsStorageClassTypeProperties.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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class NfsStorageClassTypeProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NfsStorageClassTypeProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server"u8); + writer.WriteStringValue(Server); + writer.WritePropertyName("share"u8); + writer.WriteStringValue(Share); + if (Optional.IsDefined(SubDir)) + { + writer.WritePropertyName("subDir"u8); + writer.WriteStringValue(SubDir); + } + if (Optional.IsDefined(MountPermissions)) + { + writer.WritePropertyName("mountPermissions"u8); + writer.WriteStringValue(MountPermissions); + } + if (Optional.IsDefined(OnDelete)) + { + writer.WritePropertyName("onDelete"u8); + writer.WriteStringValue(OnDelete.Value.ToString()); + } + } + + NfsStorageClassTypeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NfsStorageClassTypeProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNfsStorageClassTypeProperties(document.RootElement, options); + } + + internal static NfsStorageClassTypeProperties DeserializeNfsStorageClassTypeProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string server = default; + string share = default; + string subDir = default; + string mountPermissions = default; + NfsDirectoryActionOnVolumeDeletion? onDelete = default; + StorageClassType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("server"u8)) + { + server = property.Value.GetString(); + continue; + } + if (property.NameEquals("share"u8)) + { + share = property.Value.GetString(); + continue; + } + if (property.NameEquals("subDir"u8)) + { + subDir = property.Value.GetString(); + continue; + } + if (property.NameEquals("mountPermissions"u8)) + { + mountPermissions = property.Value.GetString(); + continue; + } + if (property.NameEquals("onDelete"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + onDelete = new NfsDirectoryActionOnVolumeDeletion(property.Value.GetString()); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new StorageClassType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NfsStorageClassTypeProperties( + type, + serializedAdditionalRawData, + server, + share, + subDir, + mountPermissions, + onDelete); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NfsStorageClassTypeProperties)} does not support writing '{options.Format}' format."); + } + } + + NfsStorageClassTypeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNfsStorageClassTypeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NfsStorageClassTypeProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NfsStorageClassTypeProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NfsStorageClassTypeProperties.cs new file mode 100644 index 000000000000..76deccf83be2 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/NfsStorageClassTypeProperties.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The properties of NFS StorageClass. + public partial class NfsStorageClassTypeProperties : StorageClassTypeProperties + { + /// Initializes a new instance of . + /// NFS Server. + /// NFS share. + /// or is null. + public NfsStorageClassTypeProperties(string server, string share) + { + Argument.AssertNotNull(server, nameof(server)); + Argument.AssertNotNull(share, nameof(share)); + + Server = server; + Share = share; + Type = StorageClassType.Nfs; + } + + /// Initializes a new instance of . + /// Type of the storage class. + /// Keeps track of any properties unknown to the library. + /// NFS Server. + /// NFS share. + /// Sub directory under share. If the sub directory doesn't exist, driver will create it. + /// Mounted folder permissions. Default is 0. If set as non-zero, driver will perform `chmod` after mount. + /// The action to take when a NFS volume is deleted. Default is Delete. + internal NfsStorageClassTypeProperties(StorageClassType type, IDictionary serializedAdditionalRawData, string server, string share, string subDir, string mountPermissions, NfsDirectoryActionOnVolumeDeletion? onDelete) : base(type, serializedAdditionalRawData) + { + Server = server; + Share = share; + SubDir = subDir; + MountPermissions = mountPermissions; + OnDelete = onDelete; + Type = type; + } + + /// Initializes a new instance of for deserialization. + internal NfsStorageClassTypeProperties() + { + } + + /// NFS Server. + public string Server { get; set; } + /// NFS share. + public string Share { get; set; } + /// Sub directory under share. If the sub directory doesn't exist, driver will create it. + public string SubDir { get; set; } + /// Mounted folder permissions. Default is 0. If set as non-zero, driver will perform `chmod` after mount. + public string MountPermissions { get; set; } + /// The action to take when a NFS volume is deleted. Default is Delete. + public NfsDirectoryActionOnVolumeDeletion? OnDelete { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/PerformanceTier.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/PerformanceTier.cs new file mode 100644 index 000000000000..f99d4a63a4e4 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/PerformanceTier.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Performance tier of a storage class. + public readonly partial struct PerformanceTier : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PerformanceTier(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UndefinedValue = "Undefined"; + private const string BasicValue = "Basic"; + private const string StandardValue = "Standard"; + private const string PremiumValue = "Premium"; + private const string UltraValue = "Ultra"; + + /// Undefined Performance Tier. + public static PerformanceTier Undefined { get; } = new PerformanceTier(UndefinedValue); + /// Basic Performance Tier. + public static PerformanceTier Basic { get; } = new PerformanceTier(BasicValue); + /// Standard Performance Tier. + public static PerformanceTier Standard { get; } = new PerformanceTier(StandardValue); + /// Premium Performance Tier. + public static PerformanceTier Premium { get; } = new PerformanceTier(PremiumValue); + /// Ultra Performance Tier. + public static PerformanceTier Ultra { get; } = new PerformanceTier(UltraValue); + /// Determines if two values are the same. + public static bool operator ==(PerformanceTier left, PerformanceTier right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PerformanceTier left, PerformanceTier right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PerformanceTier(string value) => new PerformanceTier(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PerformanceTier other && Equals(other); + /// + public bool Equals(PerformanceTier 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/RwxStorageClassTypeProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/RwxStorageClassTypeProperties.Serialization.cs new file mode 100644 index 000000000000..d4dc04ffd042 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/RwxStorageClassTypeProperties.Serialization.cs @@ -0,0 +1,118 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class RwxStorageClassTypeProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RwxStorageClassTypeProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("backingStorageClassName"u8); + writer.WriteStringValue(BackingStorageClassName); + } + + RwxStorageClassTypeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RwxStorageClassTypeProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRwxStorageClassTypeProperties(document.RootElement, options); + } + + internal static RwxStorageClassTypeProperties DeserializeRwxStorageClassTypeProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string backingStorageClassName = default; + StorageClassType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("backingStorageClassName"u8)) + { + backingStorageClassName = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new StorageClassType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RwxStorageClassTypeProperties(type, serializedAdditionalRawData, backingStorageClassName); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RwxStorageClassTypeProperties)} does not support writing '{options.Format}' format."); + } + } + + RwxStorageClassTypeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRwxStorageClassTypeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RwxStorageClassTypeProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/RwxStorageClassTypeProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/RwxStorageClassTypeProperties.cs new file mode 100644 index 000000000000..265f0aa0cab1 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/RwxStorageClassTypeProperties.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.ContainerOrchestratorRuntime.Models +{ + /// The properties of RWX StorageClass. + public partial class RwxStorageClassTypeProperties : StorageClassTypeProperties + { + /// Initializes a new instance of . + /// The backing storageclass used to create new storageclass. + /// is null. + public RwxStorageClassTypeProperties(string backingStorageClassName) + { + Argument.AssertNotNull(backingStorageClassName, nameof(backingStorageClassName)); + + BackingStorageClassName = backingStorageClassName; + Type = StorageClassType.Rwx; + } + + /// Initializes a new instance of . + /// Type of the storage class. + /// Keeps track of any properties unknown to the library. + /// The backing storageclass used to create new storageclass. + internal RwxStorageClassTypeProperties(StorageClassType type, IDictionary serializedAdditionalRawData, string backingStorageClassName) : base(type, serializedAdditionalRawData) + { + BackingStorageClassName = backingStorageClassName; + Type = type; + } + + /// Initializes a new instance of for deserialization. + internal RwxStorageClassTypeProperties() + { + } + + /// The backing storageclass used to create new storageclass. + public string BackingStorageClassName { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ServiceResourceListResult.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ServiceResourceListResult.Serialization.cs new file mode 100644 index 000000000000..e3fb2428249c --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ServiceResourceListResult.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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + internal partial class ServiceResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ServiceResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + ServiceResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ServiceResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeServiceResourceListResult(document.RootElement, options); + } + + internal static ServiceResourceListResult DeserializeServiceResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ConnectedClusterServiceData.DeserializeConnectedClusterServiceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ServiceResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ServiceResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + ServiceResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeServiceResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ServiceResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ServiceResourceListResult.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ServiceResourceListResult.cs new file mode 100644 index 000000000000..76bf3d695cb9 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/ServiceResourceListResult.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 System.Linq; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The response of a ServiceResource list operation. + internal partial class ServiceResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ServiceResource items on this page. + /// is null. + internal ServiceResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The ServiceResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal ServiceResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ServiceResourceListResult() + { + } + + /// The ServiceResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/SmbStorageClassTypeProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/SmbStorageClassTypeProperties.Serialization.cs new file mode 100644 index 000000000000..876ea6397191 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/SmbStorageClassTypeProperties.Serialization.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class SmbStorageClassTypeProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SmbStorageClassTypeProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + if (Optional.IsDefined(SubDir)) + { + writer.WritePropertyName("subDir"u8); + writer.WriteStringValue(SubDir); + } + if (Optional.IsDefined(Username)) + { + writer.WritePropertyName("username"u8); + writer.WriteStringValue(Username); + } + if (Optional.IsDefined(Password)) + { + writer.WritePropertyName("password"u8); + writer.WriteStringValue(Password); + } + if (Optional.IsDefined(Domain)) + { + writer.WritePropertyName("domain"u8); + writer.WriteStringValue(Domain); + } + } + + SmbStorageClassTypeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SmbStorageClassTypeProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSmbStorageClassTypeProperties(document.RootElement, options); + } + + internal static SmbStorageClassTypeProperties DeserializeSmbStorageClassTypeProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string source = default; + string subDir = default; + string username = default; + string password = default; + string domain = default; + StorageClassType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("subDir"u8)) + { + subDir = property.Value.GetString(); + continue; + } + if (property.NameEquals("username"u8)) + { + username = property.Value.GetString(); + continue; + } + if (property.NameEquals("password"u8)) + { + password = property.Value.GetString(); + continue; + } + if (property.NameEquals("domain"u8)) + { + domain = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new StorageClassType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SmbStorageClassTypeProperties( + type, + serializedAdditionalRawData, + source, + subDir, + username, + password, + domain); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SmbStorageClassTypeProperties)} does not support writing '{options.Format}' format."); + } + } + + SmbStorageClassTypeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSmbStorageClassTypeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SmbStorageClassTypeProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/SmbStorageClassTypeProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/SmbStorageClassTypeProperties.cs new file mode 100644 index 000000000000..e9b94101fd7d --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/SmbStorageClassTypeProperties.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The properties of SMB StorageClass. + public partial class SmbStorageClassTypeProperties : StorageClassTypeProperties + { + /// Initializes a new instance of . + /// SMB Source. + /// is null. + public SmbStorageClassTypeProperties(string source) + { + Argument.AssertNotNull(source, nameof(source)); + + Source = source; + Type = StorageClassType.Smb; + } + + /// Initializes a new instance of . + /// Type of the storage class. + /// Keeps track of any properties unknown to the library. + /// SMB Source. + /// Sub directory under share. If the sub directory doesn't exist, driver will create it. + /// Server username. + /// Server password. + /// Server domain. + internal SmbStorageClassTypeProperties(StorageClassType type, IDictionary serializedAdditionalRawData, string source, string subDir, string username, string password, string domain) : base(type, serializedAdditionalRawData) + { + Source = source; + SubDir = subDir; + Username = username; + Password = password; + Domain = domain; + Type = type; + } + + /// Initializes a new instance of for deserialization. + internal SmbStorageClassTypeProperties() + { + } + + /// SMB Source. + public string Source { get; set; } + /// Sub directory under share. If the sub directory doesn't exist, driver will create it. + public string SubDir { get; set; } + /// Server username. + public string Username { get; set; } + /// Server password. + public string Password { get; set; } + /// Server domain. + public string Domain { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassAccessMode.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassAccessMode.cs new file mode 100644 index 000000000000..a05429209c06 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassAccessMode.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Storage Class Access Mode. + public readonly partial struct StorageClassAccessMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public StorageClassAccessMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ReadWriteOnceValue = "ReadWriteOnce"; + private const string ReadWriteManyValue = "ReadWriteMany"; + + /// Read Write Once (RWO) access mode. + public static StorageClassAccessMode ReadWriteOnce { get; } = new StorageClassAccessMode(ReadWriteOnceValue); + /// Read Write Many (RWX) access mode. + public static StorageClassAccessMode ReadWriteMany { get; } = new StorageClassAccessMode(ReadWriteManyValue); + /// Determines if two values are the same. + public static bool operator ==(StorageClassAccessMode left, StorageClassAccessMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(StorageClassAccessMode left, StorageClassAccessMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator StorageClassAccessMode(string value) => new StorageClassAccessMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StorageClassAccessMode other && Equals(other); + /// + public bool Equals(StorageClassAccessMode 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassPropertiesUpdate.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassPropertiesUpdate.Serialization.cs new file mode 100644 index 000000000000..c612c0c1aa79 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassPropertiesUpdate.Serialization.cs @@ -0,0 +1,293 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class StorageClassPropertiesUpdate : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassPropertiesUpdate)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AllowVolumeExpansion)) + { + writer.WritePropertyName("allowVolumeExpansion"u8); + writer.WriteStringValue(AllowVolumeExpansion.Value.ToString()); + } + if (Optional.IsCollectionDefined(MountOptions)) + { + writer.WritePropertyName("mountOptions"u8); + writer.WriteStartArray(); + foreach (var item in MountOptions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AccessModes)) + { + writer.WritePropertyName("accessModes"u8); + writer.WriteStartArray(); + foreach (var item in AccessModes) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(DataResilience)) + { + writer.WritePropertyName("dataResilience"u8); + writer.WriteStringValue(DataResilience.Value.ToString()); + } + if (Optional.IsDefined(FailoverSpeed)) + { + writer.WritePropertyName("failoverSpeed"u8); + writer.WriteStringValue(FailoverSpeed.Value.ToString()); + } + if (Optional.IsCollectionDefined(Limitations)) + { + writer.WritePropertyName("limitations"u8); + writer.WriteStartArray(); + foreach (var item in Limitations) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Performance)) + { + writer.WritePropertyName("performance"u8); + writer.WriteStringValue(Performance.Value.ToString()); + } + if (Optional.IsDefined(Priority)) + { + writer.WritePropertyName("priority"u8); + writer.WriteNumberValue(Priority.Value); + } + if (Optional.IsDefined(TypeProperties)) + { + writer.WritePropertyName("typeProperties"u8); + writer.WriteObjectValue(TypeProperties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + StorageClassPropertiesUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassPropertiesUpdate)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageClassPropertiesUpdate(document.RootElement, options); + } + + internal static StorageClassPropertiesUpdate DeserializeStorageClassPropertiesUpdate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VolumeExpansion? allowVolumeExpansion = default; + IList mountOptions = default; + IList accessModes = default; + DataResilienceTier? dataResilience = default; + FailoverTier? failoverSpeed = default; + IList limitations = default; + PerformanceTier? performance = default; + long? priority = default; + StorageClassTypePropertiesUpdate typeProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("allowVolumeExpansion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + allowVolumeExpansion = new VolumeExpansion(property.Value.GetString()); + continue; + } + if (property.NameEquals("mountOptions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + mountOptions = array; + continue; + } + if (property.NameEquals("accessModes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new StorageClassAccessMode(item.GetString())); + } + accessModes = array; + continue; + } + if (property.NameEquals("dataResilience"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataResilience = new DataResilienceTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("failoverSpeed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + failoverSpeed = new FailoverTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("limitations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + limitations = array; + continue; + } + if (property.NameEquals("performance"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + performance = new PerformanceTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("priority"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + priority = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("typeProperties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + typeProperties = StorageClassTypePropertiesUpdate.DeserializeStorageClassTypePropertiesUpdate(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StorageClassPropertiesUpdate( + allowVolumeExpansion, + mountOptions ?? new ChangeTrackingList(), + accessModes ?? new ChangeTrackingList(), + dataResilience, + failoverSpeed, + limitations ?? new ChangeTrackingList(), + performance, + priority, + typeProperties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StorageClassPropertiesUpdate)} does not support writing '{options.Format}' format."); + } + } + + StorageClassPropertiesUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStorageClassPropertiesUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageClassPropertiesUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassPropertiesUpdate.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassPropertiesUpdate.cs new file mode 100644 index 000000000000..16e8bfd14f42 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassPropertiesUpdate.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The model for updating storageClass properties. + public partial class StorageClassPropertiesUpdate + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public StorageClassPropertiesUpdate() + { + MountOptions = new ChangeTrackingList(); + AccessModes = new ChangeTrackingList(); + Limitations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Volume can be expanded or not. + /// Additional mount options. + /// The access mode: [ReadWriteOnce, ReadWriteMany] or [ReadWriteOnce]. + /// Allow single data node failure. + /// Failover speed: NA, Slow, Fast. + /// Limitations of the storage class. + /// Performance tier. + /// Selection priority when multiple storage classes meet the criteria. 0: Highest, -1: Never use. + /// New storage class type of storageClass. + /// Keeps track of any properties unknown to the library. + internal StorageClassPropertiesUpdate(VolumeExpansion? allowVolumeExpansion, IList mountOptions, IList accessModes, DataResilienceTier? dataResilience, FailoverTier? failoverSpeed, IList limitations, PerformanceTier? performance, long? priority, StorageClassTypePropertiesUpdate typeProperties, IDictionary serializedAdditionalRawData) + { + AllowVolumeExpansion = allowVolumeExpansion; + MountOptions = mountOptions; + AccessModes = accessModes; + DataResilience = dataResilience; + FailoverSpeed = failoverSpeed; + Limitations = limitations; + Performance = performance; + Priority = priority; + TypeProperties = typeProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Volume can be expanded or not. + public VolumeExpansion? AllowVolumeExpansion { get; set; } + /// Additional mount options. + public IList MountOptions { get; } + /// The access mode: [ReadWriteOnce, ReadWriteMany] or [ReadWriteOnce]. + public IList AccessModes { get; } + /// Allow single data node failure. + public DataResilienceTier? DataResilience { get; set; } + /// Failover speed: NA, Slow, Fast. + public FailoverTier? FailoverSpeed { get; set; } + /// Limitations of the storage class. + public IList Limitations { get; } + /// Performance tier. + public PerformanceTier? Performance { get; set; } + /// Selection priority when multiple storage classes meet the criteria. 0: Highest, -1: Never use. + public long? Priority { get; set; } + /// New storage class type of storageClass. + public StorageClassTypePropertiesUpdate TypeProperties { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassResourceListResult.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassResourceListResult.Serialization.cs new file mode 100644 index 000000000000..0a06507b9e20 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassResourceListResult.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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + internal partial class StorageClassResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + StorageClassResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageClassResourceListResult(document.RootElement, options); + } + + internal static StorageClassResourceListResult DeserializeStorageClassResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ConnectedClusterStorageClassData.DeserializeConnectedClusterStorageClassData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StorageClassResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StorageClassResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + StorageClassResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStorageClassResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageClassResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassResourceListResult.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassResourceListResult.cs new file mode 100644 index 000000000000..3b009ba86c99 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassResourceListResult.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 System.Linq; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The response of a StorageClassResource list operation. + internal partial class StorageClassResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The StorageClassResource items on this page. + /// is null. + internal StorageClassResourceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The StorageClassResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal StorageClassResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal StorageClassResourceListResult() + { + } + + /// The StorageClassResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassType.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassType.cs new file mode 100644 index 000000000000..ceee73733c39 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassType.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Type of a storage class. + internal readonly partial struct StorageClassType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public StorageClassType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NativeValue = "Native"; + private const string RwxValue = "RWX"; + private const string BlobValue = "Blob"; + private const string NfsValue = "NFS"; + private const string SmbValue = "SMB"; + + /// Native storage class. + public static StorageClassType Native { get; } = new StorageClassType(NativeValue); + /// RWX storage class. + public static StorageClassType Rwx { get; } = new StorageClassType(RwxValue); + /// Blob storage class. + public static StorageClassType Blob { get; } = new StorageClassType(BlobValue); + /// NFS storage class. + public static StorageClassType Nfs { get; } = new StorageClassType(NfsValue); + /// SMB storage class. + public static StorageClassType Smb { get; } = new StorageClassType(SmbValue); + /// Determines if two values are the same. + public static bool operator ==(StorageClassType left, StorageClassType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(StorageClassType left, StorageClassType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator StorageClassType(string value) => new StorageClassType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StorageClassType other && Equals(other); + /// + public bool Equals(StorageClassType 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypeProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypeProperties.Serialization.cs new file mode 100644 index 000000000000..172388b6b1cf --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypeProperties.Serialization.cs @@ -0,0 +1,121 @@ +// 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.Core; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + [PersistableModelProxy(typeof(UnknownStorageClassTypeProperties))] + public partial class StorageClassTypeProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassTypeProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + StorageClassTypeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassTypeProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageClassTypeProperties(document.RootElement, options); + } + + internal static StorageClassTypeProperties DeserializeStorageClassTypeProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Blob": return BlobStorageClassTypeProperties.DeserializeBlobStorageClassTypeProperties(element, options); + case "Native": return NativeStorageClassTypeProperties.DeserializeNativeStorageClassTypeProperties(element, options); + case "NFS": return NfsStorageClassTypeProperties.DeserializeNfsStorageClassTypeProperties(element, options); + case "RWX": return RwxStorageClassTypeProperties.DeserializeRwxStorageClassTypeProperties(element, options); + case "SMB": return SmbStorageClassTypeProperties.DeserializeSmbStorageClassTypeProperties(element, options); + } + } + return UnknownStorageClassTypeProperties.DeserializeUnknownStorageClassTypeProperties(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StorageClassTypeProperties)} does not support writing '{options.Format}' format."); + } + } + + StorageClassTypeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStorageClassTypeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageClassTypeProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypeProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypeProperties.cs new file mode 100644 index 000000000000..209dff83e7a4 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypeProperties.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.ContainerOrchestratorRuntime.Models +{ + /// + /// The properties of storage class of the StorageClass + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public abstract partial class StorageClassTypeProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected StorageClassTypeProperties() + { + } + + /// Initializes a new instance of . + /// Type of the storage class. + /// Keeps track of any properties unknown to the library. + internal StorageClassTypeProperties(StorageClassType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Type of the storage class. + internal StorageClassType Type { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypePropertiesUpdate.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypePropertiesUpdate.Serialization.cs new file mode 100644 index 000000000000..9e968b675a04 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypePropertiesUpdate.Serialization.cs @@ -0,0 +1,267 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + public partial class StorageClassTypePropertiesUpdate : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassTypePropertiesUpdate)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(BackingStorageClassName)) + { + writer.WritePropertyName("backingStorageClassName"u8); + writer.WriteStringValue(BackingStorageClassName); + } + if (Optional.IsDefined(AzureStorageAccountName)) + { + writer.WritePropertyName("azureStorageAccountName"u8); + writer.WriteStringValue(AzureStorageAccountName); + } + if (Optional.IsDefined(AzureStorageAccountKey)) + { + writer.WritePropertyName("azureStorageAccountKey"u8); + writer.WriteStringValue(AzureStorageAccountKey); + } + if (Optional.IsDefined(Server)) + { + writer.WritePropertyName("server"u8); + writer.WriteStringValue(Server); + } + if (Optional.IsDefined(Share)) + { + writer.WritePropertyName("share"u8); + writer.WriteStringValue(Share); + } + if (Optional.IsDefined(SubDir)) + { + writer.WritePropertyName("subDir"u8); + writer.WriteStringValue(SubDir); + } + if (Optional.IsDefined(MountPermissions)) + { + writer.WritePropertyName("mountPermissions"u8); + writer.WriteStringValue(MountPermissions); + } + if (Optional.IsDefined(OnDelete)) + { + writer.WritePropertyName("onDelete"u8); + writer.WriteStringValue(OnDelete.Value.ToString()); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsDefined(Username)) + { + writer.WritePropertyName("username"u8); + writer.WriteStringValue(Username); + } + if (Optional.IsDefined(Password)) + { + writer.WritePropertyName("password"u8); + writer.WriteStringValue(Password); + } + if (Optional.IsDefined(Domain)) + { + writer.WritePropertyName("domain"u8); + writer.WriteStringValue(Domain); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + 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 + } + } + } + + StorageClassTypePropertiesUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassTypePropertiesUpdate)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageClassTypePropertiesUpdate(document.RootElement, options); + } + + internal static StorageClassTypePropertiesUpdate DeserializeStorageClassTypePropertiesUpdate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string backingStorageClassName = default; + string azureStorageAccountName = default; + string azureStorageAccountKey = default; + string server = default; + string share = default; + string subDir = default; + string mountPermissions = default; + NfsDirectoryActionOnVolumeDeletion? onDelete = default; + string source = default; + string username = default; + string password = default; + string domain = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("backingStorageClassName"u8)) + { + backingStorageClassName = property.Value.GetString(); + continue; + } + if (property.NameEquals("azureStorageAccountName"u8)) + { + azureStorageAccountName = property.Value.GetString(); + continue; + } + if (property.NameEquals("azureStorageAccountKey"u8)) + { + azureStorageAccountKey = property.Value.GetString(); + continue; + } + if (property.NameEquals("server"u8)) + { + server = property.Value.GetString(); + continue; + } + if (property.NameEquals("share"u8)) + { + share = property.Value.GetString(); + continue; + } + if (property.NameEquals("subDir"u8)) + { + subDir = property.Value.GetString(); + continue; + } + if (property.NameEquals("mountPermissions"u8)) + { + mountPermissions = property.Value.GetString(); + continue; + } + if (property.NameEquals("onDelete"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + onDelete = new NfsDirectoryActionOnVolumeDeletion(property.Value.GetString()); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("username"u8)) + { + username = property.Value.GetString(); + continue; + } + if (property.NameEquals("password"u8)) + { + password = property.Value.GetString(); + continue; + } + if (property.NameEquals("domain"u8)) + { + domain = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StorageClassTypePropertiesUpdate( + backingStorageClassName, + azureStorageAccountName, + azureStorageAccountKey, + server, + share, + subDir, + mountPermissions, + onDelete, + source, + username, + password, + domain, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StorageClassTypePropertiesUpdate)} does not support writing '{options.Format}' format."); + } + } + + StorageClassTypePropertiesUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStorageClassTypePropertiesUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageClassTypePropertiesUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypePropertiesUpdate.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypePropertiesUpdate.cs new file mode 100644 index 000000000000..8a5687727b18 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/StorageClassTypePropertiesUpdate.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// The model for update a storageClass. + public partial class StorageClassTypePropertiesUpdate + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public StorageClassTypePropertiesUpdate() + { + } + + /// Initializes a new instance of . + /// The backing storageclass used to create new storageclass. + /// Azure Storage Account Name. + /// Azure Storage Account Key. + /// NFS Server. + /// NFS share. + /// Sub directory under share. If the sub directory doesn't exist, driver will create it. + /// Mounted folder permissions. Default is 0. If set as non-zero, driver will perform `chmod` after mount. + /// The action to take when a NFS volume is deleted. Default is Delete. + /// SMB Source. + /// Server username. + /// Server password. + /// Server domain. + /// Keeps track of any properties unknown to the library. + internal StorageClassTypePropertiesUpdate(string backingStorageClassName, string azureStorageAccountName, string azureStorageAccountKey, string server, string share, string subDir, string mountPermissions, NfsDirectoryActionOnVolumeDeletion? onDelete, string source, string username, string password, string domain, IDictionary serializedAdditionalRawData) + { + BackingStorageClassName = backingStorageClassName; + AzureStorageAccountName = azureStorageAccountName; + AzureStorageAccountKey = azureStorageAccountKey; + Server = server; + Share = share; + SubDir = subDir; + MountPermissions = mountPermissions; + OnDelete = onDelete; + Source = source; + Username = username; + Password = password; + Domain = domain; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The backing storageclass used to create new storageclass. + public string BackingStorageClassName { get; set; } + /// Azure Storage Account Name. + public string AzureStorageAccountName { get; set; } + /// Azure Storage Account Key. + public string AzureStorageAccountKey { get; set; } + /// NFS Server. + public string Server { get; set; } + /// NFS share. + public string Share { get; set; } + /// Sub directory under share. If the sub directory doesn't exist, driver will create it. + public string SubDir { get; set; } + /// Mounted folder permissions. Default is 0. If set as non-zero, driver will perform `chmod` after mount. + public string MountPermissions { get; set; } + /// The action to take when a NFS volume is deleted. Default is Delete. + public NfsDirectoryActionOnVolumeDeletion? OnDelete { get; set; } + /// SMB Source. + public string Source { get; set; } + /// Server username. + public string Username { get; set; } + /// Server password. + public string Password { get; set; } + /// Server domain. + public string Domain { get; set; } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/UnknownStorageClassTypeProperties.Serialization.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/UnknownStorageClassTypeProperties.Serialization.cs new file mode 100644 index 000000000000..7c6b92fe8ef5 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/UnknownStorageClassTypeProperties.Serialization.cs @@ -0,0 +1,110 @@ +// 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; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + internal partial class UnknownStorageClassTypeProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassTypeProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + StorageClassTypeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StorageClassTypeProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStorageClassTypeProperties(document.RootElement, options); + } + + internal static UnknownStorageClassTypeProperties DeserializeUnknownStorageClassTypeProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageClassType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new StorageClassType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownStorageClassTypeProperties(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StorageClassTypeProperties)} does not support writing '{options.Format}' format."); + } + } + + StorageClassTypeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStorageClassTypeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StorageClassTypeProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/UnknownStorageClassTypeProperties.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/UnknownStorageClassTypeProperties.cs new file mode 100644 index 000000000000..8dca1d1a75cc --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/UnknownStorageClassTypeProperties.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Unknown version of StorageClassTypeProperties. + internal partial class UnknownStorageClassTypeProperties : StorageClassTypeProperties + { + /// Initializes a new instance of . + /// Type of the storage class. + /// Keeps track of any properties unknown to the library. + internal UnknownStorageClassTypeProperties(StorageClassType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + Type = type; + } + + /// Initializes a new instance of for deserialization. + internal UnknownStorageClassTypeProperties() + { + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/VolumeBindingMode.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/VolumeBindingMode.cs new file mode 100644 index 000000000000..35be2b1a88ee --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/VolumeBindingMode.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Storage class volume binding mode. + public readonly partial struct VolumeBindingMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VolumeBindingMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ImmediateValue = "Immediate"; + private const string WaitForFirstConsumerValue = "WaitForFirstConsumer"; + + /// Immediate binding mode. + public static VolumeBindingMode Immediate { get; } = new VolumeBindingMode(ImmediateValue); + /// Wait for first consumer binding mode. + public static VolumeBindingMode WaitForFirstConsumer { get; } = new VolumeBindingMode(WaitForFirstConsumerValue); + /// Determines if two values are the same. + public static bool operator ==(VolumeBindingMode left, VolumeBindingMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VolumeBindingMode left, VolumeBindingMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VolumeBindingMode(string value) => new VolumeBindingMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VolumeBindingMode other && Equals(other); + /// + public bool Equals(VolumeBindingMode 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/VolumeExpansion.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/VolumeExpansion.cs new file mode 100644 index 000000000000..ff1965551f9b --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/Models/VolumeExpansion.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime.Models +{ + /// Ability to expand volumes of a storage class. + public readonly partial struct VolumeExpansion : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VolumeExpansion(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AllowValue = "Allow"; + private const string DisallowValue = "Disallow"; + + /// Allow volume expansion. + public static VolumeExpansion Allow { get; } = new VolumeExpansion(AllowValue); + /// Disallow volume expansion. + public static VolumeExpansion Disallow { get; } = new VolumeExpansion(DisallowValue); + /// Determines if two values are the same. + public static bool operator ==(VolumeExpansion left, VolumeExpansion right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VolumeExpansion left, VolumeExpansion right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VolumeExpansion(string value) => new VolumeExpansion(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VolumeExpansion other && Equals(other); + /// + public bool Equals(VolumeExpansion 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/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ProviderConstants.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..de0af46b5e47 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/ProviderConstants.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/BgpPeersRestOperations.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/BgpPeersRestOperations.cs new file mode 100644 index 000000000000..f3018170adce --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/BgpPeersRestOperations.cs @@ -0,0 +1,437 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal partial class BgpPeersRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of BgpPeersRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public BgpPeersRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-03-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string resourceUri, string bgpPeerName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/bgpPeers/", false); + uri.AppendPath(bgpPeerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string resourceUri, string bgpPeerName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/bgpPeers/", false); + uri.AppendPath(bgpPeerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a BgpPeer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the BgpPeer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string resourceUri, string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var message = CreateGetRequest(resourceUri, bgpPeerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ConnectedClusterBgpPeerData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ConnectedClusterBgpPeerData.DeserializeConnectedClusterBgpPeerData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ConnectedClusterBgpPeerData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a BgpPeer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the BgpPeer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Get(string resourceUri, string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var message = CreateGetRequest(resourceUri, bgpPeerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ConnectedClusterBgpPeerData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ConnectedClusterBgpPeerData.DeserializeConnectedClusterBgpPeerData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ConnectedClusterBgpPeerData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string resourceUri, string bgpPeerName, ConnectedClusterBgpPeerData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/bgpPeers/", false); + uri.AppendPath(bgpPeerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceUri, string bgpPeerName, ConnectedClusterBgpPeerData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/bgpPeers/", false); + uri.AppendPath(bgpPeerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a BgpPeer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the BgpPeer. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string resourceUri, string bgpPeerName, ConnectedClusterBgpPeerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, bgpPeerName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a BgpPeer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the BgpPeer. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string resourceUri, string bgpPeerName, ConnectedClusterBgpPeerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, bgpPeerName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string resourceUri, string bgpPeerName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/bgpPeers/", false); + uri.AppendPath(bgpPeerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string resourceUri, string bgpPeerName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/bgpPeers/", false); + uri.AppendPath(bgpPeerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a BgpPeer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the BgpPeer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string resourceUri, string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var message = CreateDeleteRequest(resourceUri, bgpPeerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a BgpPeer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the BgpPeer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Delete(string resourceUri, string bgpPeerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(bgpPeerName, nameof(bgpPeerName)); + + using var message = CreateDeleteRequest(resourceUri, bgpPeerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/bgpPeers", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/bgpPeers", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List BgpPeer resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListRequest(resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BgpPeerListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BgpPeerListResult.DeserializeBgpPeerListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BgpPeer resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListRequest(resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BgpPeerListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BgpPeerListResult.DeserializeBgpPeerListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List BgpPeer resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public async Task> ListNextPageAsync(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListNextPageRequest(nextLink, resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BgpPeerListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = BgpPeerListResult.DeserializeBgpPeerListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List BgpPeer resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public Response ListNextPage(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListNextPageRequest(nextLink, resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BgpPeerListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = BgpPeerListResult.DeserializeBgpPeerListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/LoadBalancersRestOperations.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/LoadBalancersRestOperations.cs new file mode 100644 index 000000000000..e4694a90fe9e --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/LoadBalancersRestOperations.cs @@ -0,0 +1,437 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal partial class LoadBalancersRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of LoadBalancersRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public LoadBalancersRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-03-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string resourceUri, string loadBalancerName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/loadBalancers/", false); + uri.AppendPath(loadBalancerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string resourceUri, string loadBalancerName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/loadBalancers/", false); + uri.AppendPath(loadBalancerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a LoadBalancer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string resourceUri, string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var message = CreateGetRequest(resourceUri, loadBalancerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ConnectedClusterLoadBalancerData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ConnectedClusterLoadBalancerData.DeserializeConnectedClusterLoadBalancerData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ConnectedClusterLoadBalancerData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a LoadBalancer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Get(string resourceUri, string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var message = CreateGetRequest(resourceUri, loadBalancerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ConnectedClusterLoadBalancerData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ConnectedClusterLoadBalancerData.DeserializeConnectedClusterLoadBalancerData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ConnectedClusterLoadBalancerData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string resourceUri, string loadBalancerName, ConnectedClusterLoadBalancerData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/loadBalancers/", false); + uri.AppendPath(loadBalancerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceUri, string loadBalancerName, ConnectedClusterLoadBalancerData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/loadBalancers/", false); + uri.AppendPath(loadBalancerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a LoadBalancer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the LoadBalancer. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string resourceUri, string loadBalancerName, ConnectedClusterLoadBalancerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, loadBalancerName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a LoadBalancer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the LoadBalancer. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string resourceUri, string loadBalancerName, ConnectedClusterLoadBalancerData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, loadBalancerName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string resourceUri, string loadBalancerName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/loadBalancers/", false); + uri.AppendPath(loadBalancerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string resourceUri, string loadBalancerName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/loadBalancers/", false); + uri.AppendPath(loadBalancerName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a LoadBalancer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string resourceUri, string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var message = CreateDeleteRequest(resourceUri, loadBalancerName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a LoadBalancer. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the LoadBalancer. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Delete(string resourceUri, string loadBalancerName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(loadBalancerName, nameof(loadBalancerName)); + + using var message = CreateDeleteRequest(resourceUri, loadBalancerName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/loadBalancers", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/loadBalancers", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List LoadBalancer resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListRequest(resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LoadBalancerListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LoadBalancerListResult.DeserializeLoadBalancerListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List LoadBalancer resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListRequest(resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LoadBalancerListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LoadBalancerListResult.DeserializeLoadBalancerListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List LoadBalancer resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public async Task> ListNextPageAsync(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListNextPageRequest(nextLink, resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + LoadBalancerListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = LoadBalancerListResult.DeserializeLoadBalancerListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List LoadBalancer resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public Response ListNextPage(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListNextPageRequest(nextLink, resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + LoadBalancerListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = LoadBalancerListResult.DeserializeLoadBalancerListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/ServicesRestOperations.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/ServicesRestOperations.cs new file mode 100644 index 000000000000..a6a426c52010 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/ServicesRestOperations.cs @@ -0,0 +1,447 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal partial class ServicesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ServicesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public ServicesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-03-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string resourceUri, string serviceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/services/", false); + uri.AppendPath(serviceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string resourceUri, string serviceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/services/", false); + uri.AppendPath(serviceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a ServiceResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the service. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string resourceUri, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var message = CreateGetRequest(resourceUri, serviceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ConnectedClusterServiceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ConnectedClusterServiceData.DeserializeConnectedClusterServiceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ConnectedClusterServiceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a ServiceResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the service. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Get(string resourceUri, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var message = CreateGetRequest(resourceUri, serviceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ConnectedClusterServiceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ConnectedClusterServiceData.DeserializeConnectedClusterServiceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ConnectedClusterServiceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string resourceUri, string serviceName, ConnectedClusterServiceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/services/", false); + uri.AppendPath(serviceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceUri, string serviceName, ConnectedClusterServiceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/services/", false); + uri.AppendPath(serviceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a ServiceResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the service. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> CreateOrUpdateAsync(string resourceUri, string serviceName, ConnectedClusterServiceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, serviceName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + ConnectedClusterServiceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ConnectedClusterServiceData.DeserializeConnectedClusterServiceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a ServiceResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the service. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string resourceUri, string serviceName, ConnectedClusterServiceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, serviceName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + ConnectedClusterServiceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ConnectedClusterServiceData.DeserializeConnectedClusterServiceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string resourceUri, string serviceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/services/", false); + uri.AppendPath(serviceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string resourceUri, string serviceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/services/", false); + uri.AppendPath(serviceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a ServiceResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the service. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string resourceUri, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var message = CreateDeleteRequest(resourceUri, serviceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a ServiceResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the service. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Delete(string resourceUri, string serviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName)); + + using var message = CreateDeleteRequest(resourceUri, serviceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/services", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/services", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List ServiceResource resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListRequest(resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ServiceResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ServiceResourceListResult.DeserializeServiceResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List ServiceResource resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListRequest(resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ServiceResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ServiceResourceListResult.DeserializeServiceResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List ServiceResource resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public async Task> ListNextPageAsync(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListNextPageRequest(nextLink, resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ServiceResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ServiceResourceListResult.DeserializeServiceResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List ServiceResource resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public Response ListNextPage(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListNextPageRequest(nextLink, resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ServiceResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ServiceResourceListResult.DeserializeServiceResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/StorageClassRestOperations.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/StorageClassRestOperations.cs new file mode 100644 index 000000000000..455d0b047765 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Generated/RestOperations/StorageClassRestOperations.cs @@ -0,0 +1,521 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ContainerOrchestratorRuntime.Models; + +namespace Azure.ResourceManager.ContainerOrchestratorRuntime +{ + internal partial class StorageClassRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of StorageClassRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public StorageClassRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-03-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string resourceUri, string storageClassName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses/", false); + uri.AppendPath(storageClassName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string resourceUri, string storageClassName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses/", false); + uri.AppendPath(storageClassName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a StorageClassResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the storage class. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string resourceUri, string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var message = CreateGetRequest(resourceUri, storageClassName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ConnectedClusterStorageClassData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ConnectedClusterStorageClassData.DeserializeConnectedClusterStorageClassData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ConnectedClusterStorageClassData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a StorageClassResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the storage class. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Get(string resourceUri, string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var message = CreateGetRequest(resourceUri, storageClassName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ConnectedClusterStorageClassData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ConnectedClusterStorageClassData.DeserializeConnectedClusterStorageClassData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ConnectedClusterStorageClassData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string resourceUri, string storageClassName, ConnectedClusterStorageClassData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses/", false); + uri.AppendPath(storageClassName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string resourceUri, string storageClassName, ConnectedClusterStorageClassData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses/", false); + uri.AppendPath(storageClassName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a StorageClassResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the storage class. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string resourceUri, string storageClassName, ConnectedClusterStorageClassData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, storageClassName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a StorageClassResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the storage class. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string resourceUri, string storageClassName, ConnectedClusterStorageClassData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(resourceUri, storageClassName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string resourceUri, string storageClassName, ConnectedClusterStorageClassPatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses/", false); + uri.AppendPath(storageClassName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string resourceUri, string storageClassName, ConnectedClusterStorageClassPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses/", false); + uri.AppendPath(storageClassName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a StorageClassResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the storage class. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string resourceUri, string storageClassName, ConnectedClusterStorageClassPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(resourceUri, storageClassName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a StorageClassResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the storage class. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Response Update(string resourceUri, string storageClassName, ConnectedClusterStorageClassPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(resourceUri, storageClassName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string resourceUri, string storageClassName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses/", false); + uri.AppendPath(storageClassName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string resourceUri, string storageClassName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses/", false); + uri.AppendPath(storageClassName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a StorageClassResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the storage class. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string resourceUri, string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var message = CreateDeleteRequest(resourceUri, storageClassName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a StorageClassResource. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The name of the the storage class. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response Delete(string resourceUri, string storageClassName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + Argument.AssertNotNullOrEmpty(storageClassName, nameof(storageClassName)); + + using var message = CreateDeleteRequest(resourceUri, storageClassName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(resourceUri, false); + uri.AppendPath("/providers/Microsoft.KubernetesRuntime/storageClasses", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List StorageClassResource resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public async Task> ListAsync(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListRequest(resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageClassResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageClassResourceListResult.DeserializeStorageClassResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List StorageClassResource resources by parent. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// is null. + public Response List(string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListRequest(resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageClassResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageClassResourceListResult.DeserializeStorageClassResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string resourceUri) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceUri) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List StorageClassResource resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public async Task> ListNextPageAsync(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListNextPageRequest(nextLink, resourceUri); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StorageClassResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StorageClassResourceListResult.DeserializeStorageClassResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List StorageClassResource resources by parent. + /// The URL to the next page of results. + /// The fully qualified Azure Resource manager identifier of the resource. + /// The cancellation token to use. + /// or is null. + public Response ListNextPage(string nextLink, string resourceUri, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNull(resourceUri, nameof(resourceUri)); + + using var message = CreateListNextPageRequest(nextLink, resourceUri); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StorageClassResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StorageClassResourceListResult.DeserializeStorageClassResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Properties/AssemblyInfo.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..c1ff00d9c470 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.ResourceManager.ContainerOrchestratorRuntime.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/tests/Azure.ResourceManager.ContainerOrchestratorRuntime.Tests.csproj b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/tests/Azure.ResourceManager.ContainerOrchestratorRuntime.Tests.csproj new file mode 100644 index 000000000000..022e2c6204d8 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/tests/Azure.ResourceManager.ContainerOrchestratorRuntime.Tests.csproj @@ -0,0 +1,12 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/tsp-location.yaml b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/tsp-location.yaml new file mode 100644 index 000000000000..9f87a0cd21a0 --- /dev/null +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/kubernetesruntime/KubernetesRuntime.Management +commit: 69deffb3127a749733827ad735e09c1f1d55891d +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/containerorchestratorruntime/ci.yml b/sdk/containerorchestratorruntime/ci.yml new file mode 100644 index 000000000000..17b8db281930 --- /dev/null +++ b/sdk/containerorchestratorruntime/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/containerorchestratorruntime + - sdk/containerorchestratorruntime/ci.yml + - sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/containerorchestratorruntime + - sdk/containerorchestratorruntime/ci.yml + - sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: containerorchestratorruntime + ArtifactName: packages + Artifacts: + - name: Azure.ResourceManager.ContainerOrchestratorRuntime + safeName: AzureResourceManagerContainerOrchestratorRuntime