From df46e041d18c27287e3994c1204734ef40701a32 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 20 Feb 2023 07:26:12 +0000 Subject: [PATCH] CodeGen from PR 22711 in Azure/azure-rest-api-specs Merge c8c02d04d6e9c2dc26ed5c77c918802e77d47818 into b9fb4f928d43473893bff4d6291098a8a75f3870 --- .../Azure.ResourceManager.Voiceservices.sln | 51 ++ .../CHANGELOG.md | 17 + .../Directory.Build.props | 6 + .../README.md | 80 +++ ...Azure.ResourceManager.Voiceservices.csproj | 8 + .../Generated/ArmVoiceservicesModelFactory.cs | 80 +++ .../CommunicationsGatewayCollection.cs | 341 +++++++++ .../Generated/CommunicationsGatewayData.cs | 122 ++++ .../CommunicationsGatewayResource.cs | 655 ++++++++++++++++++ .../ResourceGroupResourceExtensionClient.cs | 41 ++ .../SubscriptionResourceExtensionClient.cs | 158 +++++ .../Extensions/VoiceservicesExtensions.cs | 226 ++++++ .../CommunicationsGatewayOperationSource.cs | 40 ++ .../TestLineOperationSource.cs | 40 ++ .../VoiceservicesArmOperation.cs | 70 ++ .../VoiceservicesArmOperationOfT.cs | 76 ++ .../AutoGeneratedDomainNameLabelScope.cs | 57 ++ ...ckNameAvailabilityContent.Serialization.cs | 31 + .../Models/CheckNameAvailabilityContent.cs | 23 + .../Models/CheckNameAvailabilityReason.cs | 51 ++ ...kNameAvailabilityResponse.Serialization.cs | 51 ++ .../Models/CheckNameAvailabilityResponse.cs | 36 + ...CommunicationsGatewayData.Serialization.cs | 339 +++++++++ ...icationsGatewayListResult.Serialization.cs | 48 ++ .../Models/CommunicationsGatewayListResult.cs | 43 ++ ...ommunicationsGatewayPatch.Serialization.cs | 32 + .../Models/CommunicationsGatewayPatch.cs | 25 + .../Models/CommunicationsPlatform.cs | 51 ++ .../src/Generated/Models/Connectivity.cs | 48 ++ .../src/Generated/Models/E911Type.cs | 51 ++ .../PrimaryRegionProperties.Serialization.cs | 126 ++++ .../Models/PrimaryRegionProperties.cs | 53 ++ .../src/Generated/Models/ProvisioningState.cs | 54 ++ .../ServiceRegionProperties.Serialization.cs | 45 ++ .../Models/ServiceRegionProperties.cs | 34 + .../src/Generated/Models/Status.cs | 51 ++ .../src/Generated/Models/TeamsCodec.cs | 63 ++ .../Models/TestLineData.Serialization.cs | 149 ++++ .../TestLineListResult.Serialization.cs | 48 ++ .../Generated/Models/TestLineListResult.cs | 43 ++ .../Models/TestLinePatch.Serialization.cs | 32 + .../src/Generated/Models/TestLinePatch.cs | 25 + .../src/Generated/Models/TestLinePurpose.cs | 51 ++ .../src/Generated/ProviderConstants.cs | 16 + .../CommunicationsGatewaysRestOperations.cs | 638 +++++++++++++++++ .../NameAvailabilityRestOperations.cs | 119 ++++ .../RestOperations/TestLinesRestOperations.cs | 537 ++++++++++++++ .../src/Generated/TestLineCollection.cs | 340 +++++++++ .../src/Generated/TestLineData.cs | 48 ++ .../src/Generated/TestLineResource.cs | 601 ++++++++++++++++ .../src/Properties/AssemblyInfo.cs | 9 + .../src/autorest.md | 49 ++ ...ResourceManager.Voiceservices.Tests.csproj | 5 + .../tests/autorest.tests.md | 13 + .../tests/voiceservicesManagementTestBase.cs | 41 ++ .../voiceservicesManagementTestEnvironment.cs | 11 + sdk/voiceservices/ci.mgmt.yml | 24 + 57 files changed, 6122 insertions(+) create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/Azure.ResourceManager.Voiceservices.sln create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/CHANGELOG.md create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/Directory.Build.props create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/README.md create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Azure.ResourceManager.Voiceservices.csproj create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/ArmVoiceservicesModelFactory.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayCollection.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayData.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayResource.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/VoiceservicesExtensions.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/CommunicationsGatewayOperationSource.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/TestLineOperationSource.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/VoiceservicesArmOperation.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/VoiceservicesArmOperationOfT.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/AutoGeneratedDomainNameLabelScope.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityContent.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityContent.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityReason.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityResponse.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityResponse.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayData.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayListResult.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayListResult.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayPatch.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayPatch.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsPlatform.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/Connectivity.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/E911Type.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/PrimaryRegionProperties.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/PrimaryRegionProperties.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ProvisioningState.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ServiceRegionProperties.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ServiceRegionProperties.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/Status.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TeamsCodec.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineData.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineListResult.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineListResult.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePatch.Serialization.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePatch.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePurpose.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/ProviderConstants.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/CommunicationsGatewaysRestOperations.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/NameAvailabilityRestOperations.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/TestLinesRestOperations.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineCollection.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineData.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineResource.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Properties/AssemblyInfo.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/autorest.md create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/Azure.ResourceManager.Voiceservices.Tests.csproj create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/autorest.tests.md create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/voiceservicesManagementTestBase.cs create mode 100644 sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/voiceservicesManagementTestEnvironment.cs create mode 100644 sdk/voiceservices/ci.mgmt.yml diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/Azure.ResourceManager.Voiceservices.sln b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/Azure.ResourceManager.Voiceservices.sln new file mode 100644 index 0000000000000..a09fa89054c95 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/Azure.ResourceManager.Voiceservices.sln @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30309.148 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{451C03B9-D102-44FF-BB80-9E19F9798B47}") = "Azure.ResourceManager.Voiceservices", "src\Azure.ResourceManager.Voiceservices.csproj", "{4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}" +EndProject +Project("{451C03B9-D102-44FF-BB80-9E19F9798B47}") = "Azure.ResourceManager.Voiceservices.Tests", "tests\Azure.ResourceManager.Voiceservices.Tests.csproj", "{BADA7FC4-E037-471F-96EF-F33605CEAF04}" +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ACC4939F-7C7F-4ADC-8523-DB3E5396081E} + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Debug|x64.Build.0 = Debug|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Debug|x86.Build.0 = Debug|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Release|Any CPU.Build.0 = Release|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Release|x64.ActiveCfg = Release|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Release|x64.Build.0 = Release|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Release|x86.ActiveCfg = Release|Any CPU + {4F1113E9-72D1-4BC9-A55A-A32CF1AC5104}.Release|x86.Build.0 = Release|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Debug|x64.ActiveCfg = Debug|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Debug|x64.Build.0 = Debug|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Debug|x86.ActiveCfg = Debug|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Debug|x86.Build.0 = Debug|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Release|Any CPU.Build.0 = Release|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Release|x64.ActiveCfg = Release|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Release|x64.Build.0 = Release|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Release|x86.ActiveCfg = Release|Any CPU + {BADA7FC4-E037-471F-96EF-F33605CEAF04}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/CHANGELOG.md b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/CHANGELOG.md new file mode 100644 index 0000000000000..23f86d1e896ee --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/CHANGELOG.md @@ -0,0 +1,17 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### General New Features + +This package 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. + +This package is a Public Preview version, so expect incompatible changes in subsequent releases as we improve the product. To provide feedback, submit an issue in our [Azure SDK for .NET GitHub repo](https://github.com/Azure/azure-sdk-for-net/issues). + +> NOTE: For more information about unified authentication, please refer to [Microsoft Azure Identity documentation for .NET](https://docs.microsoft.com//dotnet/api/overview/azure/identity-readme?view=azure-dotnet). \ No newline at end of file diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/Directory.Build.props b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/Directory.Build.props new file mode 100644 index 0000000000000..1a9611bd49242 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/README.md b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/README.md new file mode 100644 index 0000000000000..f6404db1ce82c --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure voiceservices 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 voiceservices management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.Voiceservices --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://docs.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ \ No newline at end of file diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Azure.ResourceManager.Voiceservices.csproj b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Azure.ResourceManager.Voiceservices.csproj new file mode 100644 index 0000000000000..981dfe15a13e4 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Azure.ResourceManager.Voiceservices.csproj @@ -0,0 +1,8 @@ + + + 1.0.0-beta.1 + Azure.ResourceManager.Voiceservices + Azure Resource Manager client SDK for Azure resource provider voiceservices. + azure;management;arm;resource manager;voiceservices + + diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/ArmVoiceservicesModelFactory.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/ArmVoiceservicesModelFactory.cs new file mode 100644 index 0000000000000..5db0e18c78db6 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/ArmVoiceservicesModelFactory.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; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Voiceservices; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// Model factory for models. + public static partial class ArmVoiceservicesModelFactory + { + /// Initializes a new instance of CommunicationsGatewayData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Resource provisioning state. + /// The current status of the deployment. + /// The regions in which to deploy the resources needed for Teams Calling. + /// How to connect back to the operator network, e.g. MAPS. + /// Voice codecs to support. + /// How to handle 911 calls. + /// What platforms to support. + /// Details of API bridge functionality, if required. + /// The scope at which the auto-generated domain name can be re-used. + /// The autogenerated label used as part of the FQDNs for accessing the Communications Gateway. + /// This number is used in Teams Phone Mobile scenarios for access to the voicemail IVR from the native dialer. + /// Whether an on-premises Mobile Control Point is in use. + /// A list of dial strings used for emergency calling. + /// A new instance for mocking. + public static CommunicationsGatewayData CommunicationsGatewayData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ProvisioningState? provisioningState = null, Status? status = null, IEnumerable serviceLocations = null, Connectivity? connectivity = null, IEnumerable codecs = null, E911Type? e911Type = null, IEnumerable platforms = null, BinaryData apiBridge = null, AutoGeneratedDomainNameLabelScope? autoGeneratedDomainNameLabelScope = null, string autoGeneratedDomainNameLabel = null, string teamsVoicemailPilotNumber = null, bool? onPremMcpEnabled = null, IEnumerable emergencyDialStrings = null) + { + tags ??= new Dictionary(); + serviceLocations ??= new List(); + codecs ??= new List(); + platforms ??= new List(); + emergencyDialStrings ??= new List(); + + return new CommunicationsGatewayData(id, name, resourceType, systemData, tags, location, provisioningState, status, serviceLocations?.ToList(), connectivity, codecs?.ToList(), e911Type, platforms?.ToList(), apiBridge, autoGeneratedDomainNameLabelScope, autoGeneratedDomainNameLabel, teamsVoicemailPilotNumber, onPremMcpEnabled, emergencyDialStrings?.ToList()); + } + + /// Initializes a new instance of CheckNameAvailabilityResponse. + /// Indicates if the resource name is available. + /// The reason why the given name is not available. + /// Detailed reason why the given name is not available. + /// A new instance for mocking. + public static CheckNameAvailabilityResponse CheckNameAvailabilityResponse(bool? nameAvailable = null, CheckNameAvailabilityReason? reason = null, string message = null) + { + return new CheckNameAvailabilityResponse(nameAvailable, reason, message); + } + + /// Initializes a new instance of TestLineData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Resource provisioning state. + /// The phone number. + /// Purpose of this test line, e.g. automated or manual testing. + /// A new instance for mocking. + public static TestLineData TestLineData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ProvisioningState? provisioningState = null, string phoneNumber = null, TestLinePurpose? purpose = null) + { + tags ??= new Dictionary(); + + return new TestLineData(id, name, resourceType, systemData, tags, location, provisioningState, phoneNumber, purpose); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayCollection.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayCollection.cs new file mode 100644 index 0000000000000..166ff4fd05f1c --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayCollection.cs @@ -0,0 +1,341 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Voiceservices +{ + /// + /// 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 GetCommunicationsGateways method from an instance of . + /// + public partial class CommunicationsGatewayCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _communicationsGatewayClientDiagnostics; + private readonly CommunicationsGatewaysRestOperations _communicationsGatewayRestClient; + + /// Initializes a new instance of the class for mocking. + protected CommunicationsGatewayCollection() + { + } + + /// 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 CommunicationsGatewayCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _communicationsGatewayClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Voiceservices", CommunicationsGatewayResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(CommunicationsGatewayResource.ResourceType, out string communicationsGatewayApiVersion); + _communicationsGatewayRestClient = new CommunicationsGatewaysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, communicationsGatewayApiVersion); +#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 a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_CreateOrUpdate + /// + /// + /// + /// 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. + /// Unique identifier for this deployment. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string communicationsGatewayName, CommunicationsGatewayData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _communicationsGatewayRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, communicationsGatewayName, data, cancellationToken).ConfigureAwait(false); + var operation = new VoiceservicesArmOperation(new CommunicationsGatewayOperationSource(Client), _communicationsGatewayClientDiagnostics, Pipeline, _communicationsGatewayRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, communicationsGatewayName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_CreateOrUpdate + /// + /// + /// + /// 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. + /// Unique identifier for this deployment. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string communicationsGatewayName, CommunicationsGatewayData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _communicationsGatewayRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, communicationsGatewayName, data, cancellationToken); + var operation = new VoiceservicesArmOperation(new CommunicationsGatewayOperationSource(Client), _communicationsGatewayClientDiagnostics, Pipeline, _communicationsGatewayRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, communicationsGatewayName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayCollection.Get"); + scope.Start(); + try + { + var response = await _communicationsGatewayRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, communicationsGatewayName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunicationsGatewayResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayCollection.Get"); + scope.Start(); + try + { + var response = _communicationsGatewayRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, communicationsGatewayName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunicationsGatewayResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List CommunicationsGateway resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways + /// + /// + /// Operation Id + /// CommunicationsGateways_ListByResourceGroup + /// + /// + /// + /// 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) => _communicationsGatewayRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _communicationsGatewayRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CommunicationsGatewayResource(Client, CommunicationsGatewayData.DeserializeCommunicationsGatewayData(e)), _communicationsGatewayClientDiagnostics, Pipeline, "CommunicationsGatewayCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List CommunicationsGateway resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways + /// + /// + /// Operation Id + /// CommunicationsGateways_ListByResourceGroup + /// + /// + /// + /// 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) => _communicationsGatewayRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _communicationsGatewayRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CommunicationsGatewayResource(Client, CommunicationsGatewayData.DeserializeCommunicationsGatewayData(e)), _communicationsGatewayClientDiagnostics, Pipeline, "CommunicationsGatewayCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayCollection.Exists"); + scope.Start(); + try + { + var response = await _communicationsGatewayRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, communicationsGatewayName, 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.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayCollection.Exists"); + scope.Start(); + try + { + var response = _communicationsGatewayRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, communicationsGatewayName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayData.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayData.cs new file mode 100644 index 0000000000000..f2950025bd3bd --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayData.cs @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + /// A class representing the CommunicationsGateway data model. + public partial class CommunicationsGatewayData : TrackedResourceData + { + /// Initializes a new instance of CommunicationsGatewayData. + /// The location. + public CommunicationsGatewayData(AzureLocation location) : base(location) + { + ServiceLocations = new ChangeTrackingList(); + Codecs = new ChangeTrackingList(); + Platforms = new ChangeTrackingList(); + EmergencyDialStrings = new ChangeTrackingList(); + } + + /// Initializes a new instance of CommunicationsGatewayData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Resource provisioning state. + /// The current status of the deployment. + /// The regions in which to deploy the resources needed for Teams Calling. + /// How to connect back to the operator network, e.g. MAPS. + /// Voice codecs to support. + /// How to handle 911 calls. + /// What platforms to support. + /// Details of API bridge functionality, if required. + /// The scope at which the auto-generated domain name can be re-used. + /// The autogenerated label used as part of the FQDNs for accessing the Communications Gateway. + /// This number is used in Teams Phone Mobile scenarios for access to the voicemail IVR from the native dialer. + /// Whether an on-premises Mobile Control Point is in use. + /// A list of dial strings used for emergency calling. + internal CommunicationsGatewayData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ProvisioningState? provisioningState, Status? status, IList serviceLocations, Connectivity? connectivity, IList codecs, E911Type? e911Type, IList platforms, BinaryData apiBridge, AutoGeneratedDomainNameLabelScope? autoGeneratedDomainNameLabelScope, string autoGeneratedDomainNameLabel, string teamsVoicemailPilotNumber, bool? onPremMcpEnabled, IList emergencyDialStrings) : base(id, name, resourceType, systemData, tags, location) + { + ProvisioningState = provisioningState; + Status = status; + ServiceLocations = serviceLocations; + Connectivity = connectivity; + Codecs = codecs; + E911Type = e911Type; + Platforms = platforms; + ApiBridge = apiBridge; + AutoGeneratedDomainNameLabelScope = autoGeneratedDomainNameLabelScope; + AutoGeneratedDomainNameLabel = autoGeneratedDomainNameLabel; + TeamsVoicemailPilotNumber = teamsVoicemailPilotNumber; + OnPremMcpEnabled = onPremMcpEnabled; + EmergencyDialStrings = emergencyDialStrings; + } + + /// Resource provisioning state. + public ProvisioningState? ProvisioningState { get; } + /// The current status of the deployment. + public Status? Status { get; } + /// The regions in which to deploy the resources needed for Teams Calling. + public IList ServiceLocations { get; } + /// How to connect back to the operator network, e.g. MAPS. + public Connectivity? Connectivity { get; set; } + /// Voice codecs to support. + public IList Codecs { get; } + /// How to handle 911 calls. + public E911Type? E911Type { get; set; } + /// What platforms to support. + public IList Platforms { get; } + /// + /// Details of API bridge functionality, if required + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formated json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ApiBridge { get; set; } + /// The scope at which the auto-generated domain name can be re-used. + public AutoGeneratedDomainNameLabelScope? AutoGeneratedDomainNameLabelScope { get; set; } + /// The autogenerated label used as part of the FQDNs for accessing the Communications Gateway. + public string AutoGeneratedDomainNameLabel { get; } + /// This number is used in Teams Phone Mobile scenarios for access to the voicemail IVR from the native dialer. + public string TeamsVoicemailPilotNumber { get; set; } + /// Whether an on-premises Mobile Control Point is in use. + public bool? OnPremMcpEnabled { get; set; } + /// A list of dial strings used for emergency calling. + public IList EmergencyDialStrings { get; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayResource.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayResource.cs new file mode 100644 index 0000000000000..bf2e3bc8cbfaa --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/CommunicationsGatewayResource.cs @@ -0,0 +1,655 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + /// + /// A Class representing a CommunicationsGateway 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 GetCommunicationsGatewayResource method. + /// Otherwise you can get one from its parent resource using the GetCommunicationsGateway method. + /// + public partial class CommunicationsGatewayResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string communicationsGatewayName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _communicationsGatewayClientDiagnostics; + private readonly CommunicationsGatewaysRestOperations _communicationsGatewayRestClient; + private readonly CommunicationsGatewayData _data; + + /// Initializes a new instance of the class for mocking. + protected CommunicationsGatewayResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal CommunicationsGatewayResource(ArmClient client, CommunicationsGatewayData 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 CommunicationsGatewayResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _communicationsGatewayClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Voiceservices", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string communicationsGatewayApiVersion); + _communicationsGatewayRestClient = new CommunicationsGatewaysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, communicationsGatewayApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.VoiceServices/communicationsGateways"; + + /// 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 CommunicationsGatewayData 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 TestLineResources in the CommunicationsGateway. + /// An object representing collection of TestLineResources and their operations over a TestLineResource. + public virtual TestLineCollection GetTestLines() + { + return GetCachedClient(Client => new TestLineCollection(Client, Id)); + } + + /// + /// Get a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// Unique identifier for this test line. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetTestLineAsync(string testLineName, CancellationToken cancellationToken = default) + { + return await GetTestLines().GetAsync(testLineName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// Unique identifier for this test line. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetTestLine(string testLineName, CancellationToken cancellationToken = default) + { + return GetTestLines().Get(testLineName, cancellationToken); + } + + /// + /// Get a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.Get"); + scope.Start(); + try + { + var response = await _communicationsGatewayRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunicationsGatewayResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.Get"); + scope.Start(); + try + { + var response = _communicationsGatewayRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CommunicationsGatewayResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Delete + /// + /// + /// + /// 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 = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.Delete"); + scope.Start(); + try + { + var response = await _communicationsGatewayRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VoiceservicesArmOperation(_communicationsGatewayClientDiagnostics, Pipeline, _communicationsGatewayRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Delete + /// + /// + /// + /// 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 = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.Delete"); + scope.Start(); + try + { + var response = _communicationsGatewayRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new VoiceservicesArmOperation(_communicationsGatewayClientDiagnostics, Pipeline, _communicationsGatewayRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Update + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(CommunicationsGatewayPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.Update"); + scope.Start(); + try + { + var response = await _communicationsGatewayRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunicationsGatewayResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Update + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(CommunicationsGatewayPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.Update"); + scope.Start(); + try + { + var response = _communicationsGatewayRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + return Response.FromValue(new CommunicationsGatewayResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// 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 = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.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 _communicationsGatewayRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunicationsGatewayResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CommunicationsGatewayPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// 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 = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.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 = _communicationsGatewayRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CommunicationsGatewayResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CommunicationsGatewayPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + 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.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// 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 = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.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 _communicationsGatewayRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunicationsGatewayResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CommunicationsGatewayPatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + 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.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// 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 = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.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 = _communicationsGatewayRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CommunicationsGatewayResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CommunicationsGatewayPatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// 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 = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.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 _communicationsGatewayRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommunicationsGatewayResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CommunicationsGatewayPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// 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 = _communicationsGatewayClientDiagnostics.CreateScope("CommunicationsGatewayResource.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 = _communicationsGatewayRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CommunicationsGatewayResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CommunicationsGatewayPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs new file mode 100644 index 0000000000000..0a00cca0b22da --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Voiceservices +{ + /// A class to add extension methods to ResourceGroupResource. + internal partial class ResourceGroupResourceExtensionClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected ResourceGroupResourceExtensionClient() + { + } + + /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of CommunicationsGatewayResources in the ResourceGroupResource. + /// An object representing collection of CommunicationsGatewayResources and their operations over a CommunicationsGatewayResource. + public virtual CommunicationsGatewayCollection GetCommunicationsGateways() + { + return GetCachedClient(Client => new CommunicationsGatewayCollection(Client, Id)); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs new file mode 100644 index 0000000000000..fc33012f40b62 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + /// A class to add extension methods to SubscriptionResource. + internal partial class SubscriptionResourceExtensionClient : ArmResource + { + private ClientDiagnostics _communicationsGatewayClientDiagnostics; + private CommunicationsGatewaysRestOperations _communicationsGatewayRestClient; + private ClientDiagnostics _nameAvailabilityClientDiagnostics; + private NameAvailabilityRestOperations _nameAvailabilityRestClient; + + /// Initializes a new instance of the class for mocking. + protected SubscriptionResourceExtensionClient() + { + } + + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics CommunicationsGatewayClientDiagnostics => _communicationsGatewayClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Voiceservices", CommunicationsGatewayResource.ResourceType.Namespace, Diagnostics); + private CommunicationsGatewaysRestOperations CommunicationsGatewayRestClient => _communicationsGatewayRestClient ??= new CommunicationsGatewaysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(CommunicationsGatewayResource.ResourceType)); + private ClientDiagnostics NameAvailabilityClientDiagnostics => _nameAvailabilityClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Voiceservices", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private NameAvailabilityRestOperations NameAvailabilityRestClient => _nameAvailabilityRestClient ??= new NameAvailabilityRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// List CommunicationsGateway resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/communicationsGateways + /// + /// + /// Operation Id + /// CommunicationsGateways_ListBySubscription + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetCommunicationsGatewaysAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CommunicationsGatewayRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CommunicationsGatewayRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CommunicationsGatewayResource(Client, CommunicationsGatewayData.DeserializeCommunicationsGatewayData(e)), CommunicationsGatewayClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetCommunicationsGateways", "value", "nextLink", cancellationToken); + } + + /// + /// List CommunicationsGateway resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/communicationsGateways + /// + /// + /// Operation Id + /// CommunicationsGateways_ListBySubscription + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetCommunicationsGateways(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CommunicationsGatewayRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CommunicationsGatewayRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CommunicationsGatewayResource(Client, CommunicationsGatewayData.DeserializeCommunicationsGatewayData(e)), CommunicationsGatewayClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetCommunicationsGateways", "value", "nextLink", cancellationToken); + } + + /// + /// Check whether the resource name is available in the given region. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/locations/{location}/checkNameAvailability + /// + /// + /// Operation Id + /// NameAvailability_CheckLocal + /// + /// + /// + /// The location in which uniqueness will be verified. + /// The check availability request body. + /// The cancellation token to use. + public virtual async Task> CheckLocalNameAvailabilityAsync(AzureLocation location, CheckNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + using var scope = NameAvailabilityClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.CheckLocalNameAvailability"); + scope.Start(); + try + { + var response = await NameAvailabilityRestClient.CheckLocalAsync(Id.SubscriptionId, location, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Check whether the resource name is available in the given region. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/locations/{location}/checkNameAvailability + /// + /// + /// Operation Id + /// NameAvailability_CheckLocal + /// + /// + /// + /// The location in which uniqueness will be verified. + /// The check availability request body. + /// The cancellation token to use. + public virtual Response CheckLocalNameAvailability(AzureLocation location, CheckNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + using var scope = NameAvailabilityClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.CheckLocalNameAvailability"); + scope.Start(); + try + { + var response = NameAvailabilityRestClient.CheckLocal(Id.SubscriptionId, location, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/VoiceservicesExtensions.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/VoiceservicesExtensions.cs new file mode 100644 index 0000000000000..e61dcaf9e2c61 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Extensions/VoiceservicesExtensions.cs @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + /// A class to add extension methods to Azure.ResourceManager.Voiceservices. + public static partial class VoiceservicesExtensions + { + private static SubscriptionResourceExtensionClient GetExtensionClient(SubscriptionResource subscriptionResource) + { + return subscriptionResource.GetCachedClient((client) => + { + return new SubscriptionResourceExtensionClient(client, subscriptionResource.Id); + } + ); + } + + /// + /// List CommunicationsGateway resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/communicationsGateways + /// + /// + /// Operation Id + /// CommunicationsGateways_ListBySubscription + /// + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetCommunicationsGatewaysAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + return GetExtensionClient(subscriptionResource).GetCommunicationsGatewaysAsync(cancellationToken); + } + + /// + /// List CommunicationsGateway resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/communicationsGateways + /// + /// + /// Operation Id + /// CommunicationsGateways_ListBySubscription + /// + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetCommunicationsGateways(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + return GetExtensionClient(subscriptionResource).GetCommunicationsGateways(cancellationToken); + } + + /// + /// Check whether the resource name is available in the given region. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/locations/{location}/checkNameAvailability + /// + /// + /// Operation Id + /// NameAvailability_CheckLocal + /// + /// + /// + /// The instance the method will execute against. + /// The location in which uniqueness will be verified. + /// The check availability request body. + /// The cancellation token to use. + /// is null. + public static async Task> CheckLocalNameAvailabilityAsync(this SubscriptionResource subscriptionResource, AzureLocation location, CheckNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + return await GetExtensionClient(subscriptionResource).CheckLocalNameAvailabilityAsync(location, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// Check whether the resource name is available in the given region. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/locations/{location}/checkNameAvailability + /// + /// + /// Operation Id + /// NameAvailability_CheckLocal + /// + /// + /// + /// The instance the method will execute against. + /// The location in which uniqueness will be verified. + /// The check availability request body. + /// The cancellation token to use. + /// is null. + public static Response CheckLocalNameAvailability(this SubscriptionResource subscriptionResource, AzureLocation location, CheckNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + return GetExtensionClient(subscriptionResource).CheckLocalNameAvailability(location, content, cancellationToken); + } + + private static ResourceGroupResourceExtensionClient GetExtensionClient(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient((client) => + { + return new ResourceGroupResourceExtensionClient(client, resourceGroupResource.Id); + } + ); + } + + /// Gets a collection of CommunicationsGatewayResources in the ResourceGroupResource. + /// The instance the method will execute against. + /// An object representing collection of CommunicationsGatewayResources and their operations over a CommunicationsGatewayResource. + public static CommunicationsGatewayCollection GetCommunicationsGateways(this ResourceGroupResource resourceGroupResource) + { + return GetExtensionClient(resourceGroupResource).GetCommunicationsGateways(); + } + + /// + /// Get a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// The instance the method will execute against. + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public static async Task> GetCommunicationsGatewayAsync(this ResourceGroupResource resourceGroupResource, string communicationsGatewayName, CancellationToken cancellationToken = default) + { + return await resourceGroupResource.GetCommunicationsGateways().GetAsync(communicationsGatewayName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName} + /// + /// + /// Operation Id + /// CommunicationsGateways_Get + /// + /// + /// + /// The instance the method will execute against. + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public static Response GetCommunicationsGateway(this ResourceGroupResource resourceGroupResource, string communicationsGatewayName, CancellationToken cancellationToken = default) + { + return resourceGroupResource.GetCommunicationsGateways().Get(communicationsGatewayName, cancellationToken); + } + + #region CommunicationsGatewayResource + /// + /// 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 instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static CommunicationsGatewayResource GetCommunicationsGatewayResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + CommunicationsGatewayResource.ValidateResourceId(id); + return new CommunicationsGatewayResource(client, id); + } + ); + } + #endregion + + #region TestLineResource + /// + /// 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 instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static TestLineResource GetTestLineResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + TestLineResource.ValidateResourceId(id); + return new TestLineResource(client, id); + } + ); + } + #endregion + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/CommunicationsGatewayOperationSource.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/CommunicationsGatewayOperationSource.cs new file mode 100644 index 0000000000000..b0bb21d4cc187 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/CommunicationsGatewayOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Voiceservices +{ + internal class CommunicationsGatewayOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal CommunicationsGatewayOperationSource(ArmClient client) + { + _client = client; + } + + CommunicationsGatewayResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = CommunicationsGatewayData.DeserializeCommunicationsGatewayData(document.RootElement); + return new CommunicationsGatewayResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = CommunicationsGatewayData.DeserializeCommunicationsGatewayData(document.RootElement); + return new CommunicationsGatewayResource(_client, data); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/TestLineOperationSource.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/TestLineOperationSource.cs new file mode 100644 index 0000000000000..d7312c7c793f9 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/TestLineOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Voiceservices +{ + internal class TestLineOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal TestLineOperationSource(ArmClient client) + { + _client = client; + } + + TestLineResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = TestLineData.DeserializeTestLineData(document.RootElement); + return new TestLineResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = TestLineData.DeserializeTestLineData(document.RootElement); + return new TestLineResource(_client, data); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/VoiceservicesArmOperation.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/VoiceservicesArmOperation.cs new file mode 100644 index 0000000000000..cfa44cce92e6a --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/VoiceservicesArmOperation.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Voiceservices +{ +#pragma warning disable SA1649 // File name should match first type name + internal class VoiceservicesArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + + /// Initializes a new instance of VoiceservicesArmOperation for mocking. + protected VoiceservicesArmOperation() + { + } + + internal VoiceservicesArmOperation(Response response) + { + _operation = OperationInternal.Succeeded(response); + } + + internal VoiceservicesArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia); + _operation = new OperationInternal(clientDiagnostics, nextLinkOperation, response, "VoiceservicesArmOperation", fallbackStrategy: new ExponentialDelayStrategy()); + } + + /// +#pragma warning disable CA1822 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public override string Id => throw new NotImplementedException(); +#pragma warning restore CA1822 + + /// + 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/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/VoiceservicesArmOperationOfT.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/VoiceservicesArmOperationOfT.cs new file mode 100644 index 0000000000000..9b8eb53302e64 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/LongRunningOperation/VoiceservicesArmOperationOfT.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Voiceservices +{ +#pragma warning disable SA1649 // File name should match first type name + internal class VoiceservicesArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + + /// Initializes a new instance of VoiceservicesArmOperation for mocking. + protected VoiceservicesArmOperation() + { + } + + internal VoiceservicesArmOperation(Response response) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + } + + internal VoiceservicesArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(source, pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia); + _operation = new OperationInternal(clientDiagnostics, nextLinkOperation, response, "VoiceservicesArmOperation", fallbackStrategy: new ExponentialDelayStrategy()); + } + + /// +#pragma warning disable CA1822 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public override string Id => throw new NotImplementedException(); +#pragma warning restore CA1822 + + /// + 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/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/AutoGeneratedDomainNameLabelScope.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/AutoGeneratedDomainNameLabelScope.cs new file mode 100644 index 0000000000000..7dd843ede8d4d --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/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.Voiceservices.Models +{ + /// Available auto-generated domain name scopes. + 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityContent.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityContent.Serialization.cs new file mode 100644 index 0000000000000..426dcdd5f84a4 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityContent.Serialization.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + public partial class CheckNameAvailabilityContent : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(ResourceType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityContent.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityContent.cs new file mode 100644 index 0000000000000..aad236370a109 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityContent.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The check availability request body. + public partial class CheckNameAvailabilityContent + { + /// Initializes a new instance of CheckNameAvailabilityContent. + public CheckNameAvailabilityContent() + { + } + + /// The name of the resource for which availability needs to be checked. + public string Name { get; set; } + /// The resource type. + public string ResourceType { get; set; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityReason.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityReason.cs new file mode 100644 index 0000000000000..e4361f5c76d6f --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityReason.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// Possible reasons for a name not being available. + public readonly partial struct CheckNameAvailabilityReason : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CheckNameAvailabilityReason(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InvalidValue = "Invalid"; + private const string AlreadyExistsValue = "AlreadyExists"; + + /// Invalid. + public static CheckNameAvailabilityReason Invalid { get; } = new CheckNameAvailabilityReason(InvalidValue); + /// AlreadyExists. + public static CheckNameAvailabilityReason AlreadyExists { get; } = new CheckNameAvailabilityReason(AlreadyExistsValue); + /// Determines if two values are the same. + public static bool operator ==(CheckNameAvailabilityReason left, CheckNameAvailabilityReason right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CheckNameAvailabilityReason left, CheckNameAvailabilityReason right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CheckNameAvailabilityReason(string value) => new CheckNameAvailabilityReason(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CheckNameAvailabilityReason other && Equals(other); + /// + public bool Equals(CheckNameAvailabilityReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityResponse.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityResponse.Serialization.cs new file mode 100644 index 0000000000000..95cafc059f12c --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityResponse.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + public partial class CheckNameAvailabilityResponse + { + internal static CheckNameAvailabilityResponse DeserializeCheckNameAvailabilityResponse(JsonElement element) + { + Optional nameAvailable = default; + Optional reason = default; + Optional message = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("nameAvailable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + nameAvailable = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("reason"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + reason = new CheckNameAvailabilityReason(property.Value.GetString()); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + } + return new CheckNameAvailabilityResponse(Optional.ToNullable(nameAvailable), Optional.ToNullable(reason), message.Value); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityResponse.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityResponse.cs new file mode 100644 index 0000000000000..2a9bc77b6279d --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CheckNameAvailabilityResponse.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The check availability result. + public partial class CheckNameAvailabilityResponse + { + /// Initializes a new instance of CheckNameAvailabilityResponse. + internal CheckNameAvailabilityResponse() + { + } + + /// Initializes a new instance of CheckNameAvailabilityResponse. + /// Indicates if the resource name is available. + /// The reason why the given name is not available. + /// Detailed reason why the given name is not available. + internal CheckNameAvailabilityResponse(bool? nameAvailable, CheckNameAvailabilityReason? reason, string message) + { + NameAvailable = nameAvailable; + Reason = reason; + Message = message; + } + + /// Indicates if the resource name is available. + public bool? NameAvailable { get; } + /// The reason why the given name is not available. + public CheckNameAvailabilityReason? Reason { get; } + /// Detailed reason why the given name is not available. + public string Message { get; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayData.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayData.Serialization.cs new file mode 100644 index 0000000000000..bb71076116e50 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayData.Serialization.cs @@ -0,0 +1,339 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + public partial class CommunicationsGatewayData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + 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(); + } + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(ServiceLocations)) + { + writer.WritePropertyName("serviceLocations"u8); + writer.WriteStartArray(); + foreach (var item in ServiceLocations) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Connectivity)) + { + writer.WritePropertyName("connectivity"u8); + writer.WriteStringValue(Connectivity.Value.ToString()); + } + if (Optional.IsCollectionDefined(Codecs)) + { + writer.WritePropertyName("codecs"u8); + writer.WriteStartArray(); + foreach (var item in Codecs) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(E911Type)) + { + writer.WritePropertyName("e911Type"u8); + writer.WriteStringValue(E911Type.Value.ToString()); + } + if (Optional.IsCollectionDefined(Platforms)) + { + writer.WritePropertyName("platforms"u8); + writer.WriteStartArray(); + foreach (var item in Platforms) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ApiBridge)) + { + writer.WritePropertyName("apiBridge"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ApiBridge); +#else + JsonSerializer.Serialize(writer, JsonDocument.Parse(ApiBridge.ToString()).RootElement); +#endif + } + if (Optional.IsDefined(AutoGeneratedDomainNameLabelScope)) + { + writer.WritePropertyName("autoGeneratedDomainNameLabelScope"u8); + writer.WriteStringValue(AutoGeneratedDomainNameLabelScope.Value.ToString()); + } + if (Optional.IsDefined(TeamsVoicemailPilotNumber)) + { + writer.WritePropertyName("teamsVoicemailPilotNumber"u8); + writer.WriteStringValue(TeamsVoicemailPilotNumber); + } + if (Optional.IsDefined(OnPremMcpEnabled)) + { + writer.WritePropertyName("onPremMcpEnabled"u8); + writer.WriteBooleanValue(OnPremMcpEnabled.Value); + } + if (Optional.IsCollectionDefined(EmergencyDialStrings)) + { + writer.WritePropertyName("emergencyDialStrings"u8); + writer.WriteStartArray(); + foreach (var item in EmergencyDialStrings) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static CommunicationsGatewayData DeserializeCommunicationsGatewayData(JsonElement element) + { + Optional> tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional provisioningState = default; + Optional status = default; + Optional> serviceLocations = default; + Optional connectivity = default; + Optional> codecs = default; + Optional e911Type = default; + Optional> platforms = default; + Optional apiBridge = default; + Optional autoGeneratedDomainNameLabelScope = default; + Optional autoGeneratedDomainNameLabel = default; + Optional teamsVoicemailPilotNumber = default; + Optional onPremMcpEnabled = default; + Optional> emergencyDialStrings = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + 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) + { + property.ThrowNonNullablePropertyIsNull(); + 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("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("status"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + status = new Status(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("serviceLocations"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(ServiceRegionProperties.DeserializeServiceRegionProperties(item)); + } + serviceLocations = array; + continue; + } + if (property0.NameEquals("connectivity"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + connectivity = new Connectivity(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("codecs"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(new TeamsCodec(item.GetString())); + } + codecs = array; + continue; + } + if (property0.NameEquals("e911Type"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + e911Type = new E911Type(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("platforms"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(new CommunicationsPlatform(item.GetString())); + } + platforms = array; + continue; + } + if (property0.NameEquals("apiBridge"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + apiBridge = BinaryData.FromString(property0.Value.GetRawText()); + continue; + } + if (property0.NameEquals("autoGeneratedDomainNameLabelScope"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + autoGeneratedDomainNameLabelScope = new AutoGeneratedDomainNameLabelScope(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("autoGeneratedDomainNameLabel"u8)) + { + autoGeneratedDomainNameLabel = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("teamsVoicemailPilotNumber"u8)) + { + teamsVoicemailPilotNumber = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("onPremMcpEnabled"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + onPremMcpEnabled = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("emergencyDialStrings"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + emergencyDialStrings = array; + continue; + } + } + continue; + } + } + return new CommunicationsGatewayData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, Optional.ToNullable(provisioningState), Optional.ToNullable(status), Optional.ToList(serviceLocations), Optional.ToNullable(connectivity), Optional.ToList(codecs), Optional.ToNullable(e911Type), Optional.ToList(platforms), apiBridge.Value, Optional.ToNullable(autoGeneratedDomainNameLabelScope), autoGeneratedDomainNameLabel.Value, teamsVoicemailPilotNumber.Value, Optional.ToNullable(onPremMcpEnabled), Optional.ToList(emergencyDialStrings)); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayListResult.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayListResult.Serialization.cs new file mode 100644 index 0000000000000..403381ebf6418 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayListResult.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Voiceservices; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + internal partial class CommunicationsGatewayListResult + { + internal static CommunicationsGatewayListResult DeserializeCommunicationsGatewayListResult(JsonElement element) + { + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CommunicationsGatewayData.DeserializeCommunicationsGatewayData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + nextLink = null; + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new CommunicationsGatewayListResult(value, nextLink.Value); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayListResult.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayListResult.cs new file mode 100644 index 0000000000000..3afe055b4587f --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Voiceservices; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The response of a CommunicationsGateway list operation. + internal partial class CommunicationsGatewayListResult + { + /// Initializes a new instance of CommunicationsGatewayListResult. + /// The CommunicationsGateway items on this page. + /// is null. + internal CommunicationsGatewayListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of CommunicationsGatewayListResult. + /// The CommunicationsGateway items on this page. + /// The link to the next page of items. + internal CommunicationsGatewayListResult(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The CommunicationsGateway items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayPatch.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayPatch.Serialization.cs new file mode 100644 index 0000000000000..3431853a20121 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayPatch.Serialization.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + public partial class CommunicationsGatewayPatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + 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(); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayPatch.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayPatch.cs new file mode 100644 index 0000000000000..82fe8e7ded477 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsGatewayPatch.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The type used for update operations of the CommunicationsGateway. + public partial class CommunicationsGatewayPatch + { + /// Initializes a new instance of CommunicationsGatewayPatch. + public CommunicationsGatewayPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsPlatform.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsPlatform.cs new file mode 100644 index 0000000000000..df921533d07c0 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/CommunicationsPlatform.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// Available platform types. + public readonly partial struct CommunicationsPlatform : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CommunicationsPlatform(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string OperatorConnectValue = "OperatorConnect"; + private const string TeamsPhoneMobileValue = "TeamsPhoneMobile"; + + /// OperatorConnect. + public static CommunicationsPlatform OperatorConnect { get; } = new CommunicationsPlatform(OperatorConnectValue); + /// TeamsPhoneMobile. + public static CommunicationsPlatform TeamsPhoneMobile { get; } = new CommunicationsPlatform(TeamsPhoneMobileValue); + /// Determines if two values are the same. + public static bool operator ==(CommunicationsPlatform left, CommunicationsPlatform right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CommunicationsPlatform left, CommunicationsPlatform right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CommunicationsPlatform(string value) => new CommunicationsPlatform(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CommunicationsPlatform other && Equals(other); + /// + public bool Equals(CommunicationsPlatform other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/Connectivity.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/Connectivity.cs new file mode 100644 index 0000000000000..1d9e256d36d2e --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/Connectivity.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.Voiceservices.Models +{ + /// How this deployment connects back to the operator network. + public readonly partial struct Connectivity : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public Connectivity(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PublicAddressValue = "PublicAddress"; + + /// This deployment connects to the operator network using a Public IP address, e.g. when using MAPS. + public static Connectivity PublicAddress { get; } = new Connectivity(PublicAddressValue); + /// Determines if two values are the same. + public static bool operator ==(Connectivity left, Connectivity right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Connectivity left, Connectivity right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator Connectivity(string value) => new Connectivity(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Connectivity other && Equals(other); + /// + public bool Equals(Connectivity other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/E911Type.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/E911Type.cs new file mode 100644 index 0000000000000..bf3d7552b8447 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/E911Type.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The method for terminating emergency calls to the PSTN. + public readonly partial struct E911Type : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public E911Type(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string StandardValue = "Standard"; + private const string DirectToEsrpValue = "DirectToEsrp"; + + /// Emergency calls are not handled different from other calls. + public static E911Type Standard { get; } = new E911Type(StandardValue); + /// Emergency calls are routed directly to the ESRP. + public static E911Type DirectToEsrp { get; } = new E911Type(DirectToEsrpValue); + /// Determines if two values are the same. + public static bool operator ==(E911Type left, E911Type right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(E911Type left, E911Type right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator E911Type(string value) => new E911Type(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is E911Type other && Equals(other); + /// + public bool Equals(E911Type other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/PrimaryRegionProperties.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/PrimaryRegionProperties.Serialization.cs new file mode 100644 index 0000000000000..d007b200009a4 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/PrimaryRegionProperties.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + public partial class PrimaryRegionProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("operatorAddresses"u8); + writer.WriteStartArray(); + foreach (var item in OperatorAddresses) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(EsrpAddresses)) + { + writer.WritePropertyName("esrpAddresses"u8); + writer.WriteStartArray(); + foreach (var item in EsrpAddresses) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AllowedSignalingSourceAddressPrefixes)) + { + writer.WritePropertyName("allowedSignalingSourceAddressPrefixes"u8); + writer.WriteStartArray(); + foreach (var item in AllowedSignalingSourceAddressPrefixes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AllowedMediaSourceAddressPrefixes)) + { + writer.WritePropertyName("allowedMediaSourceAddressPrefixes"u8); + writer.WriteStartArray(); + foreach (var item in AllowedMediaSourceAddressPrefixes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + internal static PrimaryRegionProperties DeserializePrimaryRegionProperties(JsonElement element) + { + IList operatorAddresses = default; + Optional> esrpAddresses = default; + Optional> allowedSignalingSourceAddressPrefixes = default; + Optional> allowedMediaSourceAddressPrefixes = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operatorAddresses"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + operatorAddresses = array; + continue; + } + if (property.NameEquals("esrpAddresses"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + esrpAddresses = array; + continue; + } + if (property.NameEquals("allowedSignalingSourceAddressPrefixes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + allowedSignalingSourceAddressPrefixes = array; + continue; + } + if (property.NameEquals("allowedMediaSourceAddressPrefixes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + allowedMediaSourceAddressPrefixes = array; + continue; + } + } + return new PrimaryRegionProperties(operatorAddresses, Optional.ToList(esrpAddresses), Optional.ToList(allowedSignalingSourceAddressPrefixes), Optional.ToList(allowedMediaSourceAddressPrefixes)); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/PrimaryRegionProperties.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/PrimaryRegionProperties.cs new file mode 100644 index 0000000000000..81dfaf588c72f --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/PrimaryRegionProperties.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The configuration used in this region as primary, and other regions as backup. + public partial class PrimaryRegionProperties + { + /// Initializes a new instance of PrimaryRegionProperties. + /// IP address to use to contact the operator network from this region. + /// is null. + public PrimaryRegionProperties(IEnumerable operatorAddresses) + { + Argument.AssertNotNull(operatorAddresses, nameof(operatorAddresses)); + + OperatorAddresses = operatorAddresses.ToList(); + EsrpAddresses = new ChangeTrackingList(); + AllowedSignalingSourceAddressPrefixes = new ChangeTrackingList(); + AllowedMediaSourceAddressPrefixes = new ChangeTrackingList(); + } + + /// Initializes a new instance of PrimaryRegionProperties. + /// IP address to use to contact the operator network from this region. + /// IP address to use to contact the ESRP from this region. + /// The allowed source IP address or CIDR ranges for signaling. + /// The allowed source IP address or CIDR ranges for media. + internal PrimaryRegionProperties(IList operatorAddresses, IList esrpAddresses, IList allowedSignalingSourceAddressPrefixes, IList allowedMediaSourceAddressPrefixes) + { + OperatorAddresses = operatorAddresses; + EsrpAddresses = esrpAddresses; + AllowedSignalingSourceAddressPrefixes = allowedSignalingSourceAddressPrefixes; + AllowedMediaSourceAddressPrefixes = allowedMediaSourceAddressPrefixes; + } + + /// IP address to use to contact the operator network from this region. + public IList OperatorAddresses { get; } + /// IP address to use to contact the ESRP from this region. + public IList EsrpAddresses { get; } + /// The allowed source IP address or CIDR ranges for signaling. + public IList AllowedSignalingSourceAddressPrefixes { get; } + /// The allowed source IP address or CIDR ranges for media. + public IList AllowedMediaSourceAddressPrefixes { get; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ProvisioningState.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 0000000000000..2987dc1f2686b --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ProvisioningState.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.Voiceservices.Models +{ + /// Provisioning state of the resource. + 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 SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + + /// Succeeded. + public static ProvisioningState Succeeded { get; } = new ProvisioningState(SucceededValue); + /// Failed. + public static ProvisioningState Failed { get; } = new ProvisioningState(FailedValue); + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ServiceRegionProperties.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ServiceRegionProperties.Serialization.cs new file mode 100644 index 0000000000000..a23b1f38798f1 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ServiceRegionProperties.Serialization.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + public partial class ServiceRegionProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("primaryRegionProperties"u8); + writer.WriteObjectValue(PrimaryRegionProperties); + writer.WriteEndObject(); + } + + internal static ServiceRegionProperties DeserializeServiceRegionProperties(JsonElement element) + { + string name = default; + PrimaryRegionProperties primaryRegionProperties = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("primaryRegionProperties"u8)) + { + primaryRegionProperties = PrimaryRegionProperties.DeserializePrimaryRegionProperties(property.Value); + continue; + } + } + return new ServiceRegionProperties(name, primaryRegionProperties); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ServiceRegionProperties.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ServiceRegionProperties.cs new file mode 100644 index 0000000000000..a2d1640d54ef1 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/ServiceRegionProperties.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The service region configuration needed for Teams Callings. + public partial class ServiceRegionProperties + { + /// Initializes a new instance of ServiceRegionProperties. + /// The name of the region in which the resources needed for Teams Calling will be deployed. + /// The configuration used in this region as primary, and other regions as backup. + /// or is null. + public ServiceRegionProperties(string name, PrimaryRegionProperties primaryRegionProperties) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(primaryRegionProperties, nameof(primaryRegionProperties)); + + Name = name; + PrimaryRegionProperties = primaryRegionProperties; + } + + /// The name of the region in which the resources needed for Teams Calling will be deployed. + public string Name { get; set; } + /// The configuration used in this region as primary, and other regions as backup. + public PrimaryRegionProperties PrimaryRegionProperties { get; set; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/Status.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/Status.cs new file mode 100644 index 0000000000000..65ebe0ad6fa07 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/Status.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The status of the current CommunicationsGateway resource. + public readonly partial struct Status : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public Status(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ChangePendingValue = "ChangePending"; + private const string CompleteValue = "Complete"; + + /// The resource has been created or updated, but the CommunicationsGateway service has not yet been updated to reflect the changes. + public static Status ChangePending { get; } = new Status(ChangePendingValue); + /// The CommunicationsGateway service is up and running with the parameters specified in the resource. + public static Status Complete { get; } = new Status(CompleteValue); + /// Determines if two values are the same. + public static bool operator ==(Status left, Status right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Status left, Status right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator Status(string value) => new Status(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Status other && Equals(other); + /// + public bool Equals(Status other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TeamsCodec.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TeamsCodec.cs new file mode 100644 index 0000000000000..01be5b1566479 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TeamsCodec.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The voice codecs expected for communication with Teams. + public readonly partial struct TeamsCodec : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TeamsCodec(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PcmaValue = "PCMA"; + private const string PcmuValue = "PCMU"; + private const string G722Value = "G722"; + private const string G7222Value = "G722_2"; + private const string Silk8Value = "SILK_8"; + private const string Silk16Value = "SILK_16"; + + /// PCMA. + public static TeamsCodec Pcma { get; } = new TeamsCodec(PcmaValue); + /// PCMU. + public static TeamsCodec Pcmu { get; } = new TeamsCodec(PcmuValue); + /// G722. + public static TeamsCodec G722 { get; } = new TeamsCodec(G722Value); + /// G722_2. + public static TeamsCodec G7222 { get; } = new TeamsCodec(G7222Value); + /// SILK_8. + public static TeamsCodec Silk8 { get; } = new TeamsCodec(Silk8Value); + /// SILK_16. + public static TeamsCodec Silk16 { get; } = new TeamsCodec(Silk16Value); + /// Determines if two values are the same. + public static bool operator ==(TeamsCodec left, TeamsCodec right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TeamsCodec left, TeamsCodec right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TeamsCodec(string value) => new TeamsCodec(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TeamsCodec other && Equals(other); + /// + public bool Equals(TeamsCodec other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineData.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineData.Serialization.cs new file mode 100644 index 0000000000000..9e59b25fa4756 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineData.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + public partial class TestLineData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + 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(); + } + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(PhoneNumber)) + { + writer.WritePropertyName("phoneNumber"u8); + writer.WriteStringValue(PhoneNumber); + } + if (Optional.IsDefined(Purpose)) + { + writer.WritePropertyName("purpose"u8); + writer.WriteStringValue(Purpose.Value.ToString()); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static TestLineData DeserializeTestLineData(JsonElement element) + { + Optional> tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional provisioningState = default; + Optional phoneNumber = default; + Optional purpose = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + 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) + { + property.ThrowNonNullablePropertyIsNull(); + 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("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("phoneNumber"u8)) + { + phoneNumber = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("purpose"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + purpose = new TestLinePurpose(property0.Value.GetString()); + continue; + } + } + continue; + } + } + return new TestLineData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, Optional.ToNullable(provisioningState), phoneNumber.Value, Optional.ToNullable(purpose)); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineListResult.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineListResult.Serialization.cs new file mode 100644 index 0000000000000..edf7067f41a20 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineListResult.Serialization.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Voiceservices; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + internal partial class TestLineListResult + { + internal static TestLineListResult DeserializeTestLineListResult(JsonElement element) + { + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TestLineData.DeserializeTestLineData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + nextLink = null; + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new TestLineListResult(value, nextLink.Value); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineListResult.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineListResult.cs new file mode 100644 index 0000000000000..015f778c059d3 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLineListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Voiceservices; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The response of a TestLine list operation. + internal partial class TestLineListResult + { + /// Initializes a new instance of TestLineListResult. + /// The TestLine items on this page. + /// is null. + internal TestLineListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of TestLineListResult. + /// The TestLine items on this page. + /// The link to the next page of items. + internal TestLineListResult(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The TestLine items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePatch.Serialization.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePatch.Serialization.cs new file mode 100644 index 0000000000000..8a45ed35bb4e5 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePatch.Serialization.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + public partial class TestLinePatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + 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(); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePatch.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePatch.cs new file mode 100644 index 0000000000000..d96f419230e67 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePatch.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The type used for update operations of the TestLine. + public partial class TestLinePatch + { + /// Initializes a new instance of TestLinePatch. + public TestLinePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePurpose.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePurpose.cs new file mode 100644 index 0000000000000..fb0e33f09c150 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/Models/TestLinePurpose.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Voiceservices.Models +{ + /// The purpose of the TestLine resource. + public readonly partial struct TestLinePurpose : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TestLinePurpose(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ManualValue = "Manual"; + private const string AutomatedValue = "Automated"; + + /// Manual. + public static TestLinePurpose Manual { get; } = new TestLinePurpose(ManualValue); + /// Automated. + public static TestLinePurpose Automated { get; } = new TestLinePurpose(AutomatedValue); + /// Determines if two values are the same. + public static bool operator ==(TestLinePurpose left, TestLinePurpose right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TestLinePurpose left, TestLinePurpose right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TestLinePurpose(string value) => new TestLinePurpose(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TestLinePurpose other && Equals(other); + /// + public bool Equals(TestLinePurpose other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/ProviderConstants.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/ProviderConstants.cs new file mode 100644 index 0000000000000..42315963ebbba --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/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.Voiceservices +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/CommunicationsGatewaysRestOperations.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/CommunicationsGatewaysRestOperations.cs new file mode 100644 index 0000000000000..01dbc8fd2e61e --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/CommunicationsGatewaysRestOperations.cs @@ -0,0 +1,638 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + internal partial class CommunicationsGatewaysRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CommunicationsGatewaysRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public CommunicationsGatewaysRestOperations(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 ?? "2023-01-31"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + { + 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.VoiceServices/communicationsGateways", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunicationsGateway resources by subscription ID. + /// The ID of the target subscription. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CommunicationsGatewayListResult.DeserializeCommunicationsGatewayListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunicationsGateway resources by subscription ID. + /// The ID of the target subscription. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CommunicationsGatewayListResult.DeserializeCommunicationsGatewayListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) + { + 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.VoiceServices/communicationsGateways", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunicationsGateway resources by resource group. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// 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, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CommunicationsGatewayListResult.DeserializeCommunicationsGatewayListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunicationsGateway resources by resource group. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// 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, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CommunicationsGatewayListResult.DeserializeCommunicationsGatewayListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string communicationsGatewayName) + { + 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.VoiceServices/communicationsGateways/", false); + uri.AppendPath(communicationsGatewayName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// 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 communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communicationsGatewayName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CommunicationsGatewayData.DeserializeCommunicationsGatewayData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CommunicationsGatewayData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// 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 communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communicationsGatewayName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CommunicationsGatewayData.DeserializeCommunicationsGatewayData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CommunicationsGatewayData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string communicationsGatewayName, CommunicationsGatewayData 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.VoiceServices/communicationsGateways/", false); + uri.AppendPath(communicationsGatewayName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Resource create parameters. + /// 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 communicationsGatewayName, CommunicationsGatewayData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communicationsGatewayName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Resource create parameters. + /// 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 communicationsGatewayName, CommunicationsGatewayData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communicationsGatewayName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string communicationsGatewayName) + { + 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.VoiceServices/communicationsGateways/", false); + uri.AppendPath(communicationsGatewayName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// 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 communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communicationsGatewayName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// 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 communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communicationsGatewayName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string communicationsGatewayName, CommunicationsGatewayPatch 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.VoiceServices/communicationsGateways/", false); + uri.AppendPath(communicationsGatewayName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// The resource properties to be updated. + /// 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 communicationsGatewayName, CommunicationsGatewayPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communicationsGatewayName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CommunicationsGatewayData.DeserializeCommunicationsGatewayData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// The resource properties to be updated. + /// 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 communicationsGatewayName, CommunicationsGatewayPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communicationsGatewayName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CommunicationsGatewayData.DeserializeCommunicationsGatewayData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunicationsGateway resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// 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, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CommunicationsGatewayListResult.DeserializeCommunicationsGatewayListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunicationsGateway resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// 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, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CommunicationsGatewayListResult.DeserializeCommunicationsGatewayListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List CommunicationsGateway resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// 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, 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); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CommunicationsGatewayListResult.DeserializeCommunicationsGatewayListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List CommunicationsGateway resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// 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, 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); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CommunicationsGatewayListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CommunicationsGatewayListResult.DeserializeCommunicationsGatewayListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/NameAvailabilityRestOperations.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/NameAvailabilityRestOperations.cs new file mode 100644 index 0000000000000..32536997ebb8b --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/NameAvailabilityRestOperations.cs @@ -0,0 +1,119 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + internal partial class NameAvailabilityRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NameAvailabilityRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NameAvailabilityRestOperations(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 ?? "2023-01-31"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateCheckLocalRequest(string subscriptionId, AzureLocation location, CheckNameAvailabilityContent content) + { + 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("/providers/Microsoft.VoiceServices/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/checkNameAvailability", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Check whether the resource name is available in the given region. + /// The ID of the target subscription. + /// The location in which uniqueness will be verified. + /// The check availability request body. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> CheckLocalAsync(string subscriptionId, AzureLocation location, CheckNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckLocalRequest(subscriptionId, location, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CheckNameAvailabilityResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CheckNameAvailabilityResponse.DeserializeCheckNameAvailabilityResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Check whether the resource name is available in the given region. + /// The ID of the target subscription. + /// The location in which uniqueness will be verified. + /// The check availability request body. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response CheckLocal(string subscriptionId, AzureLocation location, CheckNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckLocalRequest(subscriptionId, location, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CheckNameAvailabilityResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CheckNameAvailabilityResponse.DeserializeCheckNameAvailabilityResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/TestLinesRestOperations.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/TestLinesRestOperations.cs new file mode 100644 index 0000000000000..faf563f11d14b --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/RestOperations/TestLinesRestOperations.cs @@ -0,0 +1,537 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + internal partial class TestLinesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of TestLinesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public TestLinesRestOperations(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 ?? "2023-01-31"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListByCommunicationsGatewayRequest(string subscriptionId, string resourceGroupName, string communicationsGatewayName) + { + 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.VoiceServices/communicationsGateways/", false); + uri.AppendPath(communicationsGatewayName, true); + uri.AppendPath("/testLines", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List TestLine resources by CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCommunicationsGatewayAsync(string subscriptionId, string resourceGroupName, string communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var message = CreateListByCommunicationsGatewayRequest(subscriptionId, resourceGroupName, communicationsGatewayName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TestLineListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = TestLineListResult.DeserializeTestLineListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List TestLine resources by CommunicationsGateway. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCommunicationsGateway(string subscriptionId, string resourceGroupName, string communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var message = CreateListByCommunicationsGatewayRequest(subscriptionId, resourceGroupName, communicationsGatewayName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TestLineListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = TestLineListResult.DeserializeTestLineListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string communicationsGatewayName, string testLineName) + { + 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.VoiceServices/communicationsGateways/", false); + uri.AppendPath(communicationsGatewayName, true); + uri.AppendPath("/testLines/", false); + uri.AppendPath(testLineName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a TestLine. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Unique identifier for this test line. + /// 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 communicationsGatewayName, string testLineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communicationsGatewayName, testLineName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TestLineData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = TestLineData.DeserializeTestLineData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TestLineData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a TestLine. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Unique identifier for this test line. + /// 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 communicationsGatewayName, string testLineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, communicationsGatewayName, testLineName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TestLineData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = TestLineData.DeserializeTestLineData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TestLineData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string communicationsGatewayName, string testLineName, TestLineData 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.VoiceServices/communicationsGateways/", false); + uri.AppendPath(communicationsGatewayName, true); + uri.AppendPath("/testLines/", false); + uri.AppendPath(testLineName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a TestLine. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Unique identifier for this test line. + /// Resource create parameters. + /// 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 communicationsGatewayName, string testLineName, TestLineData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communicationsGatewayName, testLineName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a TestLine. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Unique identifier for this test line. + /// Resource create parameters. + /// 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 communicationsGatewayName, string testLineName, TestLineData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, communicationsGatewayName, testLineName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string communicationsGatewayName, string testLineName) + { + 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.VoiceServices/communicationsGateways/", false); + uri.AppendPath(communicationsGatewayName, true); + uri.AppendPath("/testLines/", false); + uri.AppendPath(testLineName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a TestLine. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Unique identifier for this test line. + /// 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 communicationsGatewayName, string testLineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communicationsGatewayName, testLineName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a TestLine. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Unique identifier for this test line. + /// 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 communicationsGatewayName, string testLineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, communicationsGatewayName, testLineName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string communicationsGatewayName, string testLineName, TestLinePatch 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.VoiceServices/communicationsGateways/", false); + uri.AppendPath(communicationsGatewayName, true); + uri.AppendPath("/testLines/", false); + uri.AppendPath(testLineName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a TestLine. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Unique identifier for this test line. + /// The resource properties to be updated. + /// 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 communicationsGatewayName, string testLineName, TestLinePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communicationsGatewayName, testLineName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TestLineData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = TestLineData.DeserializeTestLineData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a TestLine. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// Unique identifier for this test line. + /// The resource properties to be updated. + /// 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 communicationsGatewayName, string testLineName, TestLinePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, communicationsGatewayName, testLineName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TestLineData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = TestLineData.DeserializeTestLineData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByCommunicationsGatewayNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string communicationsGatewayName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List TestLine resources by CommunicationsGateway. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCommunicationsGatewayNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var message = CreateListByCommunicationsGatewayNextPageRequest(nextLink, subscriptionId, resourceGroupName, communicationsGatewayName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + TestLineListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = TestLineListResult.DeserializeTestLineListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List TestLine resources by CommunicationsGateway. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Unique identifier for this deployment. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCommunicationsGatewayNextPage(string nextLink, string subscriptionId, string resourceGroupName, string communicationsGatewayName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(communicationsGatewayName, nameof(communicationsGatewayName)); + + using var message = CreateListByCommunicationsGatewayNextPageRequest(nextLink, subscriptionId, resourceGroupName, communicationsGatewayName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TestLineListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = TestLineListResult.DeserializeTestLineListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineCollection.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineCollection.cs new file mode 100644 index 0000000000000..dfdbf3017634e --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineCollection.cs @@ -0,0 +1,340 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Voiceservices +{ + /// + /// 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 GetTestLines method from an instance of . + /// + public partial class TestLineCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _testLineClientDiagnostics; + private readonly TestLinesRestOperations _testLineRestClient; + + /// Initializes a new instance of the class for mocking. + protected TestLineCollection() + { + } + + /// 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 TestLineCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _testLineClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Voiceservices", TestLineResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(TestLineResource.ResourceType, out string testLineApiVersion); + _testLineRestClient = new TestLinesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, testLineApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CommunicationsGatewayResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CommunicationsGatewayResource.ResourceType), nameof(id)); + } + + /// + /// Create a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_CreateOrUpdate + /// + /// + /// + /// 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. + /// Unique identifier for this test line. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string testLineName, TestLineData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _testLineClientDiagnostics.CreateScope("TestLineCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _testLineRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, testLineName, data, cancellationToken).ConfigureAwait(false); + var operation = new VoiceservicesArmOperation(new TestLineOperationSource(Client), _testLineClientDiagnostics, Pipeline, _testLineRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, testLineName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_CreateOrUpdate + /// + /// + /// + /// 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. + /// Unique identifier for this test line. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string testLineName, TestLineData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _testLineClientDiagnostics.CreateScope("TestLineCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _testLineRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, testLineName, data, cancellationToken); + var operation = new VoiceservicesArmOperation(new TestLineOperationSource(Client), _testLineClientDiagnostics, Pipeline, _testLineRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, testLineName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// Unique identifier for this test line. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string testLineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + + using var scope = _testLineClientDiagnostics.CreateScope("TestLineCollection.Get"); + scope.Start(); + try + { + var response = await _testLineRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, testLineName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TestLineResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// Unique identifier for this test line. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string testLineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + + using var scope = _testLineClientDiagnostics.CreateScope("TestLineCollection.Get"); + scope.Start(); + try + { + var response = _testLineRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, testLineName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TestLineResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List TestLine resources by CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines + /// + /// + /// Operation Id + /// TestLines_ListByCommunicationsGateway + /// + /// + /// + /// 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) => _testLineRestClient.CreateListByCommunicationsGatewayRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _testLineRestClient.CreateListByCommunicationsGatewayNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TestLineResource(Client, TestLineData.DeserializeTestLineData(e)), _testLineClientDiagnostics, Pipeline, "TestLineCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List TestLine resources by CommunicationsGateway + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines + /// + /// + /// Operation Id + /// TestLines_ListByCommunicationsGateway + /// + /// + /// + /// 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) => _testLineRestClient.CreateListByCommunicationsGatewayRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _testLineRestClient.CreateListByCommunicationsGatewayNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TestLineResource(Client, TestLineData.DeserializeTestLineData(e)), _testLineClientDiagnostics, Pipeline, "TestLineCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// Unique identifier for this test line. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string testLineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + + using var scope = _testLineClientDiagnostics.CreateScope("TestLineCollection.Exists"); + scope.Start(); + try + { + var response = await _testLineRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, testLineName, 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.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// Unique identifier for this test line. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string testLineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testLineName, nameof(testLineName)); + + using var scope = _testLineClientDiagnostics.CreateScope("TestLineCollection.Exists"); + scope.Start(); + try + { + var response = _testLineRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, testLineName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineData.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineData.cs new file mode 100644 index 0000000000000..5baf014e94744 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineData.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + /// A class representing the TestLine data model. + public partial class TestLineData : TrackedResourceData + { + /// Initializes a new instance of TestLineData. + /// The location. + public TestLineData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of TestLineData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Resource provisioning state. + /// The phone number. + /// Purpose of this test line, e.g. automated or manual testing. + internal TestLineData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ProvisioningState? provisioningState, string phoneNumber, TestLinePurpose? purpose) : base(id, name, resourceType, systemData, tags, location) + { + ProvisioningState = provisioningState; + PhoneNumber = phoneNumber; + Purpose = purpose; + } + + /// Resource provisioning state. + public ProvisioningState? ProvisioningState { get; } + /// The phone number. + public string PhoneNumber { get; set; } + /// Purpose of this test line, e.g. automated or manual testing. + public TestLinePurpose? Purpose { get; set; } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineResource.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineResource.cs new file mode 100644 index 0000000000000..8ec5eb8da96b3 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Generated/TestLineResource.cs @@ -0,0 +1,601 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Voiceservices.Models; + +namespace Azure.ResourceManager.Voiceservices +{ + /// + /// A Class representing a TestLine 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 GetTestLineResource method. + /// Otherwise you can get one from its parent resource using the GetTestLine method. + /// + public partial class TestLineResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string communicationsGatewayName, string testLineName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _testLineClientDiagnostics; + private readonly TestLinesRestOperations _testLineRestClient; + private readonly TestLineData _data; + + /// Initializes a new instance of the class for mocking. + protected TestLineResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal TestLineResource(ArmClient client, TestLineData 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 TestLineResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _testLineClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Voiceservices", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string testLineApiVersion); + _testLineRestClient = new TestLinesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, testLineApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.VoiceServices/communicationsGateways/testLines"; + + /// 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 TestLineData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _testLineClientDiagnostics.CreateScope("TestLineResource.Get"); + scope.Start(); + try + { + var response = await _testLineRestClient.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 TestLineResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _testLineClientDiagnostics.CreateScope("TestLineResource.Get"); + scope.Start(); + try + { + var response = _testLineRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TestLineResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Delete + /// + /// + /// + /// 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 = _testLineClientDiagnostics.CreateScope("TestLineResource.Delete"); + scope.Start(); + try + { + var response = await _testLineRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new VoiceservicesArmOperation(_testLineClientDiagnostics, Pipeline, _testLineRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Delete + /// + /// + /// + /// 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 = _testLineClientDiagnostics.CreateScope("TestLineResource.Delete"); + scope.Start(); + try + { + var response = _testLineRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new VoiceservicesArmOperation(_testLineClientDiagnostics, Pipeline, _testLineRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Update + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(TestLinePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _testLineClientDiagnostics.CreateScope("TestLineResource.Update"); + scope.Start(); + try + { + var response = await _testLineRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TestLineResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a TestLine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Update + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(TestLinePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _testLineClientDiagnostics.CreateScope("TestLineResource.Update"); + scope.Start(); + try + { + var response = _testLineRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); + return Response.FromValue(new TestLineResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// 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 = _testLineClientDiagnostics.CreateScope("TestLineResource.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 _testLineRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TestLineResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new TestLinePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// 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 = _testLineClientDiagnostics.CreateScope("TestLineResource.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 = _testLineRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new TestLineResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new TestLinePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + 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.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// 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 = _testLineClientDiagnostics.CreateScope("TestLineResource.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 _testLineRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TestLineResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new TestLinePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + 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.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// 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 = _testLineClientDiagnostics.CreateScope("TestLineResource.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 = _testLineRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new TestLineResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new TestLinePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// 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 = _testLineClientDiagnostics.CreateScope("TestLineResource.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 _testLineRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new TestLineResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new TestLinePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName} + /// + /// + /// Operation Id + /// TestLines_Get + /// + /// + /// + /// 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 = _testLineClientDiagnostics.CreateScope("TestLineResource.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 = _testLineRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new TestLineResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new TestLinePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Properties/AssemblyInfo.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..bc3f69ec71e79 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: Azure.Core.AzureResourceProviderNamespace("voiceservices")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.Voiceservices.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/autorest.md b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/autorest.md new file mode 100644 index 0000000000000..0bbf3ad13cd9f --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/src/autorest.md @@ -0,0 +1,49 @@ +# Generated code configuration + +Run `dotnet build /t:GenerateCode` to generate code. + +``` yaml +azure-arm: true +csharp: true +library-name: voiceservices +namespace: Azure.ResourceManager.voiceservices +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/voiceservices/resource-manager/readme.md +output-folder: $(this-folder)/Generated +clear-output-folder: true +skip-csproj: true +modelerfour: + flatten-payloads: false + + + +format-by-name-rules: + 'tenantId': 'uuid' + 'ETag': 'etag' + 'location': 'azure-location' + '*Uri': 'Uri' + '*Uris': 'Uri' + +rename-rules: + CPU: Cpu + CPUs: Cpus + Os: OS + Ip: IP + Ips: IPs|ips + ID: Id + IDs: Ids + VM: Vm + VMs: Vms + Vmos: VmOS + VMScaleSet: VmScaleSet + DNS: Dns + VPN: Vpn + NAT: Nat + WAN: Wan + Ipv4: IPv4|ipv4 + Ipv6: IPv6|ipv6 + Ipsec: IPsec|ipsec + SSO: Sso + URI: Uri + Etag: ETag|etag + +``` diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/Azure.ResourceManager.Voiceservices.Tests.csproj b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/Azure.ResourceManager.Voiceservices.Tests.csproj new file mode 100644 index 0000000000000..39871da058b23 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/Azure.ResourceManager.Voiceservices.Tests.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/autorest.tests.md b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/autorest.tests.md new file mode 100644 index 0000000000000..d306b9865a169 --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/autorest.tests.md @@ -0,0 +1,13 @@ +# Generated code configuration + +Run `dotnet build /t:GenerateTests` to generate code. + +# Azure.ResourceManager.voiceservices.Tests + +> see https://aka.ms/autorest +``` yaml +require: ../src/autorest.md +include-x-ms-examples-original-file: true +testgen: + sample: true +``` \ No newline at end of file diff --git a/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/voiceservicesManagementTestBase.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/voiceservicesManagementTestBase.cs new file mode 100644 index 0000000000000..4f78eab9576ef --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/voiceservicesManagementTestBase.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Voiceservices.Tests +{ + public class voiceservicesManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + + protected voiceservicesManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected voiceservicesManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public void CreateCommonClient() + { + Client = GetArmClient(); + } + + 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/voiceservices/Azure.ResourceManager.Voiceservices/tests/voiceservicesManagementTestEnvironment.cs b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/voiceservicesManagementTestEnvironment.cs new file mode 100644 index 0000000000000..12cc90cf1b69c --- /dev/null +++ b/sdk/voiceservices/Azure.ResourceManager.Voiceservices/tests/voiceservicesManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Voiceservices.Tests +{ + public class voiceservicesManagementTestEnvironment : TestEnvironment + { + } +} \ No newline at end of file diff --git a/sdk/voiceservices/ci.mgmt.yml b/sdk/voiceservices/ci.mgmt.yml new file mode 100644 index 0000000000000..34f458c15eea4 --- /dev/null +++ b/sdk/voiceservices/ci.mgmt.yml @@ -0,0 +1,24 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/voiceservices/ci.mgmt.yml + - sdk/voiceservices/Azure.ResourceManager.Voiceservices/ + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: voiceservices + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.Voiceservices + safeName: AzureResourceManagerVoiceservices