diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules.sln b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules.sln new file mode 100644 index 000000000000..27796b8735b9 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules.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.ResourceManager.Hardwaresecuritymodules.Samples", "samples\Azure.ResourceManager.Hardwaresecuritymodules.Samples.csproj", "{7A2DFF15-5746-49F4-BD0F-C6C35337088A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Hardwaresecuritymodules", "src\Azure.ResourceManager.Hardwaresecuritymodules.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Hardwaresecuritymodules.Tests", "tests\Azure.ResourceManager.Hardwaresecuritymodules.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 + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/CHANGELOG.md b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/Directory.Build.props b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/README.md b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/README.md new file mode 100644 index 000000000000..88194d4aa6f6 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure Hardwaresecuritymodules management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure Hardwaresecuritymodules management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.Hardwaresecuritymodules --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://learn.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ \ No newline at end of file diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/assets.json b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/assets.json new file mode 100644 index 000000000000..ac7598249bce --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/assets.json @@ -0,0 +1,7 @@ + +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules", + "Tag": "" +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Azure.ResourceManager.Hardwaresecuritymodules.Samples.csproj b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Azure.ResourceManager.Hardwaresecuritymodules.Samples.csproj new file mode 100644 index 000000000000..a4adcdc80f67 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Azure.ResourceManager.Hardwaresecuritymodules.Samples.csproj @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_CloudHsmClusterCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_CloudHsmClusterCollection.cs new file mode 100644 index 000000000000..e69a9a9a5a43 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_CloudHsmClusterCollection.cs @@ -0,0 +1,209 @@ +// 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.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Samples +{ + public partial class Sample_CloudHsmClusterCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CloudHsmClusterCreateOrUpdateMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmCluster_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CloudHsmClusterResource + CloudHsmClusterCollection collection = resourceGroupResource.GetCloudHsmClusters(); + + // invoke the operation + string cloudHsmClusterName = "chsm1"; + CloudHsmClusterData data = new CloudHsmClusterData(new AzureLocation("eastus2")) + { + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-1")] = new UserAssignedIdentity() +}, + }, + Sku = new CloudHsmClusterSku(CloudHsmClusterSkuFamily.B, CloudHsmClusterSkuName.StandardB1), + Tags = +{ +["Dept"] = "hsm", +["Environment"] = "dogfood" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudHsmClusterName, data); + CloudHsmClusterResource 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 + CloudHsmClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CloudHsmClusterGetMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_Get_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmCluster_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CloudHsmClusterResource + CloudHsmClusterCollection collection = resourceGroupResource.GetCloudHsmClusters(); + + // invoke the operation + string cloudHsmClusterName = "chsm1"; + CloudHsmClusterResource result = await collection.GetAsync(cloudHsmClusterName); + + // 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 + CloudHsmClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_CloudHsmClusterListByResourceGroupMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmCluster_ListByResourceGroup" 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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CloudHsmClusterResource + CloudHsmClusterCollection collection = resourceGroupResource.GetCloudHsmClusters(); + + // invoke the operation and iterate over the result + await foreach (CloudHsmClusterResource 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 + CloudHsmClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_CloudHsmClusterGetMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_Get_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmCluster_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CloudHsmClusterResource + CloudHsmClusterCollection collection = resourceGroupResource.GetCloudHsmClusters(); + + // invoke the operation + string cloudHsmClusterName = "chsm1"; + bool result = await collection.ExistsAsync(cloudHsmClusterName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_CloudHsmClusterGetMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_Get_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmCluster_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CloudHsmClusterResource + CloudHsmClusterCollection collection = resourceGroupResource.GetCloudHsmClusters(); + + // invoke the operation + string cloudHsmClusterName = "chsm1"; + NullableResponse response = await collection.GetIfExistsAsync(cloudHsmClusterName); + CloudHsmClusterResource 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 + CloudHsmClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_CloudHsmClusterResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_CloudHsmClusterResource.cs new file mode 100644 index 000000000000..150b557cb37b --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_CloudHsmClusterResource.cs @@ -0,0 +1,320 @@ +// 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.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Samples +{ + public partial class Sample_CloudHsmClusterResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CloudHsmClusterGetMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_Get_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmCluster_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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation + CloudHsmClusterResource result = await cloudHsmCluster.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 + CloudHsmClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CloudHsmClusterDeleteMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmCluster_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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation + await cloudHsmCluster.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_CloudHsmClusterUpdateMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_Update_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmCluster_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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation + CloudHsmClusterPatch patch = new CloudHsmClusterPatch + { + Tags = +{ +["Dept"] = "hsm", +["Environment"] = "dogfood", +["Slice"] = "A" +}, + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-1")] = new UserAssignedIdentity() +}, + }, + }; + ArmOperation lro = await cloudHsmCluster.UpdateAsync(WaitUntil.Completed, patch); + CloudHsmClusterResource 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 + CloudHsmClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ValidateBackupProperties_CloudHsmClusterValidateBackupValidationMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_CreateOrValidate_Backup_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_ValidateBackupProperties" 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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation + BackupRequestProperties backupRequestProperties = new BackupRequestProperties(new Uri("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")) + { + Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED", + }; + await cloudHsmCluster.ValidateBackupPropertiesAsync(WaitUntil.Completed, backupRequestProperties: backupRequestProperties); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Backup_CloudHsmClusterCreateBackupMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_Create_Backup_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_Backup" 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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation + BackupRequestProperties backupRequestProperties = new BackupRequestProperties(new Uri("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")) + { + Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED", + }; + await cloudHsmCluster.BackupAsync(WaitUntil.Completed, backupRequestProperties: backupRequestProperties); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ValidateRestoreProperties_CloudHsmClusterValidateRestoreMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_RequestOrValidate_Restore_Properties_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_ValidateRestoreProperties" 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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation + RestoreRequestProperties restoreRequestProperties = new RestoreRequestProperties(new Uri("https://myaccount.blob.core.windows.net/sascontainer/sasContainer"), "backupId"); + await cloudHsmCluster.ValidateRestorePropertiesAsync(WaitUntil.Completed, restoreRequestProperties: restoreRequestProperties); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Restore_CloudHsmClusterRestoreMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_RequestOrValidate_Restore_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_Restore" 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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation + RestoreRequestProperties restoreRequestProperties = new RestoreRequestProperties(null, null); + await cloudHsmCluster.RestoreAsync(WaitUntil.Completed, restoreRequestProperties); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetByCloudHsmCluster_CloudHsmClusterPrivateLinkResourcesListByResourceMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmClusterPrivateLinkResource_ListByCloudHsmCluster_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_ListByCloudHsmCluster" 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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation and iterate over the result + await foreach (HardwaresecuritymodulesPrivateLinkResourceData item in cloudHsmCluster.GetByCloudHsmClusterAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CloudHsmClusterBackupStatusGet_CloudHsmClusterGetBackupStatusMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_Backup_Pending_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_CloudHsmClusterBackupStatusGet" 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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation + string jobId = "572a45927fc240e1ac075de27371680b"; + BackupResult result = await cloudHsmCluster.CloudHsmClusterBackupStatusGetAsync(jobId); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CloudHsmClusterRestoreStatusGet_CloudHsmClusterGetRestoreStatusMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_Restore_Pending_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_CloudHsmClusterRestoreStatusGet" 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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // invoke the operation + string jobId = "572a45927fc240e1ac075de27371680b"; + RestoreResult result = await cloudHsmCluster.CloudHsmClusterRestoreStatusGetAsync(jobId); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_DedicatedHsmCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_DedicatedHsmCollection.cs new file mode 100644 index 000000000000..878ba0ca45db --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_DedicatedHsmCollection.cs @@ -0,0 +1,489 @@ +// 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.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Samples +{ + public partial class Sample_DedicatedHsmCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateANewOrUpdateAnExistingDedicatedHSM() + { + // Generated from example definition: 2024-06-30-preview/DedicatedHsm_CreateOrUpdate.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + DedicatedHsmData data = new DedicatedHsmData(default, null); + await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateANewOrUpdateAnExistingPaymentHSM() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_CreateOrUpdate.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + DedicatedHsmData data = new DedicatedHsmData(default, null); + await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateANewOrUpdateAnExistingPaymentHSMWithManagementProfile() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_CreateOrUpdate_WithManagementProfile.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + DedicatedHsmData data = new DedicatedHsmData(default, null); + await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetADedicatedHSM() + { + // Generated from example definition: 2024-06-30-preview/DedicatedHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + DedicatedHsmResource result = await collection.GetAsync(name); + + // 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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAPaymentHSM() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + DedicatedHsmResource result = await collection.GetAsync(name); + + // 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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAPaymentHSMWith20181031PreviewApiVersion() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_Get_With_2018-10-31Preview_Version.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + DedicatedHsmResource result = await collection.GetAsync(name); + + // 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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListDedicatedHSMDevicesInAResourceGroup() + { + // Generated from example definition: 2024-06-30-preview/DedicatedHsm_ListByResourceGroup.json + // this example is just showing the usage of "DedicatedHsm_ListByResourceGroup" 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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation and iterate over the result + await foreach (DedicatedHsmResource 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 + DedicatedHsmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListDedicatedHSMDevicesInAResourceGroupIncludingPaymentHSM() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_ListByResourceGroup.json + // this example is just showing the usage of "DedicatedHsm_ListByResourceGroup" 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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation and iterate over the result + await foreach (DedicatedHsmResource 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 + DedicatedHsmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetADedicatedHSM() + { + // Generated from example definition: 2024-06-30-preview/DedicatedHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + bool result = await collection.ExistsAsync(name); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetAPaymentHSM() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + bool result = await collection.ExistsAsync(name); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetAPaymentHSMWith20181031PreviewApiVersion() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_Get_With_2018-10-31Preview_Version.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + bool result = await collection.ExistsAsync(name); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetADedicatedHSM() + { + // Generated from example definition: 2024-06-30-preview/DedicatedHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + NullableResponse response = await collection.GetIfExistsAsync(name); + DedicatedHsmResource 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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAPaymentHSM() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + NullableResponse response = await collection.GetIfExistsAsync(name); + DedicatedHsmResource 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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAPaymentHSMWith20181031PreviewApiVersion() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_Get_With_2018-10-31Preview_Version.json + // this example is just showing the usage of "DedicatedHsm_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 ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DedicatedHsmResource + DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); + + // invoke the operation + string name = "hsm1"; + NullableResponse response = await collection.GetIfExistsAsync(name); + DedicatedHsmResource 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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_DedicatedHsmResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_DedicatedHsmResource.cs new file mode 100644 index 000000000000..8d4c9b69be20 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_DedicatedHsmResource.cs @@ -0,0 +1,228 @@ +// 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.Hardwaresecuritymodules.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Samples +{ + public partial class Sample_DedicatedHsmResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetADedicatedHSM() + { + // Generated from example definition: 2024-06-30-preview/DedicatedHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_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 DedicatedHsmResource created on azure + // for more information of creating DedicatedHsmResource, please refer to the document of DedicatedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + string name = "hsm1"; + ResourceIdentifier dedicatedHsmResourceId = DedicatedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); + + // invoke the operation + DedicatedHsmResource result = await dedicatedHsm.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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAPaymentHSM() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_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 DedicatedHsmResource created on azure + // for more information of creating DedicatedHsmResource, please refer to the document of DedicatedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + string name = "hsm1"; + ResourceIdentifier dedicatedHsmResourceId = DedicatedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); + + // invoke the operation + DedicatedHsmResource result = await dedicatedHsm.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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAPaymentHSMWith20181031PreviewApiVersion() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_Get_With_2018-10-31Preview_Version.json + // this example is just showing the usage of "DedicatedHsm_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 DedicatedHsmResource created on azure + // for more information of creating DedicatedHsmResource, please refer to the document of DedicatedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + string name = "hsm1"; + ResourceIdentifier dedicatedHsmResourceId = DedicatedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); + + // invoke the operation + DedicatedHsmResource result = await dedicatedHsm.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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteADedicatedHSM() + { + // Generated from example definition: 2024-06-30-preview/DedicatedHsm_Delete.json + // this example is just showing the usage of "DedicatedHsm_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 DedicatedHsmResource created on azure + // for more information of creating DedicatedHsmResource, please refer to the document of DedicatedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + string name = "hsm1"; + ResourceIdentifier dedicatedHsmResourceId = DedicatedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); + + // invoke the operation + await dedicatedHsm.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_UpdateAnExistingDedicatedHSM() + { + // Generated from example definition: 2024-06-30-preview/DedicatedHsm_Update.json + // this example is just showing the usage of "DedicatedHsm_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 DedicatedHsmResource created on azure + // for more information of creating DedicatedHsmResource, please refer to the document of DedicatedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + string name = "hsm1"; + ResourceIdentifier dedicatedHsmResourceId = DedicatedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); + + // invoke the operation + DedicatedHsmPatch patch = new DedicatedHsmPatch(); + ArmOperation lro = await dedicatedHsm.UpdateAsync(WaitUntil.Completed, patch); + DedicatedHsmResource 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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_UpdateAnExistingPaymentHSM() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_Update.json + // this example is just showing the usage of "DedicatedHsm_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 DedicatedHsmResource created on azure + // for more information of creating DedicatedHsmResource, please refer to the document of DedicatedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + string name = "hsm1"; + ResourceIdentifier dedicatedHsmResourceId = DedicatedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); + + // invoke the operation + DedicatedHsmPatch patch = new DedicatedHsmPatch(); + ArmOperation lro = await dedicatedHsm.UpdateAsync(WaitUntil.Completed, patch); + DedicatedHsmResource 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 + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetOutboundNetworkDependenciesEndpoints_ListOutboundNetworkDependenciesEndpointsByManagedCluster() + { + // Generated from example definition: 2024-06-30-preview/GetOutboundNetworkDependenciesEndpointsList.json + // this example is just showing the usage of "DedicatedHsms_ListOutboundNetworkDependenciesEndpoints" 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 DedicatedHsmResource created on azure + // for more information of creating DedicatedHsmResource, please refer to the document of DedicatedHsmResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "hsm-group"; + string name = "hsm1"; + ResourceIdentifier dedicatedHsmResourceId = DedicatedHsmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); + + // invoke the operation and iterate over the result + await foreach (OutboundEnvironmentEndpoint item in dedicatedHsm.GetOutboundNetworkDependenciesEndpointsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_HardwaresecuritymodulesPrivateEndpointConnectionCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_HardwaresecuritymodulesPrivateEndpointConnectionCollection.cs new file mode 100644 index 000000000000..14140adaeb3e --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_HardwaresecuritymodulesPrivateEndpointConnectionCollection.cs @@ -0,0 +1,196 @@ +// 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 NUnit.Framework; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Samples +{ + public partial class Sample_HardwaresecuritymodulesPrivateEndpointConnectionCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CloudHsmClusterPrivateEndpointConnectionCreateMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmClusterPrivateEndpointConnection_Create_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnection_Create" 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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // get the collection of this HardwaresecuritymodulesPrivateEndpointConnectionResource + HardwaresecuritymodulesPrivateEndpointConnectionCollection collection = cloudHsmCluster.GetHardwaresecuritymodulesPrivateEndpointConnections(); + + // invoke the operation + string peConnectionName = "sample-pec"; + HardwaresecuritymodulesPrivateEndpointConnectionData data = new HardwaresecuritymodulesPrivateEndpointConnectionData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peConnectionName, data); + HardwaresecuritymodulesPrivateEndpointConnectionResource 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 + HardwaresecuritymodulesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnection_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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // get the collection of this HardwaresecuritymodulesPrivateEndpointConnectionResource + HardwaresecuritymodulesPrivateEndpointConnectionCollection collection = cloudHsmCluster.GetHardwaresecuritymodulesPrivateEndpointConnections(); + + // invoke the operation + string peConnectionName = "sample-pec"; + HardwaresecuritymodulesPrivateEndpointConnectionResource result = await collection.GetAsync(peConnectionName); + + // 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 + HardwaresecuritymodulesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_CloudHsmClusterPrivateEndpointConnectionListByResourceMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmClusterPrivateEndpointConnection_ListByCloudHsmCluster_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnection_ListByCloudHsmCluster" 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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // get the collection of this HardwaresecuritymodulesPrivateEndpointConnectionResource + HardwaresecuritymodulesPrivateEndpointConnectionCollection collection = cloudHsmCluster.GetHardwaresecuritymodulesPrivateEndpointConnections(); + + // invoke the operation and iterate over the result + await foreach (HardwaresecuritymodulesPrivateEndpointConnectionResource 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 + HardwaresecuritymodulesPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnection_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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // get the collection of this HardwaresecuritymodulesPrivateEndpointConnectionResource + HardwaresecuritymodulesPrivateEndpointConnectionCollection collection = cloudHsmCluster.GetHardwaresecuritymodulesPrivateEndpointConnections(); + + // invoke the operation + string peConnectionName = "sample-pec"; + bool result = await collection.ExistsAsync(peConnectionName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnection_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 CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); + + // get the collection of this HardwaresecuritymodulesPrivateEndpointConnectionResource + HardwaresecuritymodulesPrivateEndpointConnectionCollection collection = cloudHsmCluster.GetHardwaresecuritymodulesPrivateEndpointConnections(); + + // invoke the operation + string peConnectionName = "sample-pec"; + NullableResponse response = await collection.GetIfExistsAsync(peConnectionName); + HardwaresecuritymodulesPrivateEndpointConnectionResource 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 + HardwaresecuritymodulesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_HardwaresecuritymodulesPrivateEndpointConnectionResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_HardwaresecuritymodulesPrivateEndpointConnectionResource.cs new file mode 100644 index 000000000000..3e66babe23e1 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_HardwaresecuritymodulesPrivateEndpointConnectionResource.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 NUnit.Framework; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Samples +{ + public partial class Sample_HardwaresecuritymodulesPrivateEndpointConnectionResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnection_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 HardwaresecuritymodulesPrivateEndpointConnectionResource created on azure + // for more information of creating HardwaresecuritymodulesPrivateEndpointConnectionResource, please refer to the document of HardwaresecuritymodulesPrivateEndpointConnectionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + string peConnectionName = "sample-pec"; + ResourceIdentifier hardwaresecuritymodulesPrivateEndpointConnectionResourceId = HardwaresecuritymodulesPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName, peConnectionName); + HardwaresecuritymodulesPrivateEndpointConnectionResource hardwaresecuritymodulesPrivateEndpointConnection = client.GetHardwaresecuritymodulesPrivateEndpointConnectionResource(hardwaresecuritymodulesPrivateEndpointConnectionResourceId); + + // invoke the operation + HardwaresecuritymodulesPrivateEndpointConnectionResource result = await hardwaresecuritymodulesPrivateEndpointConnection.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 + HardwaresecuritymodulesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CloudHsmClusterPrivateEndpointConnectionDeleteMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmClusterPrivateEndpointConnection_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnection_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 HardwaresecuritymodulesPrivateEndpointConnectionResource created on azure + // for more information of creating HardwaresecuritymodulesPrivateEndpointConnectionResource, please refer to the document of HardwaresecuritymodulesPrivateEndpointConnectionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + string peConnectionName = "sample-pec"; + ResourceIdentifier hardwaresecuritymodulesPrivateEndpointConnectionResourceId = HardwaresecuritymodulesPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName, peConnectionName); + HardwaresecuritymodulesPrivateEndpointConnectionResource hardwaresecuritymodulesPrivateEndpointConnection = client.GetHardwaresecuritymodulesPrivateEndpointConnectionResource(hardwaresecuritymodulesPrivateEndpointConnectionResourceId); + + // invoke the operation + await hardwaresecuritymodulesPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_CloudHsmClusterPrivateEndpointConnectionCreateMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmClusterPrivateEndpointConnection_Create_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnection_Create" 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 HardwaresecuritymodulesPrivateEndpointConnectionResource created on azure + // for more information of creating HardwaresecuritymodulesPrivateEndpointConnectionResource, please refer to the document of HardwaresecuritymodulesPrivateEndpointConnectionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + string peConnectionName = "sample-pec"; + ResourceIdentifier hardwaresecuritymodulesPrivateEndpointConnectionResourceId = HardwaresecuritymodulesPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName, peConnectionName); + HardwaresecuritymodulesPrivateEndpointConnectionResource hardwaresecuritymodulesPrivateEndpointConnection = client.GetHardwaresecuritymodulesPrivateEndpointConnectionResource(hardwaresecuritymodulesPrivateEndpointConnectionResourceId); + + // invoke the operation + HardwaresecuritymodulesPrivateEndpointConnectionData data = new HardwaresecuritymodulesPrivateEndpointConnectionData(); + ArmOperation lro = await hardwaresecuritymodulesPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + HardwaresecuritymodulesPrivateEndpointConnectionResource 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 + HardwaresecuritymodulesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 000000000000..e0bf51fa0671 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,112 @@ +// 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.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCloudHsmClusters_CloudHsmClusterListBySubscriptionMaximumSetGen() + { + // Generated from example definition: 2024-06-30-preview/CloudHsmCluster_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmCluster_ListBySubscription" 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 SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CloudHsmClusterResource item in subscriptionResource.GetCloudHsmClustersAsync()) + { + // 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 + CloudHsmClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDedicatedHsms_ListDedicatedHSMDevicesInASubscription() + { + // Generated from example definition: 2024-06-30-preview/DedicatedHsm_ListBySubscription.json + // this example is just showing the usage of "DedicatedHsm_ListBySubscription" 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 SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DedicatedHsmResource item in subscriptionResource.GetDedicatedHsmsAsync()) + { + // 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 + DedicatedHsmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDedicatedHsms_ListDedicatedHSMDevicesInASubscriptionIncludingPaymentHSM() + { + // Generated from example definition: 2024-06-30-preview/PaymentHsm_ListBySubscription.json + // this example is just showing the usage of "DedicatedHsm_ListBySubscription" 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 SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DedicatedHsmResource item in subscriptionResource.GetDedicatedHsmsAsync()) + { + // 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 + DedicatedHsmData 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Azure.ResourceManager.Hardwaresecuritymodules.csproj b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Azure.ResourceManager.Hardwaresecuritymodules.csproj new file mode 100644 index 000000000000..1b45459b3fcf --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Azure.ResourceManager.Hardwaresecuritymodules.csproj @@ -0,0 +1,8 @@ + + + Azure Resource Manager client SDK for Azure resource provider Hardwaresecuritymodules. + 1.0.0-beta.1 + azure;management;arm;resource manager;hardwaresecuritymodules + Azure.ResourceManager.Hardwaresecuritymodules + + diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/ArmHardwaresecuritymodulesModelFactory.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/ArmHardwaresecuritymodulesModelFactory.cs new file mode 100644 index 000000000000..8380c5c65841 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/ArmHardwaresecuritymodulesModelFactory.cs @@ -0,0 +1,266 @@ +// 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.Hardwaresecuritymodules.Models +{ + /// Model factory for models. + public static partial class ArmHardwaresecuritymodulesModelFactory + { + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// State of security domain activation. + /// The Cloud HSM Cluster's auto-generated Domain Name Label Scope. + /// An array of Cloud HSM Cluster's HSMs. + /// List of private endpoint connection resources. + /// The Cloud HSM Cluster's provisioningState. + /// The Cloud HSM Cluster public network access. + /// Cloud HSM Cluster status message. + /// Managed service identity (system assigned and/or user assigned identities). + /// SKU details. + /// A new instance for mocking. + public static CloudHsmClusterData CloudHsmClusterData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ActivationState? activationState = null, AutoGeneratedDomainNameLabelScope? autoGeneratedDomainNameLabelScope = null, IEnumerable hsms = null, IEnumerable privateEndpointConnections = null, ProvisioningState? provisioningState = null, PublicNetworkAccess? publicNetworkAccess = null, string statusMessage = null, ManagedServiceIdentity identity = null, CloudHsmClusterSku sku = null) + { + tags ??= new Dictionary(); + hsms ??= new List(); + privateEndpointConnections ??= new List(); + + return new CloudHsmClusterData( + id, + name, + resourceType, + systemData, + tags, + location, + activationState, + autoGeneratedDomainNameLabelScope, + hsms?.ToList(), + privateEndpointConnections?.ToList(), + provisioningState, + publicNetworkAccess, + statusMessage, + identity, + sku, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// FQDN of the Cloud HSM. + /// The Cloud HSM State. Values are: Deploying, ConfiguringSlb, Starting, Starting, Failed, Failed, Deleting, DeletingSlbEntry, InitialProvisioning, Updating. + /// The Cloud HSM State message. + /// A new instance for mocking. + public static CloudHsmProperties CloudHsmProperties(string fqdn = null, string state = null, string stateMessage = null) + { + return new CloudHsmProperties(fqdn, state, stateMessage, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The private endpoint resource. + /// A collection of information about the state of the connection between service consumer and provider. + /// The provisioning state of the private endpoint connection resource. + /// The group ids for the private endpoint resource. + /// Modified whenever there is a change in the state of private endpoint connection. + /// A new instance for mocking. + public static HardwaresecuritymodulesPrivateEndpointConnectionData HardwaresecuritymodulesPrivateEndpointConnectionData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ResourceIdentifier privateEndpointId = null, HardwaresecuritymodulesPrivateLinkServiceConnectionState privateLinkServiceConnectionState = null, HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState? provisioningState = null, IEnumerable groupIds = null, string etag = null) + { + groupIds ??= new List(); + + return new HardwaresecuritymodulesPrivateEndpointConnectionData( + id, + name, + resourceType, + systemData, + privateEndpointId != null ? ResourceManagerModelFactory.SubResource(privateEndpointId) : null, + privateLinkServiceConnectionState, + provisioningState, + groupIds?.ToList(), + etag, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// The SAS token pointing to an Azure blob storage container. This property is reserved for Azure Backup Service. + /// A new instance for mocking. + public static BackupRequestProperties BackupRequestProperties(Uri azureStorageBlobContainerUri = null, string token = null) + { + return new BackupRequestProperties(azureStorageBlobContainerUri, token, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// The SAS token pointing to an Azure blob storage container. This property is reserved for Azure Backup Service. + /// A new instance for mocking. + public static BackupRestoreRequestBaseProperties BackupRestoreRequestBaseProperties(Uri azureStorageBlobContainerUri = null, string token = null) + { + return new BackupRestoreRequestBaseProperties(azureStorageBlobContainerUri, token, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// The ID of the backup. + /// A new instance for mocking. + public static BackupResult BackupResult(Uri azureStorageBlobContainerUri = null, string backupId = null) + { + return new BackupResult(azureStorageBlobContainerUri, backupId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// The SAS token pointing to an Azure blob storage container. This property is reserved for Azure Backup Service. + /// An autogenerated unique string ID for labeling the backup. It contains both a UUID and a date timestamp. + /// A new instance for mocking. + public static RestoreRequestProperties RestoreRequestProperties(Uri azureStorageBlobContainerUri = null, string token = null, string backupId = null) + { + return new RestoreRequestProperties(azureStorageBlobContainerUri, token, serializedAdditionalRawData: null, backupId); + } + + /// Initializes a new instance of . + /// Status of the backup/restore operation. + /// The status details of backup/restore operation. + /// Error encountered, if any, during the backup/restore operation. + /// The start time of the backup/restore operation in UTC. + /// The end time of the backup/restore operation in UTC. + /// Identifier for the backup/restore operation. + /// A new instance for mocking. + public static RestoreResult RestoreResult(BackupRestoreOperationStatus? status = null, string statusDetails = null, ResponseError error = null, DateTimeOffset? startOn = null, DateTimeOffset? endOn = null, string jobId = null) + { + return new RestoreResult( + status, + statusDetails, + error, + startOn, + endOn, + jobId, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource properties. + /// A new instance for mocking. + public static HardwaresecuritymodulesPrivateLinkResourceData HardwaresecuritymodulesPrivateLinkResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, HardwaresecuritymodulesPrivateLinkResourceProperties properties = null) + { + return new HardwaresecuritymodulesPrivateLinkResourceData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The private link resource group id. + /// The private link resource required member names. + /// The private link resource private link DNS zone name. + /// A new instance for mocking. + public static HardwaresecuritymodulesPrivateLinkResourceProperties HardwaresecuritymodulesPrivateLinkResourceProperties(string groupId = null, IEnumerable requiredMembers = null, IEnumerable requiredZoneNames = null) + { + requiredMembers ??= new List(); + requiredZoneNames ??= new List(); + + return new HardwaresecuritymodulesPrivateLinkResourceProperties(groupId, requiredMembers?.ToList(), requiredZoneNames?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// SKU details. + /// The availability zones. + /// Specifies the network interfaces of the dedicated hsm. + /// Specifies the management network interfaces of the dedicated hsm. + /// This field will be used when RP does not support Availability zones. + /// Resource Status Message. + /// Provisioning state. + /// A new instance for mocking. + public static DedicatedHsmData DedicatedHsmData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, HardwaresecuritymodulesSkuName? skuName = null, IEnumerable zones = null, NetworkProfile networkProfile = null, NetworkProfile managementNetworkProfile = null, string stampId = null, string statusMessage = null, JsonWebKeyType? provisioningState = null) + { + tags ??= new Dictionary(); + zones ??= new List(); + + return new DedicatedHsmData( + id, + name, + resourceType, + systemData, + tags, + location, + skuName != null ? new HardwaresecuritymodulesSku(skuName, serializedAdditionalRawData: null) : null, + zones?.ToList(), + networkProfile, + managementNetworkProfile, + stampId, + statusMessage, + provisioningState, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The Azure resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... + /// Private Ip address of the interface. + /// A new instance for mocking. + public static NetworkInterface NetworkInterface(ResourceIdentifier resourceId = null, string privateIPAddress = null) + { + return new NetworkInterface(resourceId, privateIPAddress, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The category of endpoints accessed by the dedicated hsm service, e.g. azure-resource-management, apiserver, etc. + /// The endpoints that dedicated hsm service connects to. + /// A new instance for mocking. + public static OutboundEnvironmentEndpoint OutboundEnvironmentEndpoint(string category = null, IEnumerable endpoints = null) + { + endpoints ??= new List(); + + return new OutboundEnvironmentEndpoint(category, endpoints?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The domain name of the dependency. + /// The Ports and Protocols used when connecting to domainName. + /// A new instance for mocking. + public static EndpointDependency EndpointDependency(string domainName = null, IEnumerable endpointDetails = null) + { + endpointDetails ??= new List(); + + return new EndpointDependency(domainName, endpointDetails?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// An IP Address that Domain Name currently resolves to. + /// The port an endpoint is connected to. + /// The protocol used for connection. + /// Description of the detail. + /// A new instance for mocking. + public static EndpointDetail EndpointDetail(string ipAddress = null, int? port = null, string protocol = null, string description = null) + { + return new EndpointDetail(ipAddress, port, protocol, description, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterCollection.cs new file mode 100644 index 000000000000..5333ecdbd6f1 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterCollection.cs @@ -0,0 +1,496 @@ +// 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.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// + /// 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 GetCloudHsmClusters method from an instance of . + /// + public partial class CloudHsmClusterCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _cloudHsmClusterClientDiagnostics; + private readonly CloudHsmClustersRestOperations _cloudHsmClusterRestClient; + + /// Initializes a new instance of the class for mocking. + protected CloudHsmClusterCollection() + { + } + + /// 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 CloudHsmClusterCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _cloudHsmClusterClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Hardwaresecuritymodules", CloudHsmClusterResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(CloudHsmClusterResource.ResourceType, out string cloudHsmClusterApiVersion); + _cloudHsmClusterRestClient = new CloudHsmClustersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, cloudHsmClusterApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Create or Update a Cloud HSM Cluster in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Parameters to create Cloud HSM Cluster. + /// 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 cloudHsmClusterName, CloudHsmClusterData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, data, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(new CloudHsmClusterOperationSource(Client), _cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, data).Request, response, OperationFinalStateVia.OriginalUri); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create or Update a Cloud HSM Cluster in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Parameters to create Cloud HSM Cluster. + /// 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 cloudHsmClusterName, CloudHsmClusterData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, data, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(new CloudHsmClusterOperationSource(Client), _cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, data).Request, response, OperationFinalStateVia.OriginalUri); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterCollection.Get"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CloudHsmClusterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterCollection.Get"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CloudHsmClusterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription and within the specified resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters + /// + /// + /// Operation Id + /// CloudHsmCluster_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string skiptoken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _cloudHsmClusterRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, skiptoken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _cloudHsmClusterRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, skiptoken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CloudHsmClusterResource(Client, CloudHsmClusterData.DeserializeCloudHsmClusterData(e)), _cloudHsmClusterClientDiagnostics, Pipeline, "CloudHsmClusterCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription and within the specified resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters + /// + /// + /// Operation Id + /// CloudHsmCluster_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(string skiptoken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _cloudHsmClusterRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, skiptoken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _cloudHsmClusterRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, skiptoken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CloudHsmClusterResource(Client, CloudHsmClusterData.DeserializeCloudHsmClusterData(e)), _cloudHsmClusterClientDiagnostics, Pipeline, "CloudHsmClusterCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterCollection.Exists"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, 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 + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterCollection.Exists"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, 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 + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new CloudHsmClusterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterCollection.GetIfExists"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, cloudHsmClusterName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new CloudHsmClusterResource(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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterData.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterData.Serialization.cs new file mode 100644 index 000000000000..7d26ee893673 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterData.Serialization.cs @@ -0,0 +1,339 @@ +// 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.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + public partial class CloudHsmClusterData : 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(CloudHsmClusterData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + JsonSerializer.Serialize(writer, Identity, serializeOptions); + } + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ActivationState)) + { + writer.WritePropertyName("activationState"u8); + writer.WriteStringValue(ActivationState.Value.ToString()); + } + if (Optional.IsDefined(AutoGeneratedDomainNameLabelScope)) + { + writer.WritePropertyName("autoGeneratedDomainNameLabelScope"u8); + writer.WriteStringValue(AutoGeneratedDomainNameLabelScope.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Hsms)) + { + writer.WritePropertyName("hsms"u8); + writer.WriteStartArray(); + foreach (var item in Hsms) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(PrivateEndpointConnections)) + { + writer.WritePropertyName("privateEndpointConnections"u8); + writer.WriteStartArray(); + foreach (var item in PrivateEndpointConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(PublicNetworkAccess)) + { + writer.WritePropertyName("publicNetworkAccess"u8); + writer.WriteStringValue(PublicNetworkAccess.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(StatusMessage)) + { + writer.WritePropertyName("statusMessage"u8); + writer.WriteStringValue(StatusMessage); + } + writer.WriteEndObject(); + } + + CloudHsmClusterData 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(CloudHsmClusterData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCloudHsmClusterData(document.RootElement, options); + } + + internal static CloudHsmClusterData DeserializeCloudHsmClusterData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ManagedServiceIdentity identity = default; + CloudHsmClusterSku sku = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + ActivationState? activationState = default; + AutoGeneratedDomainNameLabelScope? autoGeneratedDomainNameLabelScope = default; + IReadOnlyList hsms = default; + IReadOnlyList privateEndpointConnections = default; + ProvisioningState? provisioningState = default; + PublicNetworkAccess? publicNetworkAccess = default; + string statusMessage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + continue; + } + if (property.NameEquals("sku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = CloudHsmClusterSku.DeserializeCloudHsmClusterSku(property.Value, options); + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + 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 (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("activationState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + activationState = new ActivationState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("autoGeneratedDomainNameLabelScope"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autoGeneratedDomainNameLabelScope = new AutoGeneratedDomainNameLabelScope(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("hsms"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(CloudHsmProperties.DeserializeCloudHsmProperties(item, options)); + } + hsms = array; + continue; + } + if (property0.NameEquals("privateEndpointConnections"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(HardwaresecuritymodulesPrivateEndpointConnectionData.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(item, options)); + } + privateEndpointConnections = array; + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("publicNetworkAccess"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicNetworkAccess = new PublicNetworkAccess(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("statusMessage"u8)) + { + statusMessage = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CloudHsmClusterData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + activationState, + autoGeneratedDomainNameLabelScope, + hsms ?? new ChangeTrackingList(), + privateEndpointConnections ?? new ChangeTrackingList(), + provisioningState, + publicNetworkAccess, + statusMessage, + identity, + sku, + 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(CloudHsmClusterData)} does not support writing '{options.Format}' format."); + } + } + + CloudHsmClusterData 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCloudHsmClusterData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CloudHsmClusterData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterData.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterData.cs new file mode 100644 index 000000000000..63d7430533e4 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterData.cs @@ -0,0 +1,117 @@ +// 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.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// + /// A class representing the CloudHsmCluster data model. + /// Resource information with extended details. + /// + public partial class CloudHsmClusterData : TrackedResourceData + { + /// + /// 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 location. + public CloudHsmClusterData(AzureLocation location) : base(location) + { + Hsms = new ChangeTrackingList(); + PrivateEndpointConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// State of security domain activation. + /// The Cloud HSM Cluster's auto-generated Domain Name Label Scope. + /// An array of Cloud HSM Cluster's HSMs. + /// List of private endpoint connection resources. + /// The Cloud HSM Cluster's provisioningState. + /// The Cloud HSM Cluster public network access. + /// Cloud HSM Cluster status message. + /// Managed service identity (system assigned and/or user assigned identities). + /// SKU details. + /// Keeps track of any properties unknown to the library. + internal CloudHsmClusterData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ActivationState? activationState, AutoGeneratedDomainNameLabelScope? autoGeneratedDomainNameLabelScope, IReadOnlyList hsms, IReadOnlyList privateEndpointConnections, ProvisioningState? provisioningState, PublicNetworkAccess? publicNetworkAccess, string statusMessage, ManagedServiceIdentity identity, CloudHsmClusterSku sku, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + ActivationState = activationState; + AutoGeneratedDomainNameLabelScope = autoGeneratedDomainNameLabelScope; + Hsms = hsms; + PrivateEndpointConnections = privateEndpointConnections; + ProvisioningState = provisioningState; + PublicNetworkAccess = publicNetworkAccess; + StatusMessage = statusMessage; + Identity = identity; + Sku = sku; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CloudHsmClusterData() + { + } + + /// State of security domain activation. + public ActivationState? ActivationState { get; } + /// The Cloud HSM Cluster's auto-generated Domain Name Label Scope. + public AutoGeneratedDomainNameLabelScope? AutoGeneratedDomainNameLabelScope { get; set; } + /// An array of Cloud HSM Cluster's HSMs. + public IReadOnlyList Hsms { get; } + /// List of private endpoint connection resources. + public IReadOnlyList PrivateEndpointConnections { get; } + /// The Cloud HSM Cluster's provisioningState. + public ProvisioningState? ProvisioningState { get; } + /// The Cloud HSM Cluster public network access. + public PublicNetworkAccess? PublicNetworkAccess { get; set; } + /// Cloud HSM Cluster status message. + public string StatusMessage { get; } + /// Managed service identity (system assigned and/or user assigned identities). + public ManagedServiceIdentity Identity { get; set; } + /// SKU details. + public CloudHsmClusterSku Sku { get; set; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterResource.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterResource.Serialization.cs new file mode 100644 index 000000000000..1b065c2ad87e --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterResource.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.Hardwaresecuritymodules +{ + public partial class CloudHsmClusterResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + CloudHsmClusterData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerHardwaresecuritymodulesContext.Default); + + CloudHsmClusterData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerHardwaresecuritymodulesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterResource.cs new file mode 100644 index 000000000000..9df132b16a60 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/CloudHsmClusterResource.cs @@ -0,0 +1,1359 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// + /// A Class representing a CloudHsmCluster 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 GetCloudHsmClusterResource method. + /// Otherwise you can get one from its parent resource using the GetCloudHsmCluster method. + /// + public partial class CloudHsmClusterResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The cloudHsmClusterName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _cloudHsmClusterClientDiagnostics; + private readonly CloudHsmClustersRestOperations _cloudHsmClusterRestClient; + private readonly CloudHsmClusterData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.HardwareSecurityModules/cloudHsmClusters"; + + /// Initializes a new instance of the class for mocking. + protected CloudHsmClusterResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal CloudHsmClusterResource(ArmClient client, CloudHsmClusterData 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 CloudHsmClusterResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _cloudHsmClusterClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Hardwaresecuritymodules", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string cloudHsmClusterApiVersion); + _cloudHsmClusterRestClient = new CloudHsmClustersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, cloudHsmClusterApiVersion); +#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 CloudHsmClusterData 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)); + } + + /// Gets a collection of HardwaresecuritymodulesPrivateEndpointConnectionResources in the CloudHsmCluster. + /// An object representing collection of HardwaresecuritymodulesPrivateEndpointConnectionResources and their operations over a HardwaresecuritymodulesPrivateEndpointConnectionResource. + public virtual HardwaresecuritymodulesPrivateEndpointConnectionCollection GetHardwaresecuritymodulesPrivateEndpointConnections() + { + return GetCachedClient(client => new HardwaresecuritymodulesPrivateEndpointConnectionCollection(client, Id)); + } + + /// + /// Gets the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetHardwaresecuritymodulesPrivateEndpointConnectionAsync(string peConnectionName, CancellationToken cancellationToken = default) + { + return await GetHardwaresecuritymodulesPrivateEndpointConnections().GetAsync(peConnectionName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetHardwaresecuritymodulesPrivateEndpointConnection(string peConnectionName, CancellationToken cancellationToken = default) + { + return GetHardwaresecuritymodulesPrivateEndpointConnections().Get(peConnectionName, cancellationToken); + } + + /// + /// Gets the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Get"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CloudHsmClusterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Get"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CloudHsmClusterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Delete + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Delete"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, 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; + } + } + + /// + /// Deletes the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Delete + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Delete"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Cloud HSM Cluster in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Update + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Parameters to create Cloud HSM Cluster. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, CloudHsmClusterPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Update"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(new CloudHsmClusterOperationSource(Client), _cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, 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 Cloud HSM Cluster in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Update + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Parameters to create Cloud HSM Cluster. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, CloudHsmClusterPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Update"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(new CloudHsmClusterOperationSource(Client), _cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM Cluster resource in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/validateBackupProperties + /// + /// + /// Operation Id + /// CloudHsmClusters_ValidateBackupProperties + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Backup Operation Required properties. + /// The cancellation token to use. + public virtual async Task ValidateBackupPropertiesAsync(WaitUntil waitUntil, BackupRequestProperties backupRequestProperties = null, CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.ValidateBackupProperties"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.ValidateBackupPropertiesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, backupRequestProperties, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateValidateBackupPropertiesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, backupRequestProperties).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM Cluster resource in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/validateBackupProperties + /// + /// + /// Operation Id + /// CloudHsmClusters_ValidateBackupProperties + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Backup Operation Required properties. + /// The cancellation token to use. + public virtual ArmOperation ValidateBackupProperties(WaitUntil waitUntil, BackupRequestProperties backupRequestProperties = null, CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.ValidateBackupProperties"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.ValidateBackupProperties(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, backupRequestProperties, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateValidateBackupPropertiesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, backupRequestProperties).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a backup of the Cloud HSM Cluster in the specified subscription + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/backup + /// + /// + /// Operation Id + /// CloudHsmClusters_Backup + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Azure storage Resource Uri. + /// The cancellation token to use. + public virtual async Task BackupAsync(WaitUntil waitUntil, BackupRequestProperties backupRequestProperties = null, CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Backup"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.BackupAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, backupRequestProperties, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateBackupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, backupRequestProperties).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a backup of the Cloud HSM Cluster in the specified subscription + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/backup + /// + /// + /// Operation Id + /// CloudHsmClusters_Backup + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Azure storage Resource Uri. + /// The cancellation token to use. + public virtual ArmOperation Backup(WaitUntil waitUntil, BackupRequestProperties backupRequestProperties = null, CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Backup"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.Backup(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, backupRequestProperties, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateBackupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, backupRequestProperties).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Queued validating pre restore operation + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/validateRestoreProperties + /// + /// + /// Operation Id + /// CloudHsmClusters_ValidateRestoreProperties + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Optional Parameters to validate prior performing a restore operation. + /// The cancellation token to use. + public virtual async Task ValidateRestorePropertiesAsync(WaitUntil waitUntil, RestoreRequestProperties restoreRequestProperties = null, CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.ValidateRestoreProperties"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.ValidateRestorePropertiesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restoreRequestProperties, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateValidateRestorePropertiesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restoreRequestProperties).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Queued validating pre restore operation + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/validateRestoreProperties + /// + /// + /// Operation Id + /// CloudHsmClusters_ValidateRestoreProperties + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Optional Parameters to validate prior performing a restore operation. + /// The cancellation token to use. + public virtual ArmOperation ValidateRestoreProperties(WaitUntil waitUntil, RestoreRequestProperties restoreRequestProperties = null, CancellationToken cancellationToken = default) + { + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.ValidateRestoreProperties"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.ValidateRestoreProperties(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restoreRequestProperties, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateValidateRestorePropertiesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restoreRequestProperties).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Restores all key materials of a specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/restore + /// + /// + /// Operation Id + /// CloudHsmClusters_Restore + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Restore Operation Required properties. + /// The cancellation token to use. + /// is null. + public virtual async Task RestoreAsync(WaitUntil waitUntil, RestoreRequestProperties restoreRequestProperties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(restoreRequestProperties, nameof(restoreRequestProperties)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Restore"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.RestoreAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restoreRequestProperties, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateRestoreRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restoreRequestProperties).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Restores all key materials of a specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/restore + /// + /// + /// Operation Id + /// CloudHsmClusters_Restore + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Restore Operation Required properties. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Restore(WaitUntil waitUntil, RestoreRequestProperties restoreRequestProperties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(restoreRequestProperties, nameof(restoreRequestProperties)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.Restore"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.Restore(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restoreRequestProperties, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(_cloudHsmClusterClientDiagnostics, Pipeline, _cloudHsmClusterRestClient.CreateRestoreRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, restoreRequestProperties).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the private link resources supported for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateLinkResources + /// + /// + /// Operation Id + /// CloudHsmClusters_ListByCloudHsmCluster + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetByCloudHsmClusterAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _cloudHsmClusterRestClient.CreateListByCloudHsmClusterRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _cloudHsmClusterRestClient.CreateListByCloudHsmClusterNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => HardwaresecuritymodulesPrivateLinkResourceData.DeserializeHardwaresecuritymodulesPrivateLinkResourceData(e), _cloudHsmClusterClientDiagnostics, Pipeline, "CloudHsmClusterResource.GetByCloudHsmCluster", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the private link resources supported for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateLinkResources + /// + /// + /// Operation Id + /// CloudHsmClusters_ListByCloudHsmCluster + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetByCloudHsmCluster(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _cloudHsmClusterRestClient.CreateListByCloudHsmClusterRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _cloudHsmClusterRestClient.CreateListByCloudHsmClusterNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => HardwaresecuritymodulesPrivateLinkResourceData.DeserializeHardwaresecuritymodulesPrivateLinkResourceData(e), _cloudHsmClusterClientDiagnostics, Pipeline, "CloudHsmClusterResource.GetByCloudHsmCluster", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the backup operation status of the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/backupOperationStatus/{jobId} + /// + /// + /// Operation Id + /// CloudHsmClusters_CloudHsmClusterBackupStatusGet + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Identifier for the backup operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> CloudHsmClusterBackupStatusGetAsync(string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.CloudHsmClusterBackupStatusGet"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.CloudHsmClusterBackupStatusGetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, jobId, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the backup operation status of the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/backupOperationStatus/{jobId} + /// + /// + /// Operation Id + /// CloudHsmClusters_CloudHsmClusterBackupStatusGet + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Identifier for the backup operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response CloudHsmClusterBackupStatusGet(string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.CloudHsmClusterBackupStatusGet"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.CloudHsmClusterBackupStatusGet(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, jobId, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the restore operation status of the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/restoreOperationStatus/{jobId} + /// + /// + /// Operation Id + /// CloudHsmClusters_CloudHsmClusterRestoreStatusGet + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Identifier for the restore operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> CloudHsmClusterRestoreStatusGetAsync(string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.CloudHsmClusterRestoreStatusGet"); + scope.Start(); + try + { + var response = await _cloudHsmClusterRestClient.CloudHsmClusterRestoreStatusGetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, jobId, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the restore operation status of the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/restoreOperationStatus/{jobId} + /// + /// + /// Operation Id + /// CloudHsmClusters_CloudHsmClusterRestoreStatusGet + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Identifier for the restore operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response CloudHsmClusterRestoreStatusGet(string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.CloudHsmClusterRestoreStatusGet"); + scope.Start(); + try + { + var response = _cloudHsmClusterRestClient.CloudHsmClusterRestoreStatusGet(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, jobId, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _cloudHsmClusterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CloudHsmClusterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CloudHsmClusterPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _cloudHsmClusterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CloudHsmClusterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CloudHsmClusterPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _cloudHsmClusterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CloudHsmClusterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CloudHsmClusterPatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _cloudHsmClusterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CloudHsmClusterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CloudHsmClusterPatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _cloudHsmClusterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CloudHsmClusterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CloudHsmClusterPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _cloudHsmClusterClientDiagnostics.CreateScope("CloudHsmClusterResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _cloudHsmClusterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CloudHsmClusterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CloudHsmClusterPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmCollection.cs new file mode 100644 index 000000000000..4e7a4e641823 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmCollection.cs @@ -0,0 +1,496 @@ +// 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.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// + /// 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 GetDedicatedHsms method from an instance of . + /// + public partial class DedicatedHsmCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _dedicatedHsmClientDiagnostics; + private readonly DedicatedHsmsRestOperations _dedicatedHsmRestClient; + + /// Initializes a new instance of the class for mocking. + protected DedicatedHsmCollection() + { + } + + /// 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 DedicatedHsmCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _dedicatedHsmClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Hardwaresecuritymodules", DedicatedHsmResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(DedicatedHsmResource.ResourceType, out string dedicatedHsmApiVersion); + _dedicatedHsmRestClient = new DedicatedHsmsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dedicatedHsmApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Create or Update a dedicated HSM in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of the dedicated Hsm. + /// Parameters to create or update the dedicated hsm. + /// 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 name, DedicatedHsmData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _dedicatedHsmRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, name, data, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(_dedicatedHsmClientDiagnostics, Pipeline, _dedicatedHsmRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, name, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create or Update a dedicated HSM in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of the dedicated Hsm. + /// Parameters to create or update the dedicated hsm. + /// 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 name, DedicatedHsmData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _dedicatedHsmRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, name, data, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(_dedicatedHsmClientDiagnostics, Pipeline, _dedicatedHsmRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, name, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Azure dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmCollection.Get"); + scope.Start(); + try + { + var response = await _dedicatedHsmRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DedicatedHsmResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Azure dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmCollection.Get"); + scope.Start(); + try + { + var response = _dedicatedHsmRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DedicatedHsmResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs + /// + /// + /// Operation Id + /// DedicatedHsm_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Maximum number of results to return. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _dedicatedHsmRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dedicatedHsmRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, top); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DedicatedHsmResource(Client, DedicatedHsmData.DeserializeDedicatedHsmData(e)), _dedicatedHsmClientDiagnostics, Pipeline, "DedicatedHsmCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs + /// + /// + /// Operation Id + /// DedicatedHsm_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Maximum number of results to return. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _dedicatedHsmRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dedicatedHsmRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, top); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DedicatedHsmResource(Client, DedicatedHsmData.DeserializeDedicatedHsmData(e)), _dedicatedHsmClientDiagnostics, Pipeline, "DedicatedHsmCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmCollection.Exists"); + scope.Start(); + try + { + var response = await _dedicatedHsmRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, name, 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 + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmCollection.Exists"); + scope.Start(); + try + { + var response = _dedicatedHsmRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, name, 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 + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _dedicatedHsmRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, name, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DedicatedHsmResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmCollection.GetIfExists"); + scope.Start(); + try + { + var response = _dedicatedHsmRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, name, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DedicatedHsmResource(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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmData.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmData.Serialization.cs new file mode 100644 index 000000000000..c11840965440 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmData.Serialization.cs @@ -0,0 +1,284 @@ +// 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.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + public partial class DedicatedHsmData : 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(DedicatedHsmData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + if (Optional.IsCollectionDefined(Zones)) + { + writer.WritePropertyName("zones"u8); + writer.WriteStartArray(); + foreach (var item in Zones) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(NetworkProfile)) + { + writer.WritePropertyName("networkProfile"u8); + writer.WriteObjectValue(NetworkProfile, options); + } + if (Optional.IsDefined(ManagementNetworkProfile)) + { + writer.WritePropertyName("managementNetworkProfile"u8); + writer.WriteObjectValue(ManagementNetworkProfile, options); + } + if (Optional.IsDefined(StampId)) + { + writer.WritePropertyName("stampId"u8); + writer.WriteStringValue(StampId); + } + if (options.Format != "W" && Optional.IsDefined(StatusMessage)) + { + writer.WritePropertyName("statusMessage"u8); + writer.WriteStringValue(StatusMessage); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + writer.WriteEndObject(); + } + + DedicatedHsmData 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(DedicatedHsmData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDedicatedHsmData(document.RootElement, options); + } + + internal static DedicatedHsmData DeserializeDedicatedHsmData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + HardwaresecuritymodulesSku sku = default; + IList zones = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + NetworkProfile networkProfile = default; + NetworkProfile managementNetworkProfile = default; + string stampId = default; + string statusMessage = default; + JsonWebKeyType? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sku"u8)) + { + sku = HardwaresecuritymodulesSku.DeserializeHardwaresecuritymodulesSku(property.Value, options); + continue; + } + if (property.NameEquals("zones"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + zones = array; + continue; + } + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + 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 (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("networkProfile"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + networkProfile = NetworkProfile.DeserializeNetworkProfile(property0.Value, options); + continue; + } + if (property0.NameEquals("managementNetworkProfile"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managementNetworkProfile = NetworkProfile.DeserializeNetworkProfile(property0.Value, options); + continue; + } + if (property0.NameEquals("stampId"u8)) + { + stampId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("statusMessage"u8)) + { + statusMessage = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new JsonWebKeyType(property0.Value.GetString()); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DedicatedHsmData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + sku, + zones ?? new ChangeTrackingList(), + networkProfile, + managementNetworkProfile, + stampId, + statusMessage, + 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(DedicatedHsmData)} does not support writing '{options.Format}' format."); + } + } + + DedicatedHsmData 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDedicatedHsmData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DedicatedHsmData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmData.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmData.cs new file mode 100644 index 000000000000..7b153f435885 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmData.cs @@ -0,0 +1,125 @@ +// 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.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// + /// A class representing the DedicatedHsm data model. + /// Resource information with extended details. + /// + public partial class DedicatedHsmData : TrackedResourceData + { + /// + /// 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 location. + /// SKU details. + /// is null. + public DedicatedHsmData(AzureLocation location, HardwaresecuritymodulesSku sku) : base(location) + { + Argument.AssertNotNull(sku, nameof(sku)); + + Sku = sku; + Zones = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// SKU details. + /// The availability zones. + /// Specifies the network interfaces of the dedicated hsm. + /// Specifies the management network interfaces of the dedicated hsm. + /// This field will be used when RP does not support Availability zones. + /// Resource Status Message. + /// Provisioning state. + /// Keeps track of any properties unknown to the library. + internal DedicatedHsmData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, HardwaresecuritymodulesSku sku, IList zones, NetworkProfile networkProfile, NetworkProfile managementNetworkProfile, string stampId, string statusMessage, JsonWebKeyType? provisioningState, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Sku = sku; + Zones = zones; + NetworkProfile = networkProfile; + ManagementNetworkProfile = managementNetworkProfile; + StampId = stampId; + StatusMessage = statusMessage; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DedicatedHsmData() + { + } + + /// SKU details. + internal HardwaresecuritymodulesSku Sku { get; set; } + /// SKU of the dedicated HSM. + public HardwaresecuritymodulesSkuName? SkuName + { + get => Sku is null ? default : Sku.Name; + set + { + if (Sku is null) + Sku = new HardwaresecuritymodulesSku(); + Sku.Name = value; + } + } + + /// The availability zones. + public IList Zones { get; } + /// Specifies the network interfaces of the dedicated hsm. + public NetworkProfile NetworkProfile { get; set; } + /// Specifies the management network interfaces of the dedicated hsm. + public NetworkProfile ManagementNetworkProfile { get; set; } + /// This field will be used when RP does not support Availability zones. + public string StampId { get; set; } + /// Resource Status Message. + public string StatusMessage { get; } + /// Provisioning state. + public JsonWebKeyType? ProvisioningState { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmResource.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmResource.Serialization.cs new file mode 100644 index 000000000000..eefbc1c00e2d --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmResource.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.Hardwaresecuritymodules +{ + public partial class DedicatedHsmResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + DedicatedHsmData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerHardwaresecuritymodulesContext.Default); + + DedicatedHsmData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerHardwaresecuritymodulesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmResource.cs new file mode 100644 index 000000000000..7efa7fefad9a --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/DedicatedHsmResource.cs @@ -0,0 +1,768 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// + /// A Class representing a DedicatedHsm 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 GetDedicatedHsmResource method. + /// Otherwise you can get one from its parent resource using the GetDedicatedHsm method. + /// + public partial class DedicatedHsmResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The name. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string name) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _dedicatedHsmClientDiagnostics; + private readonly DedicatedHsmsRestOperations _dedicatedHsmRestClient; + private readonly DedicatedHsmData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.HardwareSecurityModules/dedicatedHSMs"; + + /// Initializes a new instance of the class for mocking. + protected DedicatedHsmResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DedicatedHsmResource(ArmClient client, DedicatedHsmData 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 DedicatedHsmResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _dedicatedHsmClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Hardwaresecuritymodules", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string dedicatedHsmApiVersion); + _dedicatedHsmRestClient = new DedicatedHsmsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dedicatedHsmApiVersion); +#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 DedicatedHsmData 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)); + } + + /// + /// Gets the specified Azure dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.Get"); + scope.Start(); + try + { + var response = await _dedicatedHsmRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DedicatedHsmResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Azure dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.Get"); + scope.Start(); + try + { + var response = _dedicatedHsmRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DedicatedHsmResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified Azure Dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Delete + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.Delete"); + scope.Start(); + try + { + var response = await _dedicatedHsmRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(_dedicatedHsmClientDiagnostics, Pipeline, _dedicatedHsmRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, 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; + } + } + + /// + /// Deletes the specified Azure Dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Delete + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.Delete"); + scope.Start(); + try + { + var response = _dedicatedHsmRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(_dedicatedHsmClientDiagnostics, Pipeline, _dedicatedHsmRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a dedicated HSM in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Update + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Parameters to patch the dedicated HSM. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DedicatedHsmPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.Update"); + scope.Start(); + try + { + var response = await _dedicatedHsmRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(new DedicatedHsmOperationSource(Client), _dedicatedHsmClientDiagnostics, Pipeline, _dedicatedHsmRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, 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 dedicated HSM in the specified subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Update + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Parameters to patch the dedicated HSM. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DedicatedHsmPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.Update"); + scope.Start(); + try + { + var response = _dedicatedHsmRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(new DedicatedHsmOperationSource(Client), _dedicatedHsmClientDiagnostics, Pipeline, _dedicatedHsmRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the specified dedicated hsm resource. The operation returns properties of each egress endpoint. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}/outboundNetworkDependenciesEndpoints + /// + /// + /// Operation Id + /// DedicatedHsms_ListOutboundNetworkDependenciesEndpoints + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetOutboundNetworkDependenciesEndpointsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _dedicatedHsmRestClient.CreateListOutboundNetworkDependenciesEndpointsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dedicatedHsmRestClient.CreateListOutboundNetworkDependenciesEndpointsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => OutboundEnvironmentEndpoint.DeserializeOutboundEnvironmentEndpoint(e), _dedicatedHsmClientDiagnostics, Pipeline, "DedicatedHsmResource.GetOutboundNetworkDependenciesEndpoints", "value", "nextLink", cancellationToken); + } + + /// + /// Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the specified dedicated hsm resource. The operation returns properties of each egress endpoint. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}/outboundNetworkDependenciesEndpoints + /// + /// + /// Operation Id + /// DedicatedHsms_ListOutboundNetworkDependenciesEndpoints + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetOutboundNetworkDependenciesEndpoints(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _dedicatedHsmRestClient.CreateListOutboundNetworkDependenciesEndpointsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dedicatedHsmRestClient.CreateListOutboundNetworkDependenciesEndpointsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => OutboundEnvironmentEndpoint.DeserializeOutboundEnvironmentEndpoint(e), _dedicatedHsmClientDiagnostics, Pipeline, "DedicatedHsmResource.GetOutboundNetworkDependenciesEndpoints", "value", "nextLink", cancellationToken); + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _dedicatedHsmRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new DedicatedHsmResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new DedicatedHsmPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _dedicatedHsmRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new DedicatedHsmResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new DedicatedHsmPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _dedicatedHsmRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new DedicatedHsmResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new DedicatedHsmPatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _dedicatedHsmRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new DedicatedHsmResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new DedicatedHsmPatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _dedicatedHsmRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new DedicatedHsmResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new DedicatedHsmPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _dedicatedHsmClientDiagnostics.CreateScope("DedicatedHsmResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _dedicatedHsmRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new DedicatedHsmResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new DedicatedHsmPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/HardwaresecuritymodulesExtensions.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/HardwaresecuritymodulesExtensions.cs new file mode 100644 index 000000000000..5cb1e8dbe63f --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/HardwaresecuritymodulesExtensions.cs @@ -0,0 +1,426 @@ +// 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.Hardwaresecuritymodules.Mocking; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// A class to add extension methods to Azure.ResourceManager.Hardwaresecuritymodules. + public static partial class HardwaresecuritymodulesExtensions + { + private static MockableHardwaresecuritymodulesArmClient GetMockableHardwaresecuritymodulesArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableHardwaresecuritymodulesArmClient(client0)); + } + + private static MockableHardwaresecuritymodulesResourceGroupResource GetMockableHardwaresecuritymodulesResourceGroupResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableHardwaresecuritymodulesResourceGroupResource(client, resource.Id)); + } + + private static MockableHardwaresecuritymodulesSubscriptionResource GetMockableHardwaresecuritymodulesSubscriptionResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableHardwaresecuritymodulesSubscriptionResource(client, resource.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 CloudHsmClusterResource GetCloudHsmClusterResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableHardwaresecuritymodulesArmClient(client).GetCloudHsmClusterResource(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 HardwaresecuritymodulesPrivateEndpointConnectionResource GetHardwaresecuritymodulesPrivateEndpointConnectionResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableHardwaresecuritymodulesArmClient(client).GetHardwaresecuritymodulesPrivateEndpointConnectionResource(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 DedicatedHsmResource GetDedicatedHsmResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableHardwaresecuritymodulesArmClient(client).GetDedicatedHsmResource(id); + } + + /// + /// Gets a collection of CloudHsmClusterResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of CloudHsmClusterResources and their operations over a CloudHsmClusterResource. + public static CloudHsmClusterCollection GetCloudHsmClusters(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableHardwaresecuritymodulesResourceGroupResource(resourceGroupResource).GetCloudHsmClusters(); + } + + /// + /// Gets the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetCloudHsmClusterAsync(this ResourceGroupResource resourceGroupResource, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableHardwaresecuritymodulesResourceGroupResource(resourceGroupResource).GetCloudHsmClusterAsync(cloudHsmClusterName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetCloudHsmCluster(this ResourceGroupResource resourceGroupResource, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableHardwaresecuritymodulesResourceGroupResource(resourceGroupResource).GetCloudHsmCluster(cloudHsmClusterName, cancellationToken); + } + + /// + /// Gets a collection of DedicatedHsmResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of DedicatedHsmResources and their operations over a DedicatedHsmResource. + public static DedicatedHsmCollection GetDedicatedHsms(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableHardwaresecuritymodulesResourceGroupResource(resourceGroupResource).GetDedicatedHsms(); + } + + /// + /// Gets the specified Azure dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetDedicatedHsmAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableHardwaresecuritymodulesResourceGroupResource(resourceGroupResource).GetDedicatedHsmAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified Azure dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetDedicatedHsm(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableHardwaresecuritymodulesResourceGroupResource(resourceGroupResource).GetDedicatedHsm(name, cancellationToken); + } + + /// + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters + /// + /// + /// Operation Id + /// CloudHsmCluster_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetCloudHsmClustersAsync(this SubscriptionResource subscriptionResource, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableHardwaresecuritymodulesSubscriptionResource(subscriptionResource).GetCloudHsmClustersAsync(skiptoken, cancellationToken); + } + + /// + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters + /// + /// + /// Operation Id + /// CloudHsmCluster_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetCloudHsmClusters(this SubscriptionResource subscriptionResource, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableHardwaresecuritymodulesSubscriptionResource(subscriptionResource).GetCloudHsmClusters(skiptoken, cancellationToken); + } + + /// + /// The List operation gets information about the dedicated HSMs associated with the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs + /// + /// + /// Operation Id + /// DedicatedHsm_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Maximum number of results to return. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetDedicatedHsmsAsync(this SubscriptionResource subscriptionResource, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableHardwaresecuritymodulesSubscriptionResource(subscriptionResource).GetDedicatedHsmsAsync(top, cancellationToken); + } + + /// + /// The List operation gets information about the dedicated HSMs associated with the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs + /// + /// + /// Operation Id + /// DedicatedHsm_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Maximum number of results to return. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetDedicatedHsms(this SubscriptionResource subscriptionResource, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableHardwaresecuritymodulesSubscriptionResource(subscriptionResource).GetDedicatedHsms(top, cancellationToken); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/MockableHardwaresecuritymodulesArmClient.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/MockableHardwaresecuritymodulesArmClient.cs new file mode 100644 index 000000000000..0dae8b9b1881 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/MockableHardwaresecuritymodulesArmClient.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableHardwaresecuritymodulesArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableHardwaresecuritymodulesArmClient() + { + } + + /// 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 MockableHardwaresecuritymodulesArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableHardwaresecuritymodulesArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 CloudHsmClusterResource GetCloudHsmClusterResource(ResourceIdentifier id) + { + CloudHsmClusterResource.ValidateResourceId(id); + return new CloudHsmClusterResource(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 HardwaresecuritymodulesPrivateEndpointConnectionResource GetHardwaresecuritymodulesPrivateEndpointConnectionResource(ResourceIdentifier id) + { + HardwaresecuritymodulesPrivateEndpointConnectionResource.ValidateResourceId(id); + return new HardwaresecuritymodulesPrivateEndpointConnectionResource(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 DedicatedHsmResource GetDedicatedHsmResource(ResourceIdentifier id) + { + DedicatedHsmResource.ValidateResourceId(id); + return new DedicatedHsmResource(Client, id); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/MockableHardwaresecuritymodulesResourceGroupResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/MockableHardwaresecuritymodulesResourceGroupResource.cs new file mode 100644 index 000000000000..760b6e5e29d6 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/MockableHardwaresecuritymodulesResourceGroupResource.cs @@ -0,0 +1,174 @@ +// 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.Hardwaresecuritymodules.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableHardwaresecuritymodulesResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableHardwaresecuritymodulesResourceGroupResource() + { + } + + /// 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 MockableHardwaresecuritymodulesResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of CloudHsmClusterResources in the ResourceGroupResource. + /// An object representing collection of CloudHsmClusterResources and their operations over a CloudHsmClusterResource. + public virtual CloudHsmClusterCollection GetCloudHsmClusters() + { + return GetCachedClient(client => new CloudHsmClusterCollection(client, Id)); + } + + /// + /// Gets the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetCloudHsmClusterAsync(string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + return await GetCloudHsmClusters().GetAsync(cloudHsmClusterName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName} + /// + /// + /// Operation Id + /// CloudHsmCluster_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetCloudHsmCluster(string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + return GetCloudHsmClusters().Get(cloudHsmClusterName, cancellationToken); + } + + /// Gets a collection of DedicatedHsmResources in the ResourceGroupResource. + /// An object representing collection of DedicatedHsmResources and their operations over a DedicatedHsmResource. + public virtual DedicatedHsmCollection GetDedicatedHsms() + { + return GetCachedClient(client => new DedicatedHsmCollection(client, Id)); + } + + /// + /// Gets the specified Azure dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDedicatedHsmAsync(string name, CancellationToken cancellationToken = default) + { + return await GetDedicatedHsms().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified Azure dedicated HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name} + /// + /// + /// Operation Id + /// DedicatedHsm_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDedicatedHsm(string name, CancellationToken cancellationToken = default) + { + return GetDedicatedHsms().Get(name, cancellationToken); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/MockableHardwaresecuritymodulesSubscriptionResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/MockableHardwaresecuritymodulesSubscriptionResource.cs new file mode 100644 index 000000000000..0931644f3844 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Extensions/MockableHardwaresecuritymodulesSubscriptionResource.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableHardwaresecuritymodulesSubscriptionResource : ArmResource + { + private ClientDiagnostics _cloudHsmClusterClientDiagnostics; + private CloudHsmClustersRestOperations _cloudHsmClusterRestClient; + private ClientDiagnostics _dedicatedHsmClientDiagnostics; + private DedicatedHsmsRestOperations _dedicatedHsmRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableHardwaresecuritymodulesSubscriptionResource() + { + } + + /// 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 MockableHardwaresecuritymodulesSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics CloudHsmClusterClientDiagnostics => _cloudHsmClusterClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Hardwaresecuritymodules", CloudHsmClusterResource.ResourceType.Namespace, Diagnostics); + private CloudHsmClustersRestOperations CloudHsmClusterRestClient => _cloudHsmClusterRestClient ??= new CloudHsmClustersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(CloudHsmClusterResource.ResourceType)); + private ClientDiagnostics DedicatedHsmClientDiagnostics => _dedicatedHsmClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Hardwaresecuritymodules", DedicatedHsmResource.ResourceType.Namespace, Diagnostics); + private DedicatedHsmsRestOperations DedicatedHsmRestClient => _dedicatedHsmRestClient ??= new DedicatedHsmsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(DedicatedHsmResource.ResourceType)); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters + /// + /// + /// Operation Id + /// CloudHsmCluster_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetCloudHsmClustersAsync(string skiptoken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CloudHsmClusterRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, skiptoken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CloudHsmClusterRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, skiptoken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CloudHsmClusterResource(Client, CloudHsmClusterData.DeserializeCloudHsmClusterData(e)), CloudHsmClusterClientDiagnostics, Pipeline, "MockableHardwaresecuritymodulesSubscriptionResource.GetCloudHsmClusters", "value", "nextLink", cancellationToken); + } + + /// + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters + /// + /// + /// Operation Id + /// CloudHsmCluster_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetCloudHsmClusters(string skiptoken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CloudHsmClusterRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, skiptoken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CloudHsmClusterRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, skiptoken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CloudHsmClusterResource(Client, CloudHsmClusterData.DeserializeCloudHsmClusterData(e)), CloudHsmClusterClientDiagnostics, Pipeline, "MockableHardwaresecuritymodulesSubscriptionResource.GetCloudHsmClusters", "value", "nextLink", cancellationToken); + } + + /// + /// The List operation gets information about the dedicated HSMs associated with the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs + /// + /// + /// Operation Id + /// DedicatedHsm_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Maximum number of results to return. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetDedicatedHsmsAsync(int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => DedicatedHsmRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DedicatedHsmRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, top); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DedicatedHsmResource(Client, DedicatedHsmData.DeserializeDedicatedHsmData(e)), DedicatedHsmClientDiagnostics, Pipeline, "MockableHardwaresecuritymodulesSubscriptionResource.GetDedicatedHsms", "value", "nextLink", cancellationToken); + } + + /// + /// The List operation gets information about the dedicated HSMs associated with the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs + /// + /// + /// Operation Id + /// DedicatedHsm_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Maximum number of results to return. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetDedicatedHsms(int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => DedicatedHsmRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DedicatedHsmRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, top); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DedicatedHsmResource(Client, DedicatedHsmData.DeserializeDedicatedHsmData(e)), DedicatedHsmClientDiagnostics, Pipeline, "MockableHardwaresecuritymodulesSubscriptionResource.GetDedicatedHsms", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionCollection.cs new file mode 100644 index 000000000000..420f27af55c5 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionCollection.cs @@ -0,0 +1,497 @@ +// 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.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// + /// 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 GetHardwaresecuritymodulesPrivateEndpointConnections method from an instance of . + /// + public partial class HardwaresecuritymodulesPrivateEndpointConnectionCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics; + private readonly PrivateEndpointConnectionsRestOperations _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient; + + /// Initializes a new instance of the class for mocking. + protected HardwaresecuritymodulesPrivateEndpointConnectionCollection() + { + } + + /// 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 HardwaresecuritymodulesPrivateEndpointConnectionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Hardwaresecuritymodules", HardwaresecuritymodulesPrivateEndpointConnectionResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(HardwaresecuritymodulesPrivateEndpointConnectionResource.ResourceType, out string hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); + _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient = new PrivateEndpointConnectionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CloudHsmClusterResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CloudHsmClusterResource.ResourceType), nameof(id)); + } + + /// + /// Creates or updates the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Create + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// Parameters of the PrivateEndpointConnection. + /// 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 peConnectionName, HardwaresecuritymodulesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, data, cancellationToken).ConfigureAwait(false); + var uri = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateCreateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new HardwaresecuritymodulesArmOperation(Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Create + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// Parameters of the PrivateEndpointConnection. + /// 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 peConnectionName, HardwaresecuritymodulesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, data, cancellationToken); + var uri = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateCreateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new HardwaresecuritymodulesArmOperation(Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionCollection.Get"); + scope.Start(); + try + { + var response = await _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionCollection.Get"); + scope.Start(); + try + { + var response = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// The List operation gets information about the private endpoint connections associated with the Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections + /// + /// + /// Operation Id + /// PrivateEndpointConnection_ListByCloudHsmCluster + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// 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) => _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListByCloudHsmClusterRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListByCloudHsmClusterNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, HardwaresecuritymodulesPrivateEndpointConnectionData.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(e)), _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, "HardwaresecuritymodulesPrivateEndpointConnectionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// The List operation gets information about the private endpoint connections associated with the Cloud HSM Cluster + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections + /// + /// + /// Operation Id + /// PrivateEndpointConnection_ListByCloudHsmCluster + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// 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) => _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListByCloudHsmClusterRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListByCloudHsmClusterNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, HardwaresecuritymodulesPrivateEndpointConnectionData.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(e)), _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, "HardwaresecuritymodulesPrivateEndpointConnectionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionCollection.Exists"); + scope.Start(); + try + { + var response = await _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, 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 + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionCollection.Exists"); + scope.Start(); + try + { + var response = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, 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 + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionCollection.GetIfExists"); + scope.Start(); + try + { + var response = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, peConnectionName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionData.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionData.Serialization.cs new file mode 100644 index 000000000000..13b9009b8408 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionData.Serialization.cs @@ -0,0 +1,241 @@ +// 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.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + public partial class HardwaresecuritymodulesPrivateEndpointConnectionData : 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(HardwaresecuritymodulesPrivateEndpointConnectionData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(PrivateEndpoint)) + { + writer.WritePropertyName("privateEndpoint"u8); + JsonSerializer.Serialize(writer, PrivateEndpoint); + } + if (Optional.IsDefined(PrivateLinkServiceConnectionState)) + { + writer.WritePropertyName("privateLinkServiceConnectionState"u8); + writer.WriteObjectValue(PrivateLinkServiceConnectionState, options); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(GroupIds)) + { + writer.WritePropertyName("groupIds"u8); + writer.WriteStartArray(); + foreach (var item in GroupIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + HardwaresecuritymodulesPrivateEndpointConnectionData 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(HardwaresecuritymodulesPrivateEndpointConnectionData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(document.RootElement, options); + } + + internal static HardwaresecuritymodulesPrivateEndpointConnectionData DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string etag = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + SubResource privateEndpoint = default; + HardwaresecuritymodulesPrivateLinkServiceConnectionState privateLinkServiceConnectionState = default; + HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState? provisioningState = default; + IReadOnlyList groupIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("etag"u8)) + { + etag = property.Value.GetString(); + 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 (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("privateEndpoint"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateEndpoint = JsonSerializer.Deserialize(property0.Value.GetRawText()); + continue; + } + if (property0.NameEquals("privateLinkServiceConnectionState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateLinkServiceConnectionState = HardwaresecuritymodulesPrivateLinkServiceConnectionState.DeserializeHardwaresecuritymodulesPrivateLinkServiceConnectionState(property0.Value, options); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("groupIds"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + groupIds = array; + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HardwaresecuritymodulesPrivateEndpointConnectionData( + id, + name, + type, + systemData, + privateEndpoint, + privateLinkServiceConnectionState, + provisioningState, + groupIds ?? new ChangeTrackingList(), + etag, + 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateEndpointConnectionData)} does not support writing '{options.Format}' format."); + } + } + + HardwaresecuritymodulesPrivateEndpointConnectionData 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateEndpointConnectionData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionData.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionData.cs new file mode 100644 index 000000000000..669aafa1283f --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionData.cs @@ -0,0 +1,99 @@ +// 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.Hardwaresecuritymodules.Models; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// + /// A class representing the HardwaresecuritymodulesPrivateEndpointConnection data model. + /// The private endpoint connection resource. + /// + public partial class HardwaresecuritymodulesPrivateEndpointConnectionData : 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 HardwaresecuritymodulesPrivateEndpointConnectionData() + { + GroupIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The private endpoint resource. + /// A collection of information about the state of the connection between service consumer and provider. + /// The provisioning state of the private endpoint connection resource. + /// The group ids for the private endpoint resource. + /// Modified whenever there is a change in the state of private endpoint connection. + /// Keeps track of any properties unknown to the library. + internal HardwaresecuritymodulesPrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, SubResource privateEndpoint, HardwaresecuritymodulesPrivateLinkServiceConnectionState privateLinkServiceConnectionState, HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState? provisioningState, IReadOnlyList groupIds, string etag, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + PrivateEndpoint = privateEndpoint; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + ProvisioningState = provisioningState; + GroupIds = groupIds; + ETag = etag; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The private endpoint resource. + internal SubResource PrivateEndpoint { get; set; } + /// Gets Id. + public ResourceIdentifier PrivateEndpointId + { + get => PrivateEndpoint is null ? default : PrivateEndpoint.Id; + } + + /// A collection of information about the state of the connection between service consumer and provider. + public HardwaresecuritymodulesPrivateLinkServiceConnectionState PrivateLinkServiceConnectionState { get; set; } + /// The provisioning state of the private endpoint connection resource. + public HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState? ProvisioningState { get; } + /// The group ids for the private endpoint resource. + public IReadOnlyList GroupIds { get; } + /// Modified whenever there is a change in the state of private endpoint connection. + public string ETag { get; set; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionResource.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionResource.Serialization.cs new file mode 100644 index 000000000000..2eb3995e7144 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionResource.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.Hardwaresecuritymodules +{ + public partial class HardwaresecuritymodulesPrivateEndpointConnectionResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + HardwaresecuritymodulesPrivateEndpointConnectionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerHardwaresecuritymodulesContext.Default); + + HardwaresecuritymodulesPrivateEndpointConnectionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerHardwaresecuritymodulesContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionResource.cs new file mode 100644 index 000000000000..d49e28113bfc --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/HardwaresecuritymodulesPrivateEndpointConnectionResource.cs @@ -0,0 +1,351 @@ +// 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.Hardwaresecuritymodules +{ + /// + /// A Class representing a HardwaresecuritymodulesPrivateEndpointConnection 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 GetHardwaresecuritymodulesPrivateEndpointConnectionResource method. + /// Otherwise you can get one from its parent resource using the GetHardwaresecuritymodulesPrivateEndpointConnection method. + /// + public partial class HardwaresecuritymodulesPrivateEndpointConnectionResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The cloudHsmClusterName. + /// The peConnectionName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics; + private readonly PrivateEndpointConnectionsRestOperations _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient; + private readonly HardwaresecuritymodulesPrivateEndpointConnectionData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.HardwareSecurityModules/cloudHsmClusters/privateEndpointConnections"; + + /// Initializes a new instance of the class for mocking. + protected HardwaresecuritymodulesPrivateEndpointConnectionResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal HardwaresecuritymodulesPrivateEndpointConnectionResource(ArmClient client, HardwaresecuritymodulesPrivateEndpointConnectionData 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 HardwaresecuritymodulesPrivateEndpointConnectionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Hardwaresecuritymodules", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); + _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient = new PrivateEndpointConnectionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); +#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 HardwaresecuritymodulesPrivateEndpointConnectionData 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)); + } + + /// + /// Gets the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionResource.Get"); + scope.Start(); + try + { + var response = await _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Get + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionResource.Get"); + scope.Start(); + try + { + var response = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Delete + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionResource.Delete"); + scope.Start(); + try + { + var response = await _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new HardwaresecuritymodulesArmOperation(_hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, 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; + } + } + + /// + /// Deletes the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Delete + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionResource.Delete"); + scope.Start(); + try + { + var response = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new HardwaresecuritymodulesArmOperation(_hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Create + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Parameters of the PrivateEndpointConnection. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, HardwaresecuritymodulesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionResource.Update"); + scope.Start(); + try + { + var response = await _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateCreateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new HardwaresecuritymodulesArmOperation(Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates the private endpoint connection for the Cloud Hsm Cluster. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnection_Create + /// + /// + /// Default Api Version + /// 2024-06-30-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Parameters of the PrivateEndpointConnection. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, HardwaresecuritymodulesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("HardwaresecuritymodulesPrivateEndpointConnectionResource.Update"); + scope.Start(); + try + { + var response = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _hardwaresecuritymodulesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateCreateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new HardwaresecuritymodulesArmOperation(Response.FromValue(new HardwaresecuritymodulesPrivateEndpointConnectionResource(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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/Argument.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..6e53dee66bc3 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/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.Hardwaresecuritymodules +{ + 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..02ba06b9c039 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/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.Hardwaresecuritymodules +{ + 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/ChangeTrackingList.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..95edc1ab8d74 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/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.Hardwaresecuritymodules +{ + 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..e63ecd5e729a --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,407 @@ +// 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.Hardwaresecuritymodules +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + + 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 bool IsSentinelValue(BinaryData value) + { + ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; + ReadOnlySpan valueSpan = value.ToMemory().Span; + return sentinelSpan.SequenceEqual(valueSpan); + } + + 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/Optional.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..fd797a36288b --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/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.Hardwaresecuritymodules +{ + 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..8467330a3cdb --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/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.Hardwaresecuritymodules +{ + 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/CloudHsmClusterOperationSource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/CloudHsmClusterOperationSource.cs new file mode 100644 index 000000000000..9273d188afa3 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/CloudHsmClusterOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + internal class CloudHsmClusterOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal CloudHsmClusterOperationSource(ArmClient client) + { + _client = client; + } + + CloudHsmClusterResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerHardwaresecuritymodulesContext.Default); + return new CloudHsmClusterResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerHardwaresecuritymodulesContext.Default); + return await Task.FromResult(new CloudHsmClusterResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/DedicatedHsmOperationSource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/DedicatedHsmOperationSource.cs new file mode 100644 index 000000000000..d5ffba0a0c63 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/DedicatedHsmOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + internal class DedicatedHsmOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal DedicatedHsmOperationSource(ArmClient client) + { + _client = client; + } + + DedicatedHsmResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerHardwaresecuritymodulesContext.Default); + return new DedicatedHsmResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerHardwaresecuritymodulesContext.Default); + return await Task.FromResult(new DedicatedHsmResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/HardwaresecuritymodulesArmOperation.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/HardwaresecuritymodulesArmOperation.cs new file mode 100644 index 000000000000..3e8ecd56e8c6 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/HardwaresecuritymodulesArmOperation.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.Hardwaresecuritymodules +{ +#pragma warning disable SA1649 // File name should match first type name + internal class HardwaresecuritymodulesArmOperation : 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 HardwaresecuritymodulesArmOperation for mocking. + protected HardwaresecuritymodulesArmOperation() + { + } + + internal HardwaresecuritymodulesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal HardwaresecuritymodulesArmOperation(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, "HardwaresecuritymodulesArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerHardwaresecuritymodulesContext.Default).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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/HardwaresecuritymodulesArmOperationOfT.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/HardwaresecuritymodulesArmOperationOfT.cs new file mode 100644 index 000000000000..dbd875ba75ab --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/LongRunningOperation/HardwaresecuritymodulesArmOperationOfT.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.Hardwaresecuritymodules +{ +#pragma warning disable SA1649 // File name should match first type name + internal class HardwaresecuritymodulesArmOperation : 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 HardwaresecuritymodulesArmOperation for mocking. + protected HardwaresecuritymodulesArmOperation() + { + } + + internal HardwaresecuritymodulesArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal HardwaresecuritymodulesArmOperation(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, "HardwaresecuritymodulesArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerHardwaresecuritymodulesContext.Default).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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ActivationState.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ActivationState.cs new file mode 100644 index 000000000000..4030b8288f7e --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ActivationState.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.Hardwaresecuritymodules.Models +{ + /// State of security domain activation. + public readonly partial struct ActivationState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ActivationState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotDefinedValue = "NotDefined"; + private const string NotActivatedValue = "NotActivated"; + private const string ActiveValue = "Active"; + private const string FailedValue = "Failed"; + private const string UnknownValue = "Unknown"; + + /// NotDefined. + public static ActivationState NotDefined { get; } = new ActivationState(NotDefinedValue); + /// NotActivated. + public static ActivationState NotActivated { get; } = new ActivationState(NotActivatedValue); + /// Active. + public static ActivationState Active { get; } = new ActivationState(ActiveValue); + /// Failed. + public static ActivationState Failed { get; } = new ActivationState(FailedValue); + /// Unknown. + public static ActivationState Unknown { get; } = new ActivationState(UnknownValue); + /// Determines if two values are the same. + public static bool operator ==(ActivationState left, ActivationState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ActivationState left, ActivationState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ActivationState(string value) => new ActivationState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ActivationState other && Equals(other); + /// + public bool Equals(ActivationState 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ApiEntityReference.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ApiEntityReference.Serialization.cs new file mode 100644 index 000000000000..56ad88ae16fe --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ApiEntityReference.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.Hardwaresecuritymodules.Models +{ + internal partial class ApiEntityReference : 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(ApiEntityReference)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ResourceId)) + { + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApiEntityReference 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(ApiEntityReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApiEntityReference(document.RootElement, options); + } + + internal static ApiEntityReference DeserializeApiEntityReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier resourceId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApiEntityReference(resourceId, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(ApiEntityReference)} does not support writing '{options.Format}' format."); + } + } + + ApiEntityReference 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApiEntityReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApiEntityReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ApiEntityReference.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ApiEntityReference.cs new file mode 100644 index 000000000000..07cc9efc0915 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ApiEntityReference.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// The API entity reference. + internal partial class ApiEntityReference + { + /// + /// 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 ApiEntityReference() + { + } + + /// Initializes a new instance of . + /// The Azure resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... + /// Keeps track of any properties unknown to the library. + internal ApiEntityReference(ResourceIdentifier resourceId, IDictionary serializedAdditionalRawData) + { + ResourceId = resourceId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The Azure resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... + public ResourceIdentifier ResourceId { get; set; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/AutoGeneratedDomainNameLabelScope.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/AutoGeneratedDomainNameLabelScope.cs new file mode 100644 index 000000000000..4f16353e0346 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/AutoGeneratedDomainNameLabelScope.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.Hardwaresecuritymodules.Models +{ + /// The Cloud HSM Cluster's auto-generated Domain Name Label Scope. + public readonly partial struct AutoGeneratedDomainNameLabelScope : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AutoGeneratedDomainNameLabelScope(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TenantReuseValue = "TenantReuse"; + private const string SubscriptionReuseValue = "SubscriptionReuse"; + private const string ResourceGroupReuseValue = "ResourceGroupReuse"; + private const string NoReuseValue = "NoReuse"; + + /// TenantReuse. + public static AutoGeneratedDomainNameLabelScope TenantReuse { get; } = new AutoGeneratedDomainNameLabelScope(TenantReuseValue); + /// SubscriptionReuse. + public static AutoGeneratedDomainNameLabelScope SubscriptionReuse { get; } = new AutoGeneratedDomainNameLabelScope(SubscriptionReuseValue); + /// ResourceGroupReuse. + public static AutoGeneratedDomainNameLabelScope ResourceGroupReuse { get; } = new AutoGeneratedDomainNameLabelScope(ResourceGroupReuseValue); + /// NoReuse. + public static AutoGeneratedDomainNameLabelScope NoReuse { get; } = new AutoGeneratedDomainNameLabelScope(NoReuseValue); + /// Determines if two values are the same. + public static bool operator ==(AutoGeneratedDomainNameLabelScope left, AutoGeneratedDomainNameLabelScope right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AutoGeneratedDomainNameLabelScope left, AutoGeneratedDomainNameLabelScope right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AutoGeneratedDomainNameLabelScope(string value) => new AutoGeneratedDomainNameLabelScope(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AutoGeneratedDomainNameLabelScope other && Equals(other); + /// + public bool Equals(AutoGeneratedDomainNameLabelScope 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/AzureResourceManagerHardwaresecuritymodulesContext.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/AzureResourceManagerHardwaresecuritymodulesContext.cs new file mode 100644 index 000000000000..500e5ebf0ebc --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/AzureResourceManagerHardwaresecuritymodulesContext.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// + public partial class AzureResourceManagerHardwaresecuritymodulesContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRequestProperties.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRequestProperties.Serialization.cs new file mode 100644 index 000000000000..7eccd9cf9ba3 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRequestProperties.Serialization.cs @@ -0,0 +1,116 @@ +// 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.Hardwaresecuritymodules.Models +{ + public partial class BackupRequestProperties : 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(BackupRequestProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + BackupRequestProperties 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(BackupRequestProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBackupRequestProperties(document.RootElement, options); + } + + internal static BackupRequestProperties DeserializeBackupRequestProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri azureStorageBlobContainerUri = default; + string token = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("azureStorageBlobContainerUri"u8)) + { + azureStorageBlobContainerUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("token"u8)) + { + token = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BackupRequestProperties(azureStorageBlobContainerUri, token, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(BackupRequestProperties)} does not support writing '{options.Format}' format."); + } + } + + BackupRequestProperties 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBackupRequestProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BackupRequestProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRequestProperties.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRequestProperties.cs new file mode 100644 index 000000000000..46373e3f552e --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRequestProperties.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Backup properties. + public partial class BackupRequestProperties : BackupRestoreRequestBaseProperties + { + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// is null. + public BackupRequestProperties(Uri azureStorageBlobContainerUri) : base(azureStorageBlobContainerUri) + { + Argument.AssertNotNull(azureStorageBlobContainerUri, nameof(azureStorageBlobContainerUri)); + } + + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// The SAS token pointing to an Azure blob storage container. This property is reserved for Azure Backup Service. + /// Keeps track of any properties unknown to the library. + internal BackupRequestProperties(Uri azureStorageBlobContainerUri, string token, IDictionary serializedAdditionalRawData) : base(azureStorageBlobContainerUri, token, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal BackupRequestProperties() + { + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRestoreOperationStatus.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRestoreOperationStatus.cs new file mode 100644 index 000000000000..9157e4a742a9 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRestoreOperationStatus.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.Hardwaresecuritymodules.Models +{ + /// Status of the backup/restore operation. + public readonly partial struct BackupRestoreOperationStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public BackupRestoreOperationStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "InProgress"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CancelledValue = "Cancelled"; + + /// InProgress. + public static BackupRestoreOperationStatus InProgress { get; } = new BackupRestoreOperationStatus(InProgressValue); + /// Succeeded. + public static BackupRestoreOperationStatus Succeeded { get; } = new BackupRestoreOperationStatus(SucceededValue); + /// Failed. + public static BackupRestoreOperationStatus Failed { get; } = new BackupRestoreOperationStatus(FailedValue); + /// Cancelled. + public static BackupRestoreOperationStatus Cancelled { get; } = new BackupRestoreOperationStatus(CancelledValue); + /// Determines if two values are the same. + public static bool operator ==(BackupRestoreOperationStatus left, BackupRestoreOperationStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(BackupRestoreOperationStatus left, BackupRestoreOperationStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator BackupRestoreOperationStatus(string value) => new BackupRestoreOperationStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is BackupRestoreOperationStatus other && Equals(other); + /// + public bool Equals(BackupRestoreOperationStatus 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRestoreRequestBaseProperties.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRestoreRequestBaseProperties.Serialization.cs new file mode 100644 index 000000000000..df98530456b3 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRestoreRequestBaseProperties.Serialization.cs @@ -0,0 +1,137 @@ +// 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.Hardwaresecuritymodules.Models +{ + public partial class BackupRestoreRequestBaseProperties : 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(BackupRestoreRequestBaseProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("azureStorageBlobContainerUri"u8); + writer.WriteStringValue(AzureStorageBlobContainerUri.AbsoluteUri); + if (Optional.IsDefined(Token)) + { + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + BackupRestoreRequestBaseProperties 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(BackupRestoreRequestBaseProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBackupRestoreRequestBaseProperties(document.RootElement, options); + } + + internal static BackupRestoreRequestBaseProperties DeserializeBackupRestoreRequestBaseProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri azureStorageBlobContainerUri = default; + string token = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("azureStorageBlobContainerUri"u8)) + { + azureStorageBlobContainerUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("token"u8)) + { + token = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BackupRestoreRequestBaseProperties(azureStorageBlobContainerUri, token, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(BackupRestoreRequestBaseProperties)} does not support writing '{options.Format}' format."); + } + } + + BackupRestoreRequestBaseProperties 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBackupRestoreRequestBaseProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BackupRestoreRequestBaseProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRestoreRequestBaseProperties.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRestoreRequestBaseProperties.cs new file mode 100644 index 000000000000..095135311535 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupRestoreRequestBaseProperties.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Backup and Restore Common properties. + public partial class BackupRestoreRequestBaseProperties + { + /// + /// 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 . + /// The Azure blob storage container Uri which contains the backup. + /// is null. + public BackupRestoreRequestBaseProperties(Uri azureStorageBlobContainerUri) + { + Argument.AssertNotNull(azureStorageBlobContainerUri, nameof(azureStorageBlobContainerUri)); + + AzureStorageBlobContainerUri = azureStorageBlobContainerUri; + } + + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// The SAS token pointing to an Azure blob storage container. This property is reserved for Azure Backup Service. + /// Keeps track of any properties unknown to the library. + internal BackupRestoreRequestBaseProperties(Uri azureStorageBlobContainerUri, string token, IDictionary serializedAdditionalRawData) + { + AzureStorageBlobContainerUri = azureStorageBlobContainerUri; + Token = token; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BackupRestoreRequestBaseProperties() + { + } + + /// The Azure blob storage container Uri which contains the backup. + public Uri AzureStorageBlobContainerUri { get; } + /// The SAS token pointing to an Azure blob storage container. This property is reserved for Azure Backup Service. + public string Token { get; set; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupResult.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupResult.Serialization.cs new file mode 100644 index 000000000000..7b49e39151ad --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupResult.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class BackupResult : 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(BackupResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(AzureStorageBlobContainerUri)) + { + writer.WritePropertyName("azureStorageBlobContainerUri"u8); + writer.WriteStringValue(AzureStorageBlobContainerUri.AbsoluteUri); + } + if (Optional.IsDefined(BackupId)) + { + writer.WritePropertyName("backupId"u8); + writer.WriteStringValue(BackupId); + } + writer.WriteEndObject(); + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + BackupResult 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(BackupResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBackupResult(document.RootElement, options); + } + + internal static BackupResult DeserializeBackupResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri azureStorageBlobContainerUri = default; + string backupId = 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) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("azureStorageBlobContainerUri"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + azureStorageBlobContainerUri = new Uri(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("backupId"u8)) + { + backupId = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BackupResult(azureStorageBlobContainerUri, backupId, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(BackupResult)} does not support writing '{options.Format}' format."); + } + } + + BackupResult 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBackupResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BackupResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupResult.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupResult.cs new file mode 100644 index 000000000000..7ede06430628 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/BackupResult.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.Hardwaresecuritymodules.Models +{ + /// Backup operation Result. + public partial class BackupResult + { + /// + /// 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 . + internal BackupResult() + { + } + + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// The ID of the backup. + /// Keeps track of any properties unknown to the library. + internal BackupResult(Uri azureStorageBlobContainerUri, string backupId, IDictionary serializedAdditionalRawData) + { + AzureStorageBlobContainerUri = azureStorageBlobContainerUri; + BackupId = backupId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The Azure blob storage container Uri which contains the backup. + public Uri AzureStorageBlobContainerUri { get; } + /// The ID of the backup. + public string BackupId { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterListResult.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterListResult.Serialization.cs new file mode 100644 index 000000000000..9d1ca53f74cf --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterListResult.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.Hardwaresecuritymodules.Models +{ + internal partial class CloudHsmClusterListResult : 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(CloudHsmClusterListResult)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CloudHsmClusterListResult 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(CloudHsmClusterListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCloudHsmClusterListResult(document.RootElement, options); + } + + internal static CloudHsmClusterListResult DeserializeCloudHsmClusterListResult(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(CloudHsmClusterData.DeserializeCloudHsmClusterData(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 CloudHsmClusterListResult(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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(CloudHsmClusterListResult)} does not support writing '{options.Format}' format."); + } + } + + CloudHsmClusterListResult 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCloudHsmClusterListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CloudHsmClusterListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterListResult.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterListResult.cs new file mode 100644 index 000000000000..b73511b62200 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterListResult.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.Hardwaresecuritymodules.Models +{ + /// The response of a CloudHsmCluster list operation. + internal partial class CloudHsmClusterListResult + { + /// + /// 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 CloudHsmCluster items on this page. + /// is null. + internal CloudHsmClusterListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The CloudHsmCluster items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal CloudHsmClusterListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CloudHsmClusterListResult() + { + } + + /// The CloudHsmCluster items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterPatch.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterPatch.Serialization.cs new file mode 100644 index 000000000000..f939a07e5487 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterPatch.Serialization.cs @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class CloudHsmClusterPatch : 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(CloudHsmClusterPatch)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + JsonSerializer.Serialize(writer, Identity, serializeOptions); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CloudHsmClusterPatch 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(CloudHsmClusterPatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCloudHsmClusterPatch(document.RootElement, options); + } + + internal static CloudHsmClusterPatch DeserializeCloudHsmClusterPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + ManagedServiceIdentity identity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; + identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CloudHsmClusterPatch(tags ?? new ChangeTrackingDictionary(), identity, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(CloudHsmClusterPatch)} does not support writing '{options.Format}' format."); + } + } + + CloudHsmClusterPatch 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCloudHsmClusterPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CloudHsmClusterPatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterPatch.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterPatch.cs new file mode 100644 index 000000000000..379e41bda086 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterPatch.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Patchable properties of the Cloud HSM Cluster. + public partial class CloudHsmClusterPatch + { + /// + /// 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 CloudHsmClusterPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The Cloud HSM Cluster's tags. + /// Managed service identity (system assigned and/or user assigned identities). + /// Keeps track of any properties unknown to the library. + internal CloudHsmClusterPatch(IDictionary tags, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) + { + Tags = tags; + Identity = identity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The Cloud HSM Cluster's tags. + public IDictionary Tags { get; } + /// Managed service identity (system assigned and/or user assigned identities). + public ManagedServiceIdentity Identity { get; set; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSku.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSku.Serialization.cs new file mode 100644 index 000000000000..bacd8c4846ec --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSku.Serialization.cs @@ -0,0 +1,149 @@ +// 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.Hardwaresecuritymodules.Models +{ + public partial class CloudHsmClusterSku : 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(CloudHsmClusterSku)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("family"u8); + writer.WriteStringValue(Family.ToString()); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.ToSerialString()); + if (Optional.IsDefined(Capacity)) + { + writer.WritePropertyName("capacity"u8); + writer.WriteNumberValue(Capacity.Value); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CloudHsmClusterSku 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(CloudHsmClusterSku)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCloudHsmClusterSku(document.RootElement, options); + } + + internal static CloudHsmClusterSku DeserializeCloudHsmClusterSku(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CloudHsmClusterSkuFamily family = default; + CloudHsmClusterSkuName name = default; + int? capacity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("family"u8)) + { + family = new CloudHsmClusterSkuFamily(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString().ToCloudHsmClusterSkuName(); + continue; + } + if (property.NameEquals("capacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + capacity = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CloudHsmClusterSku(family, name, capacity, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(CloudHsmClusterSku)} does not support writing '{options.Format}' format."); + } + } + + CloudHsmClusterSku 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCloudHsmClusterSku(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CloudHsmClusterSku)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSku.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSku.cs new file mode 100644 index 000000000000..ede22f8ce0d0 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSku.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Cloud Hsm Cluster SKU information. + public partial class CloudHsmClusterSku + { + /// + /// 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 . + /// Sku family of the Cloud HSM Cluster. + /// Sku name of the Cloud HSM Cluster. + public CloudHsmClusterSku(CloudHsmClusterSkuFamily family, CloudHsmClusterSkuName name) + { + Family = family; + Name = name; + } + + /// Initializes a new instance of . + /// Sku family of the Cloud HSM Cluster. + /// Sku name of the Cloud HSM Cluster. + /// Sku capacity. + /// Keeps track of any properties unknown to the library. + internal CloudHsmClusterSku(CloudHsmClusterSkuFamily family, CloudHsmClusterSkuName name, int? capacity, IDictionary serializedAdditionalRawData) + { + Family = family; + Name = name; + Capacity = capacity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CloudHsmClusterSku() + { + } + + /// Sku family of the Cloud HSM Cluster. + public CloudHsmClusterSkuFamily Family { get; set; } + /// Sku name of the Cloud HSM Cluster. + public CloudHsmClusterSkuName Name { get; set; } + /// Sku capacity. + public int? Capacity { get; set; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSkuFamily.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSkuFamily.cs new file mode 100644 index 000000000000..3c97657bb457 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSkuFamily.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Sku family of the Cloud HSM Cluster. + public readonly partial struct CloudHsmClusterSkuFamily : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CloudHsmClusterSkuFamily(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string BValue = "B"; + + /// B. + public static CloudHsmClusterSkuFamily B { get; } = new CloudHsmClusterSkuFamily(BValue); + /// Determines if two values are the same. + public static bool operator ==(CloudHsmClusterSkuFamily left, CloudHsmClusterSkuFamily right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CloudHsmClusterSkuFamily left, CloudHsmClusterSkuFamily right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CloudHsmClusterSkuFamily(string value) => new CloudHsmClusterSkuFamily(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CloudHsmClusterSkuFamily other && Equals(other); + /// + public bool Equals(CloudHsmClusterSkuFamily 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSkuName.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSkuName.Serialization.cs new file mode 100644 index 000000000000..9f1fa494fccf --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSkuName.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + internal static partial class CloudHsmClusterSkuNameExtensions + { + public static string ToSerialString(this CloudHsmClusterSkuName value) => value switch + { + CloudHsmClusterSkuName.StandardB1 => "Standard_B1", + CloudHsmClusterSkuName.StandardB10 => "Standard B10", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CloudHsmClusterSkuName value.") + }; + + public static CloudHsmClusterSkuName ToCloudHsmClusterSkuName(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Standard_B1")) return CloudHsmClusterSkuName.StandardB1; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Standard B10")) return CloudHsmClusterSkuName.StandardB10; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CloudHsmClusterSkuName value."); + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSkuName.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSkuName.cs new file mode 100644 index 000000000000..b36752b145ec --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmClusterSkuName.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Sku name of the Cloud HSM Cluster. + public enum CloudHsmClusterSkuName + { + /// Standard_B1. + StandardB1, + /// Standard B10. + StandardB10 + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmProperties.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmProperties.Serialization.cs new file mode 100644 index 000000000000..daa164fd2d01 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmProperties.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.Hardwaresecuritymodules.Models +{ + public partial class CloudHsmProperties : 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(CloudHsmProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Fqdn)) + { + writer.WritePropertyName("fqdn"u8); + writer.WriteStringValue(Fqdn); + } + if (Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State); + } + if (Optional.IsDefined(StateMessage)) + { + writer.WritePropertyName("stateMessage"u8); + writer.WriteStringValue(StateMessage); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CloudHsmProperties 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(CloudHsmProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCloudHsmProperties(document.RootElement, options); + } + + internal static CloudHsmProperties DeserializeCloudHsmProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fqdn = default; + string state = default; + string stateMessage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fqdn"u8)) + { + fqdn = property.Value.GetString(); + continue; + } + if (property.NameEquals("state"u8)) + { + state = property.Value.GetString(); + continue; + } + if (property.NameEquals("stateMessage"u8)) + { + stateMessage = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CloudHsmProperties(fqdn, state, stateMessage, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(CloudHsmProperties)} does not support writing '{options.Format}' format."); + } + } + + CloudHsmProperties 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCloudHsmProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CloudHsmProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmProperties.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmProperties.cs new file mode 100644 index 000000000000..8f773d23d9d2 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/CloudHsmProperties.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// The Cloud HSM Properties. + public partial class CloudHsmProperties + { + /// + /// 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 . + internal CloudHsmProperties() + { + } + + /// Initializes a new instance of . + /// FQDN of the Cloud HSM. + /// The Cloud HSM State. Values are: Deploying, ConfiguringSlb, Starting, Starting, Failed, Failed, Deleting, DeletingSlbEntry, InitialProvisioning, Updating. + /// The Cloud HSM State message. + /// Keeps track of any properties unknown to the library. + internal CloudHsmProperties(string fqdn, string state, string stateMessage, IDictionary serializedAdditionalRawData) + { + Fqdn = fqdn; + State = state; + StateMessage = stateMessage; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// FQDN of the Cloud HSM. + public string Fqdn { get; } + /// The Cloud HSM State. Values are: Deploying, ConfiguringSlb, Starting, Starting, Failed, Failed, Deleting, DeletingSlbEntry, InitialProvisioning, Updating. + public string State { get; } + /// The Cloud HSM State message. + public string StateMessage { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmListResult.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmListResult.Serialization.cs new file mode 100644 index 000000000000..45f435d2976f --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmListResult.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.Hardwaresecuritymodules.Models +{ + internal partial class DedicatedHsmListResult : 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(DedicatedHsmListResult)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DedicatedHsmListResult 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(DedicatedHsmListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDedicatedHsmListResult(document.RootElement, options); + } + + internal static DedicatedHsmListResult DeserializeDedicatedHsmListResult(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(DedicatedHsmData.DeserializeDedicatedHsmData(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 DedicatedHsmListResult(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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(DedicatedHsmListResult)} does not support writing '{options.Format}' format."); + } + } + + DedicatedHsmListResult 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDedicatedHsmListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DedicatedHsmListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmListResult.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmListResult.cs new file mode 100644 index 000000000000..5c6b35ab4157 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmListResult.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.Hardwaresecuritymodules.Models +{ + /// The response of a DedicatedHsm list operation. + internal partial class DedicatedHsmListResult + { + /// + /// 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 DedicatedHsm items on this page. + /// is null. + internal DedicatedHsmListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The DedicatedHsm items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal DedicatedHsmListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DedicatedHsmListResult() + { + } + + /// The DedicatedHsm items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmPatch.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmPatch.Serialization.cs new file mode 100644 index 000000000000..67d038d11d81 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmPatch.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class DedicatedHsmPatch : 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(DedicatedHsmPatch)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DedicatedHsmPatch 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(DedicatedHsmPatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDedicatedHsmPatch(document.RootElement, options); + } + + internal static DedicatedHsmPatch DeserializeDedicatedHsmPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"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()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DedicatedHsmPatch(tags ?? new ChangeTrackingDictionary(), 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(DedicatedHsmPatch)} does not support writing '{options.Format}' format."); + } + } + + DedicatedHsmPatch 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDedicatedHsmPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DedicatedHsmPatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmPatch.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmPatch.cs new file mode 100644 index 000000000000..78e27ebbb1d4 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/DedicatedHsmPatch.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Patchable properties of the dedicated HSM. + public partial class DedicatedHsmPatch + { + /// + /// 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 DedicatedHsmPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Resource tags. + /// Keeps track of any properties unknown to the library. + internal DedicatedHsmPatch(IDictionary tags, IDictionary serializedAdditionalRawData) + { + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDependency.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDependency.Serialization.cs new file mode 100644 index 000000000000..aa94440a8af5 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDependency.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class EndpointDependency : 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(EndpointDependency)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DomainName)) + { + writer.WritePropertyName("domainName"u8); + writer.WriteStringValue(DomainName); + } + if (Optional.IsCollectionDefined(EndpointDetails)) + { + writer.WritePropertyName("endpointDetails"u8); + writer.WriteStartArray(); + foreach (var item in EndpointDetails) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EndpointDependency 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(EndpointDependency)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEndpointDependency(document.RootElement, options); + } + + internal static EndpointDependency DeserializeEndpointDependency(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string domainName = default; + IReadOnlyList endpointDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("domainName"u8)) + { + domainName = property.Value.GetString(); + continue; + } + if (property.NameEquals("endpointDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EndpointDetail.DeserializeEndpointDetail(item, options)); + } + endpointDetails = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EndpointDependency(domainName, endpointDetails ?? new ChangeTrackingList(), 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(EndpointDependency)} does not support writing '{options.Format}' format."); + } + } + + EndpointDependency 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEndpointDependency(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EndpointDependency)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDependency.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDependency.cs new file mode 100644 index 000000000000..c002fad73489 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDependency.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// A domain name that dedicated hsm services are reaching at. + public partial class EndpointDependency + { + /// + /// 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 . + internal EndpointDependency() + { + EndpointDetails = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The domain name of the dependency. + /// The Ports and Protocols used when connecting to domainName. + /// Keeps track of any properties unknown to the library. + internal EndpointDependency(string domainName, IReadOnlyList endpointDetails, IDictionary serializedAdditionalRawData) + { + DomainName = domainName; + EndpointDetails = endpointDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The domain name of the dependency. + public string DomainName { get; } + /// The Ports and Protocols used when connecting to domainName. + public IReadOnlyList EndpointDetails { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDetail.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDetail.Serialization.cs new file mode 100644 index 000000000000..b9e3fff61372 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDetail.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class EndpointDetail : 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(EndpointDetail)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(IPAddress)) + { + writer.WritePropertyName("ipAddress"u8); + writer.WriteStringValue(IPAddress); + } + if (Optional.IsDefined(Port)) + { + writer.WritePropertyName("port"u8); + writer.WriteNumberValue(Port.Value); + } + if (Optional.IsDefined(Protocol)) + { + writer.WritePropertyName("protocol"u8); + writer.WriteStringValue(Protocol); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + EndpointDetail 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(EndpointDetail)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEndpointDetail(document.RootElement, options); + } + + internal static EndpointDetail DeserializeEndpointDetail(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string ipAddress = default; + int? port = default; + string protocol = default; + string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ipAddress"u8)) + { + ipAddress = property.Value.GetString(); + continue; + } + if (property.NameEquals("port"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + port = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("protocol"u8)) + { + protocol = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EndpointDetail(ipAddress, port, protocol, description, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(EndpointDetail)} does not support writing '{options.Format}' format."); + } + } + + EndpointDetail 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEndpointDetail(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EndpointDetail)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDetail.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDetail.cs new file mode 100644 index 000000000000..34ec48914819 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/EndpointDetail.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Connect information from the dedicated hsm service to a single endpoint. + public partial class EndpointDetail + { + /// + /// 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 . + internal EndpointDetail() + { + } + + /// Initializes a new instance of . + /// An IP Address that Domain Name currently resolves to. + /// The port an endpoint is connected to. + /// The protocol used for connection. + /// Description of the detail. + /// Keeps track of any properties unknown to the library. + internal EndpointDetail(string ipAddress, int? port, string protocol, string description, IDictionary serializedAdditionalRawData) + { + IPAddress = ipAddress; + Port = port; + Protocol = protocol; + Description = description; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// An IP Address that Domain Name currently resolves to. + public string IPAddress { get; } + /// The port an endpoint is connected to. + public int? Port { get; } + /// The protocol used for connection. + public string Protocol { get; } + /// Description of the detail. + public string Description { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointConnectionListResult.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointConnectionListResult.Serialization.cs new file mode 100644 index 000000000000..4d329c3e526e --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointConnectionListResult.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.Hardwaresecuritymodules.Models +{ + internal partial class HardwaresecuritymodulesPrivateEndpointConnectionListResult : 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(HardwaresecuritymodulesPrivateEndpointConnectionListResult)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + HardwaresecuritymodulesPrivateEndpointConnectionListResult 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(HardwaresecuritymodulesPrivateEndpointConnectionListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHardwaresecuritymodulesPrivateEndpointConnectionListResult(document.RootElement, options); + } + + internal static HardwaresecuritymodulesPrivateEndpointConnectionListResult DeserializeHardwaresecuritymodulesPrivateEndpointConnectionListResult(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(HardwaresecuritymodulesPrivateEndpointConnectionData.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(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 HardwaresecuritymodulesPrivateEndpointConnectionListResult(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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateEndpointConnectionListResult)} does not support writing '{options.Format}' format."); + } + } + + HardwaresecuritymodulesPrivateEndpointConnectionListResult 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHardwaresecuritymodulesPrivateEndpointConnectionListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateEndpointConnectionListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointConnectionListResult.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointConnectionListResult.cs new file mode 100644 index 000000000000..4c61b268d985 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointConnectionListResult.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.Hardwaresecuritymodules.Models +{ + /// The response of a PrivateEndpointConnection list operation. + internal partial class HardwaresecuritymodulesPrivateEndpointConnectionListResult + { + /// + /// 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 PrivateEndpointConnection items on this page. + /// is null. + internal HardwaresecuritymodulesPrivateEndpointConnectionListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The PrivateEndpointConnection items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal HardwaresecuritymodulesPrivateEndpointConnectionListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal HardwaresecuritymodulesPrivateEndpointConnectionListResult() + { + } + + /// The PrivateEndpointConnection items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState.cs new file mode 100644 index 000000000000..14ffbba64ecb --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState.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.Hardwaresecuritymodules.Models +{ + /// The current provisioning state. + public readonly partial struct HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string CreatingValue = "Creating"; + private const string DeletingValue = "Deleting"; + private const string FailedValue = "Failed"; + private const string UpdatingValue = "Updating"; + private const string InternalErrorValue = "InternalError"; + private const string CanceledValue = "Canceled"; + + /// Succeeded. + public static HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState Succeeded { get; } = new HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(SucceededValue); + /// Creating. + public static HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState Creating { get; } = new HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(CreatingValue); + /// Deleting. + public static HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState Deleting { get; } = new HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(DeletingValue); + /// Failed. + public static HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState Failed { get; } = new HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(FailedValue); + /// Updating. + public static HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState Updating { get; } = new HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(UpdatingValue); + /// InternalError. + public static HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState InternalError { get; } = new HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(InternalErrorValue); + /// Canceled. + public static HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState Canceled { get; } = new HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(CanceledValue); + /// Determines if two values are the same. + public static bool operator ==(HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState left, HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState left, HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(string value) => new HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState other && Equals(other); + /// + public bool Equals(HardwaresecuritymodulesPrivateEndpointConnectionProvisioningState 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus.cs new file mode 100644 index 000000000000..ce57c7f19e91 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus.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.Hardwaresecuritymodules.Models +{ + /// The private endpoint connection status. + public readonly partial struct HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PendingValue = "Pending"; + private const string ApprovedValue = "Approved"; + private const string RejectedValue = "Rejected"; + + /// Connectionaiting for approval or rejection. + public static HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus Pending { get; } = new HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus(PendingValue); + /// Connection approved. + public static HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus Approved { get; } = new HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus(ApprovedValue); + /// Connection Rejected. + public static HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus Rejected { get; } = new HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus(RejectedValue); + /// Determines if two values are the same. + public static bool operator ==(HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus left, HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus left, HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus(string value) => new HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus other && Equals(other); + /// + public bool Equals(HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceData.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceData.Serialization.cs new file mode 100644 index 000000000000..555da17f8355 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceData.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class HardwaresecuritymodulesPrivateLinkResourceData : 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(HardwaresecuritymodulesPrivateLinkResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + HardwaresecuritymodulesPrivateLinkResourceData 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(HardwaresecuritymodulesPrivateLinkResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHardwaresecuritymodulesPrivateLinkResourceData(document.RootElement, options); + } + + internal static HardwaresecuritymodulesPrivateLinkResourceData DeserializeHardwaresecuritymodulesPrivateLinkResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + HardwaresecuritymodulesPrivateLinkResourceProperties 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 = HardwaresecuritymodulesPrivateLinkResourceProperties.DeserializeHardwaresecuritymodulesPrivateLinkResourceProperties(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 HardwaresecuritymodulesPrivateLinkResourceData( + 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateLinkResourceData)} does not support writing '{options.Format}' format."); + } + } + + HardwaresecuritymodulesPrivateLinkResourceData 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHardwaresecuritymodulesPrivateLinkResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateLinkResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceData.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceData.cs new file mode 100644 index 000000000000..c10bdae452db --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceData.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// A private link resource. + public partial class HardwaresecuritymodulesPrivateLinkResourceData : 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 . + internal HardwaresecuritymodulesPrivateLinkResourceData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource properties. + /// Keeps track of any properties unknown to the library. + internal HardwaresecuritymodulesPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, HardwaresecuritymodulesPrivateLinkResourceProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource properties. + public HardwaresecuritymodulesPrivateLinkResourceProperties Properties { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceListResult.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceListResult.Serialization.cs new file mode 100644 index 000000000000..aa2fa4b82af1 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceListResult.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + internal partial class HardwaresecuritymodulesPrivateLinkResourceListResult : 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(HardwaresecuritymodulesPrivateLinkResourceListResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + HardwaresecuritymodulesPrivateLinkResourceListResult 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(HardwaresecuritymodulesPrivateLinkResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHardwaresecuritymodulesPrivateLinkResourceListResult(document.RootElement, options); + } + + internal static HardwaresecuritymodulesPrivateLinkResourceListResult DeserializeHardwaresecuritymodulesPrivateLinkResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(HardwaresecuritymodulesPrivateLinkResourceData.DeserializeHardwaresecuritymodulesPrivateLinkResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HardwaresecuritymodulesPrivateLinkResourceListResult(value ?? new ChangeTrackingList(), 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateLinkResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + HardwaresecuritymodulesPrivateLinkResourceListResult 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHardwaresecuritymodulesPrivateLinkResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateLinkResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceListResult.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceListResult.cs new file mode 100644 index 000000000000..ab5b999ce77d --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// A list of private link resources. + internal partial class HardwaresecuritymodulesPrivateLinkResourceListResult + { + /// + /// 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 . + internal HardwaresecuritymodulesPrivateLinkResourceListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Array of private link resources. + /// URL to get the next set of operation list results (if there are any). + /// Keeps track of any properties unknown to the library. + internal HardwaresecuritymodulesPrivateLinkResourceListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Array of private link resources. + public IReadOnlyList Value { get; } + /// URL to get the next set of operation list results (if there are any). + public string NextLink { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceProperties.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceProperties.Serialization.cs new file mode 100644 index 000000000000..ef5e43fdb187 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceProperties.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class HardwaresecuritymodulesPrivateLinkResourceProperties : 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(HardwaresecuritymodulesPrivateLinkResourceProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(GroupId)) + { + writer.WritePropertyName("groupId"u8); + writer.WriteStringValue(GroupId); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RequiredMembers)) + { + writer.WritePropertyName("requiredMembers"u8); + writer.WriteStartArray(); + foreach (var item in RequiredMembers) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(RequiredZoneNames)) + { + writer.WritePropertyName("requiredZoneNames"u8); + writer.WriteStartArray(); + foreach (var item in RequiredZoneNames) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + HardwaresecuritymodulesPrivateLinkResourceProperties 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(HardwaresecuritymodulesPrivateLinkResourceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHardwaresecuritymodulesPrivateLinkResourceProperties(document.RootElement, options); + } + + internal static HardwaresecuritymodulesPrivateLinkResourceProperties DeserializeHardwaresecuritymodulesPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string groupId = default; + IReadOnlyList requiredMembers = default; + IReadOnlyList requiredZoneNames = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("groupId"u8)) + { + groupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("requiredMembers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + requiredMembers = array; + continue; + } + if (property.NameEquals("requiredZoneNames"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + requiredZoneNames = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HardwaresecuritymodulesPrivateLinkResourceProperties(groupId, requiredMembers ?? new ChangeTrackingList(), requiredZoneNames ?? new ChangeTrackingList(), 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateLinkResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + HardwaresecuritymodulesPrivateLinkResourceProperties 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHardwaresecuritymodulesPrivateLinkResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateLinkResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceProperties.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceProperties.cs new file mode 100644 index 000000000000..0461fe5bf405 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkResourceProperties.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Properties of a private link resource. + public partial class HardwaresecuritymodulesPrivateLinkResourceProperties + { + /// + /// 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 . + internal HardwaresecuritymodulesPrivateLinkResourceProperties() + { + RequiredMembers = new ChangeTrackingList(); + RequiredZoneNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The private link resource group id. + /// The private link resource required member names. + /// The private link resource private link DNS zone name. + /// Keeps track of any properties unknown to the library. + internal HardwaresecuritymodulesPrivateLinkResourceProperties(string groupId, IReadOnlyList requiredMembers, IReadOnlyList requiredZoneNames, IDictionary serializedAdditionalRawData) + { + GroupId = groupId; + RequiredMembers = requiredMembers; + RequiredZoneNames = requiredZoneNames; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The private link resource group id. + public string GroupId { get; } + /// The private link resource required member names. + public IReadOnlyList RequiredMembers { get; } + /// The private link resource private link DNS zone name. + public IReadOnlyList RequiredZoneNames { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkServiceConnectionState.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkServiceConnectionState.Serialization.cs new file mode 100644 index 000000000000..bdc93c80b658 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkServiceConnectionState.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; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class HardwaresecuritymodulesPrivateLinkServiceConnectionState : 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(HardwaresecuritymodulesPrivateLinkServiceConnectionState)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(ActionsRequired)) + { + writer.WritePropertyName("actionsRequired"u8); + writer.WriteStringValue(ActionsRequired); + } + if (options.Format != "W" && _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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + HardwaresecuritymodulesPrivateLinkServiceConnectionState 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(HardwaresecuritymodulesPrivateLinkServiceConnectionState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHardwaresecuritymodulesPrivateLinkServiceConnectionState(document.RootElement, options); + } + + internal static HardwaresecuritymodulesPrivateLinkServiceConnectionState DeserializeHardwaresecuritymodulesPrivateLinkServiceConnectionState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus? status = default; + string description = default; + string actionsRequired = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("actionsRequired"u8)) + { + actionsRequired = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HardwaresecuritymodulesPrivateLinkServiceConnectionState(status, description, actionsRequired, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateLinkServiceConnectionState)} does not support writing '{options.Format}' format."); + } + } + + HardwaresecuritymodulesPrivateLinkServiceConnectionState 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHardwaresecuritymodulesPrivateLinkServiceConnectionState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesPrivateLinkServiceConnectionState)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkServiceConnectionState.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkServiceConnectionState.cs new file mode 100644 index 000000000000..d13b7409d6d7 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesPrivateLinkServiceConnectionState.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// A collection of information about the state of the connection between service consumer and provider. + public partial class HardwaresecuritymodulesPrivateLinkServiceConnectionState + { + /// + /// 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 HardwaresecuritymodulesPrivateLinkServiceConnectionState() + { + } + + /// Initializes a new instance of . + /// Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + /// The reason for approval/rejection of the connection. + /// A message indicating if changes on the service provider require any updates on the consumer. + /// Keeps track of any properties unknown to the library. + internal HardwaresecuritymodulesPrivateLinkServiceConnectionState(HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus? status, string description, string actionsRequired, IDictionary serializedAdditionalRawData) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + public HardwaresecuritymodulesPrivateEndpointServiceConnectionStatus? Status { get; set; } + /// The reason for approval/rejection of the connection. + public string Description { get; set; } + /// A message indicating if changes on the service provider require any updates on the consumer. + public string ActionsRequired { get; set; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesSku.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesSku.Serialization.cs new file mode 100644 index 000000000000..300c9a13584e --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesSku.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.Hardwaresecuritymodules.Models +{ + public partial class HardwaresecuritymodulesSku : 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(HardwaresecuritymodulesSku)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + HardwaresecuritymodulesSku 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(HardwaresecuritymodulesSku)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHardwaresecuritymodulesSku(document.RootElement, options); + } + + internal static HardwaresecuritymodulesSku DeserializeHardwaresecuritymodulesSku(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + HardwaresecuritymodulesSkuName? name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + name = new HardwaresecuritymodulesSkuName(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HardwaresecuritymodulesSku(name, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesSku)} does not support writing '{options.Format}' format."); + } + } + + HardwaresecuritymodulesSku 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHardwaresecuritymodulesSku(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HardwaresecuritymodulesSku)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesSku.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesSku.cs new file mode 100644 index 000000000000..9d0a413dbcc8 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesSku.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.Hardwaresecuritymodules.Models +{ + /// SKU of the dedicated HSM. + public partial class HardwaresecuritymodulesSku + { + /// + /// 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 HardwaresecuritymodulesSku() + { + } + + /// Initializes a new instance of . + /// SKU of the dedicated HSM. + /// Keeps track of any properties unknown to the library. + internal HardwaresecuritymodulesSku(HardwaresecuritymodulesSkuName? name, IDictionary serializedAdditionalRawData) + { + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// SKU of the dedicated HSM. + public HardwaresecuritymodulesSkuName? Name { get; set; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesSkuName.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesSkuName.cs new file mode 100644 index 000000000000..616189b16c3c --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/HardwaresecuritymodulesSkuName.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.Hardwaresecuritymodules.Models +{ + /// SKU of the dedicated HSM. + public readonly partial struct HardwaresecuritymodulesSkuName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public HardwaresecuritymodulesSkuName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SafeNetLunaNetworkHSMA790Value = "SafeNet Luna Network HSM A790"; + private const string PayShield10KLMK1CPS60Value = "payShield10K_LMK1_CPS60"; + private const string PayShield10KLMK1CPS250Value = "payShield10K_LMK1_CPS250"; + private const string PayShield10KLMK1CPS2500Value = "payShield10K_LMK1_CPS2500"; + private const string PayShield10KLMK2CPS60Value = "payShield10K_LMK2_CPS60"; + private const string PayShield10KLMK2CPS250Value = "payShield10K_LMK2_CPS250"; + private const string PayShield10KLMK2CPS2500Value = "payShield10K_LMK2_CPS2500"; + + /// The dedicated HSM is a Safenet Luna Network HSM A790 device. + public static HardwaresecuritymodulesSkuName SafeNetLunaNetworkHSMA790 { get; } = new HardwaresecuritymodulesSkuName(SafeNetLunaNetworkHSMA790Value); + /// The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with 1 local master key which supports up to 60 calls per second. + public static HardwaresecuritymodulesSkuName PayShield10KLMK1CPS60 { get; } = new HardwaresecuritymodulesSkuName(PayShield10KLMK1CPS60Value); + /// The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with 1 local master key which supports up to 250 calls per second. + public static HardwaresecuritymodulesSkuName PayShield10KLMK1CPS250 { get; } = new HardwaresecuritymodulesSkuName(PayShield10KLMK1CPS250Value); + /// The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with 1 local master key which supports up to 2500 calls per second. + public static HardwaresecuritymodulesSkuName PayShield10KLMK1CPS2500 { get; } = new HardwaresecuritymodulesSkuName(PayShield10KLMK1CPS2500Value); + /// The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with 2 local master keys which supports up to 60 calls per second. + public static HardwaresecuritymodulesSkuName PayShield10KLMK2CPS60 { get; } = new HardwaresecuritymodulesSkuName(PayShield10KLMK2CPS60Value); + /// The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with 2 local master keys which supports up to 250 calls per second. + public static HardwaresecuritymodulesSkuName PayShield10KLMK2CPS250 { get; } = new HardwaresecuritymodulesSkuName(PayShield10KLMK2CPS250Value); + /// The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with 2 local master keys which supports up to 2500 calls per second. + public static HardwaresecuritymodulesSkuName PayShield10KLMK2CPS2500 { get; } = new HardwaresecuritymodulesSkuName(PayShield10KLMK2CPS2500Value); + /// Determines if two values are the same. + public static bool operator ==(HardwaresecuritymodulesSkuName left, HardwaresecuritymodulesSkuName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(HardwaresecuritymodulesSkuName left, HardwaresecuritymodulesSkuName right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator HardwaresecuritymodulesSkuName(string value) => new HardwaresecuritymodulesSkuName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is HardwaresecuritymodulesSkuName other && Equals(other); + /// + public bool Equals(HardwaresecuritymodulesSkuName 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/JsonWebKeyType.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/JsonWebKeyType.cs new file mode 100644 index 000000000000..945f17221ee7 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/JsonWebKeyType.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.Hardwaresecuritymodules.Models +{ + /// Provisioning state. + public readonly partial struct JsonWebKeyType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public JsonWebKeyType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string ProvisioningValue = "Provisioning"; + private const string AllocatingValue = "Allocating"; + private const string ConnectingValue = "Connecting"; + private const string FailedValue = "Failed"; + private const string CheckingQuotaValue = "CheckingQuota"; + private const string DeletingValue = "Deleting"; + + /// The dedicated HSM has been fully provisioned. + public static JsonWebKeyType Succeeded { get; } = new JsonWebKeyType(SucceededValue); + /// The dedicated HSM is currently being provisioned. + public static JsonWebKeyType Provisioning { get; } = new JsonWebKeyType(ProvisioningValue); + /// A device is currently being allocated for the dedicated HSM resource. + public static JsonWebKeyType Allocating { get; } = new JsonWebKeyType(AllocatingValue); + /// The dedicated HSM is being connected to the virtual network. + public static JsonWebKeyType Connecting { get; } = new JsonWebKeyType(ConnectingValue); + /// Provisioning of the dedicated HSM has failed. + public static JsonWebKeyType Failed { get; } = new JsonWebKeyType(FailedValue); + /// Validating the subscription has sufficient quota to allocate a dedicated HSM device. + public static JsonWebKeyType CheckingQuota { get; } = new JsonWebKeyType(CheckingQuotaValue); + /// The dedicated HSM is currently being deleted. + public static JsonWebKeyType Deleting { get; } = new JsonWebKeyType(DeletingValue); + /// Determines if two values are the same. + public static bool operator ==(JsonWebKeyType left, JsonWebKeyType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(JsonWebKeyType left, JsonWebKeyType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator JsonWebKeyType(string value) => new JsonWebKeyType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is JsonWebKeyType other && Equals(other); + /// + public bool Equals(JsonWebKeyType 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/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkInterface.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkInterface.Serialization.cs new file mode 100644 index 000000000000..0ab3ae83579b --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkInterface.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class NetworkInterface : 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(NetworkInterface)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(ResourceId)) + { + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + } + if (Optional.IsDefined(PrivateIPAddress)) + { + writer.WritePropertyName("privateIpAddress"u8); + writer.WriteStringValue(PrivateIPAddress); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NetworkInterface 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(NetworkInterface)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkInterface(document.RootElement, options); + } + + internal static NetworkInterface DeserializeNetworkInterface(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier resourceId = default; + string privateIPAddress = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("privateIpAddress"u8)) + { + privateIPAddress = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkInterface(resourceId, privateIPAddress, 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(NetworkInterface)} does not support writing '{options.Format}' format."); + } + } + + NetworkInterface 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNetworkInterface(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkInterface)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkInterface.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkInterface.cs new file mode 100644 index 000000000000..cdab76d60c3f --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkInterface.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// The network interface definition. + public partial class NetworkInterface + { + /// + /// 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 NetworkInterface() + { + } + + /// Initializes a new instance of . + /// The Azure resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... + /// Private Ip address of the interface. + /// Keeps track of any properties unknown to the library. + internal NetworkInterface(ResourceIdentifier resourceId, string privateIPAddress, IDictionary serializedAdditionalRawData) + { + ResourceId = resourceId; + PrivateIPAddress = privateIPAddress; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The Azure resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... + public ResourceIdentifier ResourceId { get; } + /// Private Ip address of the interface. + public string PrivateIPAddress { get; set; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkProfile.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkProfile.Serialization.cs new file mode 100644 index 000000000000..ebe53cb3d07b --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkProfile.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class NetworkProfile : 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(NetworkProfile)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Subnet)) + { + writer.WritePropertyName("subnet"u8); + writer.WriteObjectValue(Subnet, options); + } + if (Optional.IsCollectionDefined(NetworkInterfaces)) + { + writer.WritePropertyName("networkInterfaces"u8); + writer.WriteStartArray(); + foreach (var item in NetworkInterfaces) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NetworkProfile 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(NetworkProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkProfile(document.RootElement, options); + } + + internal static NetworkProfile DeserializeNetworkProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ApiEntityReference subnet = default; + IList networkInterfaces = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("subnet"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + subnet = ApiEntityReference.DeserializeApiEntityReference(property.Value, options); + continue; + } + if (property.NameEquals("networkInterfaces"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NetworkInterface.DeserializeNetworkInterface(item, options)); + } + networkInterfaces = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkProfile(subnet, networkInterfaces ?? new ChangeTrackingList(), 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(NetworkProfile)} does not support writing '{options.Format}' format."); + } + } + + NetworkProfile 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNetworkProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkProfile.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkProfile.cs new file mode 100644 index 000000000000..96de73a9ffbb --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/NetworkProfile.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// The network profile definition. + public partial class NetworkProfile + { + /// + /// 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 NetworkProfile() + { + NetworkInterfaces = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Specifies the identifier of the subnet. + /// Specifies the list of resource Ids for the network interfaces associated with the dedicated HSM. + /// Keeps track of any properties unknown to the library. + internal NetworkProfile(ApiEntityReference subnet, IList networkInterfaces, IDictionary serializedAdditionalRawData) + { + Subnet = subnet; + NetworkInterfaces = networkInterfaces; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies the identifier of the subnet. + internal ApiEntityReference Subnet { get; set; } + /// The Azure resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... + public ResourceIdentifier SubnetResourceId + { + get => Subnet is null ? default : Subnet.ResourceId; + set + { + if (Subnet is null) + Subnet = new ApiEntityReference(); + Subnet.ResourceId = value; + } + } + + /// Specifies the list of resource Ids for the network interfaces associated with the dedicated HSM. + public IList NetworkInterfaces { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpoint.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpoint.Serialization.cs new file mode 100644 index 000000000000..09486f05ac6c --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpoint.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + public partial class OutboundEnvironmentEndpoint : 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(OutboundEnvironmentEndpoint)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Category)) + { + writer.WritePropertyName("category"u8); + writer.WriteStringValue(Category); + } + if (Optional.IsCollectionDefined(Endpoints)) + { + writer.WritePropertyName("endpoints"u8); + writer.WriteStartArray(); + foreach (var item in Endpoints) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OutboundEnvironmentEndpoint 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(OutboundEnvironmentEndpoint)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOutboundEnvironmentEndpoint(document.RootElement, options); + } + + internal static OutboundEnvironmentEndpoint DeserializeOutboundEnvironmentEndpoint(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string category = default; + IReadOnlyList endpoints = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("category"u8)) + { + category = property.Value.GetString(); + continue; + } + if (property.NameEquals("endpoints"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EndpointDependency.DeserializeEndpointDependency(item, options)); + } + endpoints = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OutboundEnvironmentEndpoint(category, endpoints ?? new ChangeTrackingList(), 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(OutboundEnvironmentEndpoint)} does not support writing '{options.Format}' format."); + } + } + + OutboundEnvironmentEndpoint 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOutboundEnvironmentEndpoint(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OutboundEnvironmentEndpoint)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpoint.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpoint.cs new file mode 100644 index 000000000000..b3e706ccbec9 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpoint.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Egress endpoints which dedicated hsm service connects to for common purpose. + public partial class OutboundEnvironmentEndpoint + { + /// + /// 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 . + internal OutboundEnvironmentEndpoint() + { + Endpoints = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The category of endpoints accessed by the dedicated hsm service, e.g. azure-resource-management, apiserver, etc. + /// The endpoints that dedicated hsm service connects to. + /// Keeps track of any properties unknown to the library. + internal OutboundEnvironmentEndpoint(string category, IReadOnlyList endpoints, IDictionary serializedAdditionalRawData) + { + Category = category; + Endpoints = endpoints; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The category of endpoints accessed by the dedicated hsm service, e.g. azure-resource-management, apiserver, etc. + public string Category { get; } + /// The endpoints that dedicated hsm service connects to. + public IReadOnlyList Endpoints { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpointCollection.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpointCollection.Serialization.cs new file mode 100644 index 000000000000..ba03e5107422 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpointCollection.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.Hardwaresecuritymodules.Models +{ + internal partial class OutboundEnvironmentEndpointCollection : 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(OutboundEnvironmentEndpointCollection)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OutboundEnvironmentEndpointCollection 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(OutboundEnvironmentEndpointCollection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOutboundEnvironmentEndpointCollection(document.RootElement, options); + } + + internal static OutboundEnvironmentEndpointCollection DeserializeOutboundEnvironmentEndpointCollection(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(OutboundEnvironmentEndpoint.DeserializeOutboundEnvironmentEndpoint(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 OutboundEnvironmentEndpointCollection(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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(OutboundEnvironmentEndpointCollection)} does not support writing '{options.Format}' format."); + } + } + + OutboundEnvironmentEndpointCollection 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOutboundEnvironmentEndpointCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OutboundEnvironmentEndpointCollection)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpointCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpointCollection.cs new file mode 100644 index 000000000000..ef8f7ffc0228 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/OutboundEnvironmentEndpointCollection.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.Hardwaresecuritymodules.Models +{ + /// Collection of OutboundEnvironmentEndpoint. + internal partial class OutboundEnvironmentEndpointCollection + { + /// + /// 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 OutboundEnvironmentEndpoint items on this page. + /// is null. + internal OutboundEnvironmentEndpointCollection(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The OutboundEnvironmentEndpoint items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal OutboundEnvironmentEndpointCollection(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OutboundEnvironmentEndpointCollection() + { + } + + /// The OutboundEnvironmentEndpoint items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ProvisioningState.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..71bf488cd5c2 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/ProvisioningState.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.Hardwaresecuritymodules.Models +{ + /// The Cloud HSM Cluster's provisioningState. + public readonly partial struct ProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ProvisioningValue = "Provisioning"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string DeletingValue = "Deleting"; + private const string CanceledValue = "Canceled"; + + /// Provisioning. + public static ProvisioningState Provisioning { get; } = new ProvisioningState(ProvisioningValue); + /// Succeeded. + public static ProvisioningState Succeeded { get; } = new ProvisioningState(SucceededValue); + /// Failed. + public static ProvisioningState Failed { get; } = new ProvisioningState(FailedValue); + /// Deleting. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + /// Canceled. + public static ProvisioningState Canceled { get; } = new ProvisioningState(CanceledValue); + /// Determines if two values are the same. + public static bool operator ==(ProvisioningState left, ProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ProvisioningState left, ProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ProvisioningState(string value) => new ProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProvisioningState other && Equals(other); + /// + public bool Equals(ProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/PublicNetworkAccess.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/PublicNetworkAccess.cs new file mode 100644 index 000000000000..747874e06efe --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/PublicNetworkAccess.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// The Cloud HSM Cluster public network access. + public readonly partial struct PublicNetworkAccess : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PublicNetworkAccess(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DisabledValue = "Disabled"; + + /// Disabled. + public static PublicNetworkAccess Disabled { get; } = new PublicNetworkAccess(DisabledValue); + /// Determines if two values are the same. + public static bool operator ==(PublicNetworkAccess left, PublicNetworkAccess right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PublicNetworkAccess left, PublicNetworkAccess right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PublicNetworkAccess(string value) => new PublicNetworkAccess(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PublicNetworkAccess other && Equals(other); + /// + public bool Equals(PublicNetworkAccess other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreRequestProperties.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreRequestProperties.Serialization.cs new file mode 100644 index 000000000000..f7c053a572c4 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreRequestProperties.Serialization.cs @@ -0,0 +1,124 @@ +// 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.Hardwaresecuritymodules.Models +{ + public partial class RestoreRequestProperties : 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(RestoreRequestProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("backupId"u8); + writer.WriteStringValue(BackupId); + } + + RestoreRequestProperties 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(RestoreRequestProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRestoreRequestProperties(document.RootElement, options); + } + + internal static RestoreRequestProperties DeserializeRestoreRequestProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string backupId = default; + Uri azureStorageBlobContainerUri = default; + string token = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("backupId"u8)) + { + backupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("azureStorageBlobContainerUri"u8)) + { + azureStorageBlobContainerUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("token"u8)) + { + token = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RestoreRequestProperties(azureStorageBlobContainerUri, token, serializedAdditionalRawData, backupId); + } + + 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(RestoreRequestProperties)} does not support writing '{options.Format}' format."); + } + } + + RestoreRequestProperties 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRestoreRequestProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RestoreRequestProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreRequestProperties.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreRequestProperties.cs new file mode 100644 index 000000000000..05c49fb99354 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreRequestProperties.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Cloud Hsm Cluster restore information. + public partial class RestoreRequestProperties : BackupRestoreRequestBaseProperties + { + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// An autogenerated unique string ID for labeling the backup. It contains both a UUID and a date timestamp. + /// or is null. + public RestoreRequestProperties(Uri azureStorageBlobContainerUri, string backupId) : base(azureStorageBlobContainerUri) + { + Argument.AssertNotNull(azureStorageBlobContainerUri, nameof(azureStorageBlobContainerUri)); + Argument.AssertNotNull(backupId, nameof(backupId)); + + BackupId = backupId; + } + + /// Initializes a new instance of . + /// The Azure blob storage container Uri which contains the backup. + /// The SAS token pointing to an Azure blob storage container. This property is reserved for Azure Backup Service. + /// Keeps track of any properties unknown to the library. + /// An autogenerated unique string ID for labeling the backup. It contains both a UUID and a date timestamp. + internal RestoreRequestProperties(Uri azureStorageBlobContainerUri, string token, IDictionary serializedAdditionalRawData, string backupId) : base(azureStorageBlobContainerUri, token, serializedAdditionalRawData) + { + BackupId = backupId; + } + + /// Initializes a new instance of for deserialization. + internal RestoreRequestProperties() + { + } + + /// An autogenerated unique string ID for labeling the backup. It contains both a UUID and a date timestamp. + public string BackupId { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreResult.Serialization.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreResult.Serialization.cs new file mode 100644 index 000000000000..4d9ba12012a8 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreResult.Serialization.cs @@ -0,0 +1,230 @@ +// 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.Hardwaresecuritymodules.Models +{ + public partial class RestoreResult : 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(RestoreResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(StatusDetails)) + { + writer.WritePropertyName("statusDetails"u8); + writer.WriteStringValue(StatusDetails); + } + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + JsonSerializer.Serialize(writer, Error); + } + if (options.Format != "W" && Optional.IsDefined(StartOn)) + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(EndOn)) + { + if (EndOn != null) + { + writer.WritePropertyName("endTime"u8); + writer.WriteStringValue(EndOn.Value, "O"); + } + else + { + writer.WriteNull("endTime"); + } + } + if (Optional.IsDefined(JobId)) + { + writer.WritePropertyName("jobId"u8); + writer.WriteStringValue(JobId); + } + writer.WriteEndObject(); + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RestoreResult 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(RestoreResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRestoreResult(document.RootElement, options); + } + + internal static RestoreResult DeserializeRestoreResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BackupRestoreOperationStatus? status = default; + string statusDetails = default; + ResponseError error = default; + DateTimeOffset? startTime = default; + DateTimeOffset? endTime = default; + string jobId = 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) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("status"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new BackupRestoreOperationStatus(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("statusDetails"u8)) + { + statusDetails = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("error"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = JsonSerializer.Deserialize(property0.Value.GetRawText()); + continue; + } + if (property0.NameEquals("startTime"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startTime = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("endTime"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + endTime = null; + continue; + } + endTime = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("jobId"u8)) + { + jobId = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RestoreResult( + status, + statusDetails, + error, + startTime, + endTime, + jobId, + 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, AzureResourceManagerHardwaresecuritymodulesContext.Default); + default: + throw new FormatException($"The model {nameof(RestoreResult)} does not support writing '{options.Format}' format."); + } + } + + RestoreResult 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRestoreResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RestoreResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreResult.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreResult.cs new file mode 100644 index 000000000000..0146aa4f78ca --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/Models/RestoreResult.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Models +{ + /// Restore operation properties. + public partial class RestoreResult + { + /// + /// 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 . + internal RestoreResult() + { + } + + /// Initializes a new instance of . + /// Status of the backup/restore operation. + /// The status details of backup/restore operation. + /// Error encountered, if any, during the backup/restore operation. + /// The start time of the backup/restore operation in UTC. + /// The end time of the backup/restore operation in UTC. + /// Identifier for the backup/restore operation. + /// Keeps track of any properties unknown to the library. + internal RestoreResult(BackupRestoreOperationStatus? status, string statusDetails, ResponseError error, DateTimeOffset? startOn, DateTimeOffset? endOn, string jobId, IDictionary serializedAdditionalRawData) + { + Status = status; + StatusDetails = statusDetails; + Error = error; + StartOn = startOn; + EndOn = endOn; + JobId = jobId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Status of the backup/restore operation. + public BackupRestoreOperationStatus? Status { get; } + /// The status details of backup/restore operation. + public string StatusDetails { get; } + /// Error encountered, if any, during the backup/restore operation. + public ResponseError Error { get; } + /// The start time of the backup/restore operation in UTC. + public DateTimeOffset? StartOn { get; } + /// The end time of the backup/restore operation in UTC. + public DateTimeOffset? EndOn { get; } + /// Identifier for the backup/restore operation. + public string JobId { get; } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/ProviderConstants.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..2687b696d417 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/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.Hardwaresecuritymodules +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/RestOperations/CloudHsmClustersRestOperations.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/RestOperations/CloudHsmClustersRestOperations.cs new file mode 100644 index 000000000000..224fd06613f8 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/RestOperations/CloudHsmClustersRestOperations.cs @@ -0,0 +1,1512 @@ +// 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.Hardwaresecuritymodules.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + internal partial class CloudHsmClustersRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CloudHsmClustersRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public CloudHsmClustersRestOperations(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-06-30-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, cloudHsmClusterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CloudHsmClusterData.DeserializeCloudHsmClusterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CloudHsmClusterData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, cloudHsmClusterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CloudHsmClusterData.DeserializeCloudHsmClusterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CloudHsmClusterData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CloudHsmClusterData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CloudHsmClusterData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, 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 or Update a Cloud HSM Cluster in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Parameters to create Cloud HSM Cluster. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CloudHsmClusterData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, 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 or Update a Cloud HSM Cluster in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Parameters to create Cloud HSM Cluster. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CloudHsmClusterData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, 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 subscriptionId, string resourceGroupName, string cloudHsmClusterName, CloudHsmClusterPatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CloudHsmClusterPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, 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 Cloud HSM Cluster in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Parameters to create Cloud HSM Cluster. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CloudHsmClusterPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, 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 Cloud HSM Cluster in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Parameters to create Cloud HSM Cluster. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CloudHsmClusterPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, 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 subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, cloudHsmClusterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, cloudHsmClusterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName, string skiptoken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skiptoken != null) + { + uri.AppendQuery("$skiptoken", skiptoken, true); + } + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, string skiptoken) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skiptoken != null) + { + uri.AppendQuery("$skiptoken", skiptoken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription and within the specified resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, skiptoken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CloudHsmClusterListResult.DeserializeCloudHsmClusterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription and within the specified resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, skiptoken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CloudHsmClusterListResult.DeserializeCloudHsmClusterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId, string skiptoken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skiptoken != null) + { + uri.AppendQuery("$skiptoken", skiptoken, true); + } + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId, string skiptoken) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skiptoken != null) + { + uri.AppendQuery("$skiptoken", skiptoken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, skiptoken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CloudHsmClusterListResult.DeserializeCloudHsmClusterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, skiptoken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CloudHsmClusterListResult.DeserializeCloudHsmClusterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateValidateBackupPropertiesRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, BackupRequestProperties backupRequestProperties) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/validateBackupProperties", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateValidateBackupPropertiesRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, BackupRequestProperties backupRequestProperties) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/validateBackupProperties", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + if (backupRequestProperties != null) + { + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(backupRequestProperties, ModelSerializationExtensions.WireOptions); + request.Content = content; + } + _userAgent.Apply(message); + return message; + } + + /// Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM Cluster resource in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Backup Operation Required properties. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task ValidateBackupPropertiesAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, BackupRequestProperties backupRequestProperties = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateValidateBackupPropertiesRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, backupRequestProperties); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM Cluster resource in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Backup Operation Required properties. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ValidateBackupProperties(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, BackupRequestProperties backupRequestProperties = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateValidateBackupPropertiesRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, backupRequestProperties); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateBackupRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, BackupRequestProperties backupRequestProperties) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/backup", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateBackupRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, BackupRequestProperties backupRequestProperties) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/backup", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + if (backupRequestProperties != null) + { + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(backupRequestProperties, ModelSerializationExtensions.WireOptions); + request.Content = content; + } + _userAgent.Apply(message); + return message; + } + + /// Create a backup of the Cloud HSM Cluster in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Azure storage Resource Uri. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task BackupAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, BackupRequestProperties backupRequestProperties = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateBackupRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, backupRequestProperties); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a backup of the Cloud HSM Cluster in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Azure storage Resource Uri. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Backup(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, BackupRequestProperties backupRequestProperties = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateBackupRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, backupRequestProperties); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateValidateRestorePropertiesRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, RestoreRequestProperties restoreRequestProperties) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/validateRestoreProperties", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateValidateRestorePropertiesRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, RestoreRequestProperties restoreRequestProperties) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/validateRestoreProperties", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + if (restoreRequestProperties != null) + { + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(restoreRequestProperties, ModelSerializationExtensions.WireOptions); + request.Content = content; + } + _userAgent.Apply(message); + return message; + } + + /// Queued validating pre restore operation. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Optional Parameters to validate prior performing a restore operation. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task ValidateRestorePropertiesAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, RestoreRequestProperties restoreRequestProperties = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateValidateRestorePropertiesRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, restoreRequestProperties); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Queued validating pre restore operation. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Optional Parameters to validate prior performing a restore operation. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ValidateRestoreProperties(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, RestoreRequestProperties restoreRequestProperties = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateValidateRestorePropertiesRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, restoreRequestProperties); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateRestoreRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, RestoreRequestProperties restoreRequestProperties) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/restore", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateRestoreRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, RestoreRequestProperties restoreRequestProperties) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/restore", false); + 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(restoreRequestProperties, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Restores all key materials of a specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Restore Operation Required properties. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task RestoreAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, RestoreRequestProperties restoreRequestProperties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNull(restoreRequestProperties, nameof(restoreRequestProperties)); + + using var message = CreateRestoreRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, restoreRequestProperties); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Restores all key materials of a specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Restore Operation Required properties. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Restore(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, RestoreRequestProperties restoreRequestProperties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNull(restoreRequestProperties, nameof(restoreRequestProperties)); + + using var message = CreateRestoreRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, restoreRequestProperties); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByCloudHsmClusterRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateLinkResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByCloudHsmClusterRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateLinkResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the private link resources supported for the Cloud Hsm Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCloudHsmClusterAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateListByCloudHsmClusterRequest(subscriptionId, resourceGroupName, cloudHsmClusterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateLinkResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = HardwaresecuritymodulesPrivateLinkResourceListResult.DeserializeHardwaresecuritymodulesPrivateLinkResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the private link resources supported for the Cloud Hsm Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCloudHsmCluster(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateListByCloudHsmClusterRequest(subscriptionId, resourceGroupName, cloudHsmClusterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateLinkResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = HardwaresecuritymodulesPrivateLinkResourceListResult.DeserializeHardwaresecuritymodulesPrivateLinkResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCloudHsmClusterBackupStatusGetRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string jobId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/backupOperationStatus/", false); + uri.AppendPath(jobId, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCloudHsmClusterBackupStatusGetRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string jobId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/backupOperationStatus/", false); + uri.AppendPath(jobId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the backup operation status of the specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The to use. + /// Identifier for the backup operation. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> CloudHsmClusterBackupStatusGetAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + using var message = CreateCloudHsmClusterBackupStatusGetRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, jobId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BackupResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = BackupResult.DeserializeBackupResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 202: + return Response.FromValue((BackupResult)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the backup operation status of the specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The to use. + /// Identifier for the backup operation. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CloudHsmClusterBackupStatusGet(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + using var message = CreateCloudHsmClusterBackupStatusGetRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, jobId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BackupResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = BackupResult.DeserializeBackupResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 202: + return Response.FromValue((BackupResult)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCloudHsmClusterRestoreStatusGetRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string jobId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/restoreOperationStatus/", false); + uri.AppendPath(jobId, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCloudHsmClusterRestoreStatusGetRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string jobId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/restoreOperationStatus/", false); + uri.AppendPath(jobId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the restore operation status of the specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the Cloud HSM Cluster. + /// Identifier for the restore operation. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> CloudHsmClusterRestoreStatusGetAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + using var message = CreateCloudHsmClusterRestoreStatusGetRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, jobId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RestoreResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = RestoreResult.DeserializeRestoreResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 202: + return Response.FromValue((RestoreResult)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the restore operation status of the specified Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the Cloud HSM Cluster. + /// Identifier for the restore operation. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CloudHsmClusterRestoreStatusGet(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string jobId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(jobId, nameof(jobId)); + + using var message = CreateCloudHsmClusterRestoreStatusGetRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, jobId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RestoreResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = RestoreResult.DeserializeRestoreResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 202: + return Response.FromValue((RestoreResult)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string skiptoken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string skiptoken) + { + 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; + } + + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription and within the specified resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, skiptoken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CloudHsmClusterListResult.DeserializeCloudHsmClusterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription and within the specified resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, skiptoken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CloudHsmClusterListResult.DeserializeCloudHsmClusterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId, string skiptoken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId, string skiptoken) + { + 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; + } + + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, skiptoken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CloudHsmClusterListResult.DeserializeCloudHsmClusterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the Cloud HSM Clusters associated with the subscription. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The page-continuation token to use with a paged version of this API. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, string skiptoken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, skiptoken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CloudHsmClusterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CloudHsmClusterListResult.DeserializeCloudHsmClusterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByCloudHsmClusterNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByCloudHsmClusterNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + 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; + } + + /// Gets the private link resources supported for the Cloud Hsm Cluster. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCloudHsmClusterNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateListByCloudHsmClusterNextPageRequest(nextLink, subscriptionId, resourceGroupName, cloudHsmClusterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateLinkResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = HardwaresecuritymodulesPrivateLinkResourceListResult.DeserializeHardwaresecuritymodulesPrivateLinkResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the private link resources supported for the Cloud Hsm Cluster. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCloudHsmClusterNextPage(string nextLink, string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateListByCloudHsmClusterNextPageRequest(nextLink, subscriptionId, resourceGroupName, cloudHsmClusterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateLinkResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = HardwaresecuritymodulesPrivateLinkResourceListResult.DeserializeHardwaresecuritymodulesPrivateLinkResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/RestOperations/DedicatedHsmsRestOperations.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/RestOperations/DedicatedHsmsRestOperations.cs new file mode 100644 index 000000000000..7c01dc054854 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/RestOperations/DedicatedHsmsRestOperations.cs @@ -0,0 +1,925 @@ +// 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.Hardwaresecuritymodules.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + internal partial class DedicatedHsmsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DedicatedHsmsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public DedicatedHsmsRestOperations(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-06-30-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string name) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string name) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified Azure dedicated HSM. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = DedicatedHsmData.DeserializeDedicatedHsmData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DedicatedHsmData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified Azure dedicated HSM. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = DedicatedHsmData.DeserializeDedicatedHsmData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DedicatedHsmData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string name, DedicatedHsmData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string name, DedicatedHsmData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, 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 or Update a dedicated HSM in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// Parameters to create or update the dedicated hsm. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string name, DedicatedHsmData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, name, 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 or Update a dedicated HSM in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// Parameters to create or update the dedicated hsm. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string name, DedicatedHsmData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, name, 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 subscriptionId, string resourceGroupName, string name, DedicatedHsmPatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string name, DedicatedHsmPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, 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 dedicated HSM in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// Parameters to patch the dedicated HSM. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string name, DedicatedHsmPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, name, 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 dedicated HSM in the specified subscription. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// Parameters to patch the dedicated HSM. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string name, DedicatedHsmPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, name, 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 subscriptionId, string resourceGroupName, string name) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string name) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the specified Azure Dedicated HSM. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the specified Azure Dedicated HSM. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName, int? top) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, int? top) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Maximum number of results to return. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = DedicatedHsmListResult.DeserializeDedicatedHsmListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Maximum number of results to return. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = DedicatedHsmListResult.DeserializeDedicatedHsmListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId, int? top) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId, int? top) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// The List operation gets information about the dedicated HSMs associated with the subscription. + /// The ID of the target subscription. The value must be an UUID. + /// Maximum number of results to return. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = DedicatedHsmListResult.DeserializeDedicatedHsmListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the dedicated HSMs associated with the subscription. + /// The ID of the target subscription. The value must be an UUID. + /// Maximum number of results to return. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = DedicatedHsmListResult.DeserializeDedicatedHsmListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListOutboundNetworkDependenciesEndpointsRequestUri(string subscriptionId, string resourceGroupName, string name) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/outboundNetworkDependenciesEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListOutboundNetworkDependenciesEndpointsRequest(string subscriptionId, string resourceGroupName, string name) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/", false); + uri.AppendPath(name, true); + uri.AppendPath("/outboundNetworkDependenciesEndpoints", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the specified dedicated hsm resource. The operation returns properties of each egress endpoint. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListOutboundNetworkDependenciesEndpointsAsync(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListOutboundNetworkDependenciesEndpointsRequest(subscriptionId, resourceGroupName, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OutboundEnvironmentEndpointCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = OutboundEnvironmentEndpointCollection.DeserializeOutboundEnvironmentEndpointCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the specified dedicated hsm resource. The operation returns properties of each egress endpoint. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListOutboundNetworkDependenciesEndpoints(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListOutboundNetworkDependenciesEndpointsRequest(subscriptionId, resourceGroupName, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OutboundEnvironmentEndpointCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = OutboundEnvironmentEndpointCollection.DeserializeOutboundEnvironmentEndpointCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, int? top) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, int? top) + { + 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; + } + + /// The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Maximum number of results to return. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = DedicatedHsmListResult.DeserializeDedicatedHsmListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Maximum number of results to return. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = DedicatedHsmListResult.DeserializeDedicatedHsmListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId, int? top) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId, int? top) + { + 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; + } + + /// The List operation gets information about the dedicated HSMs associated with the subscription. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// Maximum number of results to return. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = DedicatedHsmListResult.DeserializeDedicatedHsmListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the dedicated HSMs associated with the subscription. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// Maximum number of results to return. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DedicatedHsmListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = DedicatedHsmListResult.DeserializeDedicatedHsmListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListOutboundNetworkDependenciesEndpointsNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string name) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListOutboundNetworkDependenciesEndpointsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string name) + { + 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; + } + + /// Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the specified dedicated hsm resource. The operation returns properties of each egress endpoint. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListOutboundNetworkDependenciesEndpointsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListOutboundNetworkDependenciesEndpointsNextPageRequest(nextLink, subscriptionId, resourceGroupName, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OutboundEnvironmentEndpointCollection value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = OutboundEnvironmentEndpointCollection.DeserializeOutboundEnvironmentEndpointCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the specified dedicated hsm resource. The operation returns properties of each egress endpoint. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the dedicated Hsm. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListOutboundNetworkDependenciesEndpointsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListOutboundNetworkDependenciesEndpointsNextPageRequest(nextLink, subscriptionId, resourceGroupName, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OutboundEnvironmentEndpointCollection value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = OutboundEnvironmentEndpointCollection.DeserializeOutboundEnvironmentEndpointCollection(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs new file mode 100644 index 000000000000..91203794c15e --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.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.Hardwaresecuritymodules.Models; + +namespace Azure.ResourceManager.Hardwaresecuritymodules +{ + internal partial class PrivateEndpointConnectionsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of PrivateEndpointConnectionsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public PrivateEndpointConnectionsRestOperations(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-06-30-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(peConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(peConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the private endpoint connection for the Cloud Hsm Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, peConnectionName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateEndpointConnectionData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = HardwaresecuritymodulesPrivateEndpointConnectionData.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((HardwaresecuritymodulesPrivateEndpointConnectionData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the private endpoint connection for the Cloud Hsm Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, peConnectionName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateEndpointConnectionData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = HardwaresecuritymodulesPrivateEndpointConnectionData.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((HardwaresecuritymodulesPrivateEndpointConnectionData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName, HardwaresecuritymodulesPrivateEndpointConnectionData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(peConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName, HardwaresecuritymodulesPrivateEndpointConnectionData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(peConnectionName, 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; + } + + /// Creates or updates the private endpoint connection for the Cloud Hsm Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// Parameters of the PrivateEndpointConnection. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> CreateAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName, HardwaresecuritymodulesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, peConnectionName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateEndpointConnectionData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = HardwaresecuritymodulesPrivateEndpointConnectionData.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or updates the private endpoint connection for the Cloud Hsm Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// Parameters of the PrivateEndpointConnection. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Create(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName, HardwaresecuritymodulesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, peConnectionName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateEndpointConnectionData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = HardwaresecuritymodulesPrivateEndpointConnectionData.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(peConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(peConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the private endpoint connection for the Cloud Hsm Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, peConnectionName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the private endpoint connection for the Cloud Hsm Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// Name of the private endpoint connection associated with the Cloud HSM Cluster. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, string peConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + Argument.AssertNotNullOrEmpty(peConnectionName, nameof(peConnectionName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, cloudHsmClusterName, peConnectionName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByCloudHsmClusterRequestUri(string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateEndpointConnections", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByCloudHsmClusterRequest(string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/", false); + uri.AppendPath(cloudHsmClusterName, true); + uri.AppendPath("/privateEndpointConnections", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// The List operation gets information about the private endpoint connections associated with the Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCloudHsmClusterAsync(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateListByCloudHsmClusterRequest(subscriptionId, resourceGroupName, cloudHsmClusterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateEndpointConnectionListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = HardwaresecuritymodulesPrivateEndpointConnectionListResult.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the private endpoint connections associated with the Cloud HSM Cluster. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCloudHsmCluster(string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateListByCloudHsmClusterRequest(subscriptionId, resourceGroupName, cloudHsmClusterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateEndpointConnectionListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = HardwaresecuritymodulesPrivateEndpointConnectionListResult.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByCloudHsmClusterNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByCloudHsmClusterNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string cloudHsmClusterName) + { + 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; + } + + /// The List operation gets information about the private endpoint connections associated with the Cloud HSM Cluster. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCloudHsmClusterNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateListByCloudHsmClusterNextPageRequest(nextLink, subscriptionId, resourceGroupName, cloudHsmClusterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateEndpointConnectionListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = HardwaresecuritymodulesPrivateEndpointConnectionListResult.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The List operation gets information about the private endpoint connections associated with the Cloud HSM Cluster. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Cloud HSM Cluster within the specified resource group. Cloud HSM Cluster names must be between 3 and 23 characters in length. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCloudHsmClusterNextPage(string nextLink, string subscriptionId, string resourceGroupName, string cloudHsmClusterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(cloudHsmClusterName, nameof(cloudHsmClusterName)); + + using var message = CreateListByCloudHsmClusterNextPageRequest(nextLink, subscriptionId, resourceGroupName, cloudHsmClusterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + HardwaresecuritymodulesPrivateEndpointConnectionListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = HardwaresecuritymodulesPrivateEndpointConnectionListResult.DeserializeHardwaresecuritymodulesPrivateEndpointConnectionListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Properties/AssemblyInfo.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..a88825dcb43b --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/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.Hardwaresecuritymodules.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("Hardwaresecuritymodules")] diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tests/Azure.ResourceManager.Hardwaresecuritymodules.Tests.csproj b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tests/Azure.ResourceManager.Hardwaresecuritymodules.Tests.csproj new file mode 100644 index 000000000000..cd8fc846267b --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tests/Azure.ResourceManager.Hardwaresecuritymodules.Tests.csproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tests/HardwaresecuritymodulesManagementTestBase.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tests/HardwaresecuritymodulesManagementTestBase.cs new file mode 100644 index 000000000000..7cc3c04733a6 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tests/HardwaresecuritymodulesManagementTestBase.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Tests +{ + public class HardwaresecuritymodulesManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected HardwaresecuritymodulesManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected HardwaresecuritymodulesManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tests/HardwaresecuritymodulesManagementTestEnvironment.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tests/HardwaresecuritymodulesManagementTestEnvironment.cs new file mode 100644 index 000000000000..a962f7c71236 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tests/HardwaresecuritymodulesManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Hardwaresecuritymodules.Tests +{ + public class HardwaresecuritymodulesManagementTestEnvironment : TestEnvironment + { + } +} diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tsp-location.yaml b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tsp-location.yaml new file mode 100644 index 000000000000..7c4b52b76e27 --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/hardwaresecuritymodules/HardwareSecurityModules.Management +commit: e2be75ed1428d068d3ea9f08828e79308f31c4fe +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/ci.mgmt.yml b/sdk/resourcemanager/ci.mgmt.yml index 9ae0a7e75290..344606332478 100644 --- a/sdk/resourcemanager/ci.mgmt.yml +++ b/sdk/resourcemanager/ci.mgmt.yml @@ -96,6 +96,7 @@ trigger: - sdk/grafana/Azure.ResourceManager.Grafana - sdk/graphservices/Azure.ResourceManager.GraphServices - sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration + - sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules - sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules - sdk/hdinsight/Azure.ResourceManager.HDInsight - sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers @@ -312,6 +313,7 @@ pr: - sdk/grafana/Azure.ResourceManager.Grafana - sdk/graphservices/Azure.ResourceManager.GraphServices - sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration + - sdk/hardwaresecuritymodules/Azure.ResourceManager.Hardwaresecuritymodules - sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules - sdk/hdinsight/Azure.ResourceManager.HDInsight - sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers diff --git a/sdk/storage/ci.yml b/sdk/storage/ci.yml index 2ca0501b60bd..4e749e6b85b1 100644 --- a/sdk/storage/ci.yml +++ b/sdk/storage/ci.yml @@ -12,6 +12,8 @@ trigger: - sdk/storage/Azure.Storage.DataMovement/ - sdk/storage/Azure.Storage.DataMovement.Blobs/ - sdk/storage/Azure.Storage.DataMovement.Files/ + exclude: + - sdk/storage/Azure.ResourceManager.Storage/ - sdk/storage/Azure.Storage.DataMovement.Blobs.Files.Shares/ exclude: - sdk/storage/Azure.ResourceManager.Storage/