diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/Azure.Communication.ProgrammableConnectivity.sln b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/Azure.Communication.ProgrammableConnectivity.sln new file mode 100644 index 0000000000000..fc1ee5156b11c --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/Azure.Communication.ProgrammableConnectivity.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Communication.ProgrammableConnectivity", "src\Azure.Communication.ProgrammableConnectivity.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Communication.ProgrammableConnectivity.Tests", "tests\Azure.Communication.ProgrammableConnectivity.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/CHANGELOG.md b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/CHANGELOG.md new file mode 100644 index 0000000000000..13dd08af78abe --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/Directory.Build.props b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/Directory.Build.props new file mode 100644 index 0000000000000..63bd836ad44b7 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/README.md b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/README.md new file mode 100644 index 0000000000000..4800bd72defb9 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/README.md @@ -0,0 +1,86 @@ +# Azure.Communication.ProgrammableConnectivity client library for .NET + +Azure.Communication.ProgrammableConnectivity is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.Communication.ProgrammableConnectivity --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/README.png) diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Azure.Communication.ProgrammableConnectivity.csproj b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Azure.Communication.ProgrammableConnectivity.csproj new file mode 100644 index 0000000000000..c3ece2ddf8eab --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Azure.Communication.ProgrammableConnectivity.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.Communication.ProgrammableConnectivity client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.Communication.ProgrammableConnectivity for Azure Data Plane + 1.0.0-beta.1 + Azure.Communication.ProgrammableConnectivity + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/CommunicationProgrammableConnectivityClientBuilderExtensions.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/CommunicationProgrammableConnectivityClientBuilderExtensions.cs new file mode 100644 index 0000000000000..e5e56416b03cc --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/CommunicationProgrammableConnectivityClientBuilderExtensions.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Communication.ProgrammableConnectivity; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class CommunicationProgrammableConnectivityClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// An Azure Programmable Connectivity Endpoint providing access to Network APIs, for example https://{region}.apcgatewayapi.azure.com. + public static IAzureClientBuilder AddProgrammableConnectivityClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new ProgrammableConnectivityClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddProgrammableConnectivityClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/CommunicationProgrammableConnectivityModelFactory.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/CommunicationProgrammableConnectivityModelFactory.cs new file mode 100644 index 0000000000000..39a641da9e128 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/CommunicationProgrammableConnectivityModelFactory.cs @@ -0,0 +1,113 @@ +// 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; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Model factory for models. + public static partial class CommunicationProgrammableConnectivityModelFactory + { + /// Initializes a new instance of . + /// True if the location is in the specified area, False otherwise. + /// A new instance for mocking. + public static DeviceLocationVerificationResult DeviceLocationVerificationResult(bool verificationResult = default) + { + return new DeviceLocationVerificationResult(verificationResult, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier for the network. This can be used as the networkIdentifier for the service APIs. + /// A new instance for mocking. + public static NetworkRetrievalResult NetworkRetrievalResult(string networkCode = null) + { + return new NetworkRetrievalResult(networkCode, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Identifier for the network to query for this device. + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// Hashed phone number. SHA-256 (in hexadecimal representation) of the mobile phone number in **E.164 format (starting with country code)**. Optionally prefixed with '+'. + /// The code provided by APC is exchange for the operator code. + /// A new instance for mocking. + public static NumberVerificationContent NumberVerificationContent(NetworkIdentifier networkIdentifier = null, string phoneNumber = null, string hashedPhoneNumber = null, string apcCode = null) + { + return new NumberVerificationContent(networkIdentifier, phoneNumber, hashedPhoneNumber, apcCode, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Optional content. + /// A new instance for mocking. + public static EmptyResponse EmptyResponse(string content = null) + { + return new EmptyResponse(content, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// True if number if the phone number matches the device, False otherwise. + /// A new instance for mocking. + public static NumberVerificationResult NumberVerificationResult(bool verificationResult = default) + { + return new NumberVerificationResult(verificationResult, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Identifier for the network to query for this device. + /// The code provided by APC is exchange for the operator code. + /// A new instance for mocking. + public static NumberRetrievalContent NumberRetrievalContent(NetworkIdentifier networkIdentifier = null, string apcCode = null) + { + return new NumberRetrievalContent(networkIdentifier, apcCode, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// A new instance for mocking. + public static NumberRetrievalResult NumberRetrievalResult(string phoneNumber = null) + { + return new NumberRetrievalResult(phoneNumber, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// Network to query for this device. + /// A new instance for mocking. + public static SimSwapRetrievalContent SimSwapRetrievalContent(string phoneNumber = null, NetworkIdentifier networkIdentifier = null) + { + return new SimSwapRetrievalContent(phoneNumber, networkIdentifier, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Datetime of most recent swap for SIM. + /// A new instance for mocking. + public static SimSwapRetrievalResult SimSwapRetrievalResult(DateTimeOffset date = default) + { + return new SimSwapRetrievalResult(date, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// Maximum lookback for SimSwap verification. + /// Identifier for the network to query for this device. + /// A new instance for mocking. + public static SimSwapVerificationContent SimSwapVerificationContent(string phoneNumber = null, int? maxAgeHours = null, NetworkIdentifier networkIdentifier = null) + { + return new SimSwapVerificationContent(phoneNumber, maxAgeHours, networkIdentifier, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// True if the SIM has swapped in the specified period, False otherwise. + /// A new instance for mocking. + public static SimSwapVerificationResult SimSwapVerificationResult(bool verificationResult = default) + { + return new SimSwapVerificationResult(verificationResult, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocation.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocation.cs new file mode 100644 index 0000000000000..3ecf3cc2d1062 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocation.cs @@ -0,0 +1,200 @@ +// 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; + +namespace Azure.Communication.ProgrammableConnectivity +{ + // Data plane generated sub-client. + /// The DeviceLocation sub-client. + public partial class DeviceLocation + { + private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com//.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of DeviceLocation for mocking. + protected DeviceLocation() + { + } + + /// Initializes a new instance of DeviceLocation. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// An Azure Programmable Connectivity Endpoint providing access to Network APIs, for example https://{region}.apcgatewayapi.azure.com. + /// The API version to use for this operation. + internal DeviceLocation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Verifies whether a device is within a specified location area, defined as an accuracy (radius) around a point, specified by longitude and latitude. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to verify Location. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> VerifyAsync(string apcGatewayId, DeviceLocationVerificationContent deviceLocationVerificationContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(deviceLocationVerificationContent, nameof(deviceLocationVerificationContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = deviceLocationVerificationContent.ToRequestContent(); + Response response = await VerifyAsync(apcGatewayId, content, context).ConfigureAwait(false); + return Response.FromValue(DeviceLocationVerificationResult.FromResponse(response), response); + } + + /// Verifies whether a device is within a specified location area, defined as an accuracy (radius) around a point, specified by longitude and latitude. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to verify Location. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response Verify(string apcGatewayId, DeviceLocationVerificationContent deviceLocationVerificationContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(deviceLocationVerificationContent, nameof(deviceLocationVerificationContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = deviceLocationVerificationContent.ToRequestContent(); + Response response = Verify(apcGatewayId, content, context); + return Response.FromValue(DeviceLocationVerificationResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Verifies whether a device is within a specified location area, defined as an accuracy (radius) around a point, specified by longitude and latitude. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task VerifyAsync(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("DeviceLocation.Verify"); + scope.Start(); + try + { + using HttpMessage message = CreateVerifyRequest(apcGatewayId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Verifies whether a device is within a specified location area, defined as an accuracy (radius) around a point, specified by longitude and latitude. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Verify(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("DeviceLocation.Verify"); + scope.Start(); + try + { + using HttpMessage message = CreateVerifyRequest(apcGatewayId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateVerifyRequest(string apcGatewayId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/device-location/location:verify", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("apc-gateway-id", apcGatewayId); + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationContent.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationContent.Serialization.cs new file mode 100644 index 0000000000000..65ea446c5a899 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationContent.Serialization.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class DeviceLocationVerificationContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeviceLocationVerificationContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("networkIdentifier"u8); + writer.WriteObjectValue(NetworkIdentifier); + writer.WritePropertyName("latitude"u8); + writer.WriteNumberValue(Latitude); + writer.WritePropertyName("longitude"u8); + writer.WriteNumberValue(Longitude); + writer.WritePropertyName("accuracy"u8); + writer.WriteNumberValue(Accuracy); + writer.WritePropertyName("locationDevice"u8); + writer.WriteObjectValue(LocationDevice); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DeviceLocationVerificationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeviceLocationVerificationContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeviceLocationVerificationContent(document.RootElement, options); + } + + internal static DeviceLocationVerificationContent DeserializeDeviceLocationVerificationContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NetworkIdentifier networkIdentifier = default; + double latitude = default; + double longitude = default; + int accuracy = default; + LocationDevice locationDevice = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("networkIdentifier"u8)) + { + networkIdentifier = NetworkIdentifier.DeserializeNetworkIdentifier(property.Value); + continue; + } + if (property.NameEquals("latitude"u8)) + { + latitude = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("longitude"u8)) + { + longitude = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("accuracy"u8)) + { + accuracy = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("locationDevice"u8)) + { + locationDevice = LocationDevice.DeserializeLocationDevice(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DeviceLocationVerificationContent(networkIdentifier, latitude, longitude, accuracy, locationDevice, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DeviceLocationVerificationContent)} does not support '{options.Format}' format."); + } + } + + DeviceLocationVerificationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDeviceLocationVerificationContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeviceLocationVerificationContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DeviceLocationVerificationContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDeviceLocationVerificationContent(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationContent.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationContent.cs new file mode 100644 index 0000000000000..1351bfc3a991e --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationContent.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Request to verify Location. + public partial class DeviceLocationVerificationContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Network to query for this device, or device information to enable network routing. + /// Latitude of location to be verified. + /// Longitude of location to be verified. + /// Accuracy expected for location verification in kilometers. + /// The device to find the location for. + /// or is null. + public DeviceLocationVerificationContent(NetworkIdentifier networkIdentifier, double latitude, double longitude, int accuracy, LocationDevice locationDevice) + { + Argument.AssertNotNull(networkIdentifier, nameof(networkIdentifier)); + Argument.AssertNotNull(locationDevice, nameof(locationDevice)); + + NetworkIdentifier = networkIdentifier; + Latitude = latitude; + Longitude = longitude; + Accuracy = accuracy; + LocationDevice = locationDevice; + } + + /// Initializes a new instance of . + /// Network to query for this device, or device information to enable network routing. + /// Latitude of location to be verified. + /// Longitude of location to be verified. + /// Accuracy expected for location verification in kilometers. + /// The device to find the location for. + /// Keeps track of any properties unknown to the library. + internal DeviceLocationVerificationContent(NetworkIdentifier networkIdentifier, double latitude, double longitude, int accuracy, LocationDevice locationDevice, IDictionary serializedAdditionalRawData) + { + NetworkIdentifier = networkIdentifier; + Latitude = latitude; + Longitude = longitude; + Accuracy = accuracy; + LocationDevice = locationDevice; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DeviceLocationVerificationContent() + { + } + + /// Network to query for this device, or device information to enable network routing. + public NetworkIdentifier NetworkIdentifier { get; } + /// Latitude of location to be verified. + public double Latitude { get; } + /// Longitude of location to be verified. + public double Longitude { get; } + /// Accuracy expected for location verification in kilometers. + public int Accuracy { get; } + /// The device to find the location for. + public LocationDevice LocationDevice { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationResult.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationResult.Serialization.cs new file mode 100644 index 0000000000000..f8ff5235f76ba --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationResult.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class DeviceLocationVerificationResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeviceLocationVerificationResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("verificationResult"u8); + writer.WriteBooleanValue(VerificationResult); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DeviceLocationVerificationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeviceLocationVerificationResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeviceLocationVerificationResult(document.RootElement, options); + } + + internal static DeviceLocationVerificationResult DeserializeDeviceLocationVerificationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool verificationResult = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("verificationResult"u8)) + { + verificationResult = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new DeviceLocationVerificationResult(verificationResult, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DeviceLocationVerificationResult)} does not support '{options.Format}' format."); + } + } + + DeviceLocationVerificationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDeviceLocationVerificationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeviceLocationVerificationResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DeviceLocationVerificationResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDeviceLocationVerificationResult(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationResult.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationResult.cs new file mode 100644 index 0000000000000..dff7039b7fff7 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceLocationVerificationResult.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Response verifying location. + public partial class DeviceLocationVerificationResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// True if the location is in the specified area, False otherwise. + internal DeviceLocationVerificationResult(bool verificationResult) + { + VerificationResult = verificationResult; + } + + /// Initializes a new instance of . + /// True if the location is in the specified area, False otherwise. + /// Keeps track of any properties unknown to the library. + internal DeviceLocationVerificationResult(bool verificationResult, IDictionary serializedAdditionalRawData) + { + VerificationResult = verificationResult; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DeviceLocationVerificationResult() + { + } + + /// True if the location is in the specified area, False otherwise. + public bool VerificationResult { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceNetwork.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceNetwork.cs new file mode 100644 index 0000000000000..6c6d88634e8ea --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/DeviceNetwork.cs @@ -0,0 +1,200 @@ +// 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; + +namespace Azure.Communication.ProgrammableConnectivity +{ + // Data plane generated sub-client. + /// The DeviceNetwork sub-client. + public partial class DeviceNetwork + { + private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com//.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of DeviceNetwork for mocking. + protected DeviceNetwork() + { + } + + /// Initializes a new instance of DeviceNetwork. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// An Azure Programmable Connectivity Endpoint providing access to Network APIs, for example https://{region}.apcgatewayapi.azure.com. + /// The API version to use for this operation. + internal DeviceNetwork(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Retrieves the network a given device is on. Returns network in a networkCode format that can be used for other APIs. + /// The identifier of the APC Gateway resource which should handle this request. + /// Identifier for the network to be queried. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> RetrieveAsync(string apcGatewayId, NetworkIdentifier networkIdentifier, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(networkIdentifier, nameof(networkIdentifier)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = networkIdentifier.ToRequestContent(); + Response response = await RetrieveAsync(apcGatewayId, content, context).ConfigureAwait(false); + return Response.FromValue(NetworkRetrievalResult.FromResponse(response), response); + } + + /// Retrieves the network a given device is on. Returns network in a networkCode format that can be used for other APIs. + /// The identifier of the APC Gateway resource which should handle this request. + /// Identifier for the network to be queried. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response Retrieve(string apcGatewayId, NetworkIdentifier networkIdentifier, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(networkIdentifier, nameof(networkIdentifier)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = networkIdentifier.ToRequestContent(); + Response response = Retrieve(apcGatewayId, content, context); + return Response.FromValue(NetworkRetrievalResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves the network a given device is on. Returns network in a networkCode format that can be used for other APIs. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task RetrieveAsync(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("DeviceNetwork.Retrieve"); + scope.Start(); + try + { + using HttpMessage message = CreateRetrieveRequest(apcGatewayId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves the network a given device is on. Returns network in a networkCode format that can be used for other APIs. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Retrieve(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("DeviceNetwork.Retrieve"); + scope.Start(); + try + { + using HttpMessage message = CreateRetrieveRequest(apcGatewayId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateRetrieveRequest(string apcGatewayId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/device-network/network:retrieve", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("apc-gateway-id", apcGatewayId); + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/DeviceLocation.xml b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/DeviceLocation.xml new file mode 100644 index 0000000000000..51b5bf01ee35b --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/DeviceLocation.xml @@ -0,0 +1,185 @@ + + + + + +This sample shows how to call VerifyAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + +DeviceLocationVerificationContent deviceLocationVerificationContent = new DeviceLocationVerificationContent(new NetworkIdentifier("", ""), 123.45, 123.45, 1234, new LocationDevice()); +Response response = await client.VerifyAsync("", deviceLocationVerificationContent); +]]> +This sample shows how to call VerifyAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + +DeviceLocationVerificationContent deviceLocationVerificationContent = new DeviceLocationVerificationContent(new NetworkIdentifier("", ""), 123.45, 123.45, 1234, new LocationDevice +{ + NetworkAccessIdentifier = "", + PhoneNumber = "", + Ipv4Address = new Ipv4Address("", 1234), + Ipv6Address = new Ipv6Address("", 1234), +}); +Response response = await client.VerifyAsync("", deviceLocationVerificationContent); +]]> + + + +This sample shows how to call Verify. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + +DeviceLocationVerificationContent deviceLocationVerificationContent = new DeviceLocationVerificationContent(new NetworkIdentifier("", ""), 123.45, 123.45, 1234, new LocationDevice()); +Response response = client.Verify("", deviceLocationVerificationContent); +]]> +This sample shows how to call Verify with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + +DeviceLocationVerificationContent deviceLocationVerificationContent = new DeviceLocationVerificationContent(new NetworkIdentifier("", ""), 123.45, 123.45, 1234, new LocationDevice +{ + NetworkAccessIdentifier = "", + PhoneNumber = "", + Ipv4Address = new Ipv4Address("", 1234), + Ipv6Address = new Ipv6Address("", 1234), +}); +Response response = client.Verify("", deviceLocationVerificationContent); +]]> + + + +This sample shows how to call VerifyAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + latitude = 123.45, + longitude = 123.45, + accuracy = 1234, + locationDevice = new object(), +}); +Response response = await client.VerifyAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> +This sample shows how to call VerifyAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + latitude = 123.45, + longitude = 123.45, + accuracy = 1234, + locationDevice = new + { + networkAccessIdentifier = "", + phoneNumber = "", + ipv4Address = new + { + ipv4 = "", + port = 1234, + }, + ipv6Address = new + { + ipv6 = "", + port = 1234, + }, + }, +}); +Response response = await client.VerifyAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> + + + +This sample shows how to call Verify and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + latitude = 123.45, + longitude = 123.45, + accuracy = 1234, + locationDevice = new object(), +}); +Response response = client.Verify("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> +This sample shows how to call Verify with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + latitude = 123.45, + longitude = 123.45, + accuracy = 1234, + locationDevice = new + { + networkAccessIdentifier = "", + phoneNumber = "", + ipv4Address = new + { + ipv4 = "", + port = 1234, + }, + ipv6Address = new + { + ipv6 = "", + port = 1234, + }, + }, +}); +Response response = client.Verify("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/DeviceNetwork.xml b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/DeviceNetwork.xml new file mode 100644 index 0000000000000..86e2a3a5d0804 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/DeviceNetwork.xml @@ -0,0 +1,117 @@ + + + + + +This sample shows how to call RetrieveAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + +NetworkIdentifier networkIdentifier = new NetworkIdentifier("", ""); +Response response = await client.RetrieveAsync("", networkIdentifier); +]]> +This sample shows how to call RetrieveAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + +NetworkIdentifier networkIdentifier = new NetworkIdentifier("", ""); +Response response = await client.RetrieveAsync("", networkIdentifier); +]]> + + + +This sample shows how to call Retrieve. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + +NetworkIdentifier networkIdentifier = new NetworkIdentifier("", ""); +Response response = client.Retrieve("", networkIdentifier); +]]> +This sample shows how to call Retrieve with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + +NetworkIdentifier networkIdentifier = new NetworkIdentifier("", ""); +Response response = client.Retrieve("", networkIdentifier); +]]> + + + +This sample shows how to call RetrieveAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + identifierType = "", + identifier = "", +}); +Response response = await client.RetrieveAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("networkCode").ToString()); +]]> +This sample shows how to call RetrieveAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + identifierType = "", + identifier = "", +}); +Response response = await client.RetrieveAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("networkCode").ToString()); +]]> + + + +This sample shows how to call Retrieve and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + identifierType = "", + identifier = "", +}); +Response response = client.Retrieve("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("networkCode").ToString()); +]]> +This sample shows how to call Retrieve with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + identifierType = "", + identifier = "", +}); +Response response = client.Retrieve("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("networkCode").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/NumberVerification.xml b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/NumberVerification.xml new file mode 100644 index 0000000000000..8966e94d12743 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/NumberVerification.xml @@ -0,0 +1,549 @@ + + + + + +This sample shows how to call VerifyWithoutCodeAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")); +Response response = await client.VerifyWithoutCodeAsync("", numberVerificationContent); +]]> +This sample shows how to call VerifyWithoutCodeAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")) +{ + PhoneNumber = "", + HashedPhoneNumber = "", + ApcCode = "", +}; +Response response = await client.VerifyWithoutCodeAsync("", numberVerificationContent); +]]> + + + +This sample shows how to call VerifyWithoutCode. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")); +Response response = client.VerifyWithoutCode("", numberVerificationContent); +]]> +This sample shows how to call VerifyWithoutCode with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")) +{ + PhoneNumber = "", + HashedPhoneNumber = "", + ApcCode = "", +}; +Response response = client.VerifyWithoutCode("", numberVerificationContent); +]]> + + + +This sample shows how to call VerifyWithoutCodeAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = await client.VerifyWithoutCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call VerifyWithoutCodeAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + phoneNumber = "", + hashedPhoneNumber = "", + apcCode = "", +}); +Response response = await client.VerifyWithoutCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("content").ToString()); +]]> + + + +This sample shows how to call VerifyWithoutCode and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = client.VerifyWithoutCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call VerifyWithoutCode with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + phoneNumber = "", + hashedPhoneNumber = "", + apcCode = "", +}); +Response response = client.VerifyWithoutCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("content").ToString()); +]]> + + + +This sample shows how to call VerifyWithCodeAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")); +Response response = await client.VerifyWithCodeAsync("", numberVerificationContent); +]]> +This sample shows how to call VerifyWithCodeAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")) +{ + PhoneNumber = "", + HashedPhoneNumber = "", + ApcCode = "", +}; +Response response = await client.VerifyWithCodeAsync("", numberVerificationContent); +]]> + + + +This sample shows how to call VerifyWithCode. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")); +Response response = client.VerifyWithCode("", numberVerificationContent); +]]> +This sample shows how to call VerifyWithCode with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")) +{ + PhoneNumber = "", + HashedPhoneNumber = "", + ApcCode = "", +}; +Response response = client.VerifyWithCode("", numberVerificationContent); +]]> + + + +This sample shows how to call VerifyWithCodeAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = await client.VerifyWithCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> +This sample shows how to call VerifyWithCodeAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + phoneNumber = "", + hashedPhoneNumber = "", + apcCode = "", +}); +Response response = await client.VerifyWithCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> + + + +This sample shows how to call VerifyWithCode and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = client.VerifyWithCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> +This sample shows how to call VerifyWithCode with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + phoneNumber = "", + hashedPhoneNumber = "", + apcCode = "", +}); +Response response = client.VerifyWithCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> + + + +This sample shows how to call RetrieveWithoutCodeAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")); +Response response = await client.RetrieveWithoutCodeAsync("", numberRetrievalContent); +]]> +This sample shows how to call RetrieveWithoutCodeAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")) +{ + ApcCode = "", +}; +Response response = await client.RetrieveWithoutCodeAsync("", numberRetrievalContent); +]]> + + + +This sample shows how to call RetrieveWithoutCode. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")); +Response response = client.RetrieveWithoutCode("", numberRetrievalContent); +]]> +This sample shows how to call RetrieveWithoutCode with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")) +{ + ApcCode = "", +}; +Response response = client.RetrieveWithoutCode("", numberRetrievalContent); +]]> + + + +This sample shows how to call RetrieveWithoutCodeAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = await client.RetrieveWithoutCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call RetrieveWithoutCodeAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + apcCode = "", +}); +Response response = await client.RetrieveWithoutCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("content").ToString()); +]]> + + + +This sample shows how to call RetrieveWithoutCode and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = client.RetrieveWithoutCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call RetrieveWithoutCode with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + apcCode = "", +}); +Response response = client.RetrieveWithoutCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("content").ToString()); +]]> + + + +This sample shows how to call RetrieveWithCodeAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")); +Response response = await client.RetrieveWithCodeAsync("", numberRetrievalContent); +]]> +This sample shows how to call RetrieveWithCodeAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")) +{ + ApcCode = "", +}; +Response response = await client.RetrieveWithCodeAsync("", numberRetrievalContent); +]]> + + + +This sample shows how to call RetrieveWithCode. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")); +Response response = client.RetrieveWithCode("", numberRetrievalContent); +]]> +This sample shows how to call RetrieveWithCode with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")) +{ + ApcCode = "", +}; +Response response = client.RetrieveWithCode("", numberRetrievalContent); +]]> + + + +This sample shows how to call RetrieveWithCodeAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = await client.RetrieveWithCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("phoneNumber").ToString()); +]]> +This sample shows how to call RetrieveWithCodeAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + apcCode = "", +}); +Response response = await client.RetrieveWithCodeAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("phoneNumber").ToString()); +]]> + + + +This sample shows how to call RetrieveWithCode and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = client.RetrieveWithCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("phoneNumber").ToString()); +]]> +This sample shows how to call RetrieveWithCode with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + apcCode = "", +}); +Response response = client.RetrieveWithCode("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("phoneNumber").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/SimSwap.xml b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/SimSwap.xml new file mode 100644 index 0000000000000..b5a5fe09e5e1e --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Docs/SimSwap.xml @@ -0,0 +1,273 @@ + + + + + +This sample shows how to call RetrieveAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +SimSwapRetrievalContent simSwapRetrievalContent = new SimSwapRetrievalContent(new NetworkIdentifier("", "")); +Response response = await client.RetrieveAsync("", simSwapRetrievalContent); +]]> +This sample shows how to call RetrieveAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +SimSwapRetrievalContent simSwapRetrievalContent = new SimSwapRetrievalContent(new NetworkIdentifier("", "")) +{ + PhoneNumber = "", +}; +Response response = await client.RetrieveAsync("", simSwapRetrievalContent); +]]> + + + +This sample shows how to call Retrieve. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +SimSwapRetrievalContent simSwapRetrievalContent = new SimSwapRetrievalContent(new NetworkIdentifier("", "")); +Response response = client.Retrieve("", simSwapRetrievalContent); +]]> +This sample shows how to call Retrieve with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +SimSwapRetrievalContent simSwapRetrievalContent = new SimSwapRetrievalContent(new NetworkIdentifier("", "")) +{ + PhoneNumber = "", +}; +Response response = client.Retrieve("", simSwapRetrievalContent); +]]> + + + +This sample shows how to call RetrieveAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = await client.RetrieveAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("date").ToString()); +]]> +This sample shows how to call RetrieveAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + phoneNumber = "", + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = await client.RetrieveAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("date").ToString()); +]]> + + + +This sample shows how to call Retrieve and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = client.Retrieve("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("date").ToString()); +]]> +This sample shows how to call Retrieve with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + phoneNumber = "", + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = client.Retrieve("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("date").ToString()); +]]> + + + +This sample shows how to call VerifyAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +SimSwapVerificationContent simSwapVerificationContent = new SimSwapVerificationContent(new NetworkIdentifier("", "")); +Response response = await client.VerifyAsync("", simSwapVerificationContent); +]]> +This sample shows how to call VerifyAsync with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +SimSwapVerificationContent simSwapVerificationContent = new SimSwapVerificationContent(new NetworkIdentifier("", "")) +{ + PhoneNumber = "", + MaxAgeHours = 1234, +}; +Response response = await client.VerifyAsync("", simSwapVerificationContent); +]]> + + + +This sample shows how to call Verify. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +SimSwapVerificationContent simSwapVerificationContent = new SimSwapVerificationContent(new NetworkIdentifier("", "")); +Response response = client.Verify("", simSwapVerificationContent); +]]> +This sample shows how to call Verify with all parameters. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +SimSwapVerificationContent simSwapVerificationContent = new SimSwapVerificationContent(new NetworkIdentifier("", "")) +{ + PhoneNumber = "", + MaxAgeHours = 1234, +}; +Response response = client.Verify("", simSwapVerificationContent); +]]> + + + +This sample shows how to call VerifyAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = await client.VerifyAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> +This sample shows how to call VerifyAsync with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + phoneNumber = "", + maxAgeHours = 1234, + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = await client.VerifyAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> + + + +This sample shows how to call Verify and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = client.Verify("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> +This sample shows how to call Verify with all parameters and request content and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + +using RequestContent content = RequestContent.Create(new +{ + phoneNumber = "", + maxAgeHours = 1234, + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, +}); +Response response = client.Verify("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("verificationResult").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/EmptyResponse.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/EmptyResponse.Serialization.cs new file mode 100644 index 0000000000000..55196f2636a8c --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/EmptyResponse.Serialization.cs @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class EmptyResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EmptyResponse)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + EmptyResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EmptyResponse)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEmptyResponse(document.RootElement, options); + } + + internal static EmptyResponse DeserializeEmptyResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("content"u8)) + { + content = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new EmptyResponse(content.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(EmptyResponse)} does not support '{options.Format}' format."); + } + } + + EmptyResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEmptyResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EmptyResponse)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static EmptyResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeEmptyResponse(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/EmptyResponse.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/EmptyResponse.cs new file mode 100644 index 0000000000000..b23c753889bf6 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/EmptyResponse.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Empty model to return as part of 302 redirect. + public partial class EmptyResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal EmptyResponse() + { + } + + /// Initializes a new instance of . + /// Optional content. + /// Keeps track of any properties unknown to the library. + internal EmptyResponse(string content, IDictionary serializedAdditionalRawData) + { + Content = content; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Optional content. + public string Content { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv4Address.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv4Address.Serialization.cs new file mode 100644 index 0000000000000..1af95fe2df7a1 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv4Address.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class Ipv4Address : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Ipv4Address)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("ipv4"u8); + writer.WriteStringValue(Ipv4); + writer.WritePropertyName("port"u8); + writer.WriteNumberValue(Port); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Ipv4Address IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Ipv4Address)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIpv4Address(document.RootElement, options); + } + + internal static Ipv4Address DeserializeIpv4Address(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string ipv4 = default; + int port = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ipv4"u8)) + { + ipv4 = property.Value.GetString(); + continue; + } + if (property.NameEquals("port"u8)) + { + port = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new Ipv4Address(ipv4, port, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Ipv4Address)} does not support '{options.Format}' format."); + } + } + + Ipv4Address IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeIpv4Address(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Ipv4Address)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Ipv4Address FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeIpv4Address(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv4Address.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv4Address.cs new file mode 100644 index 0000000000000..588754fae7e2e --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv4Address.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// IPv4 device indicator. + public partial class Ipv4Address + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// IPv4 address may be specified in form <address/mask> as: + /// - address - an IPv4 number in dotted-quad form 1.2.3.4. Only this exact IP number will match the flow control rule. + /// - address/mask - an IP number as above with a mask width of the form 1.2.3.4/24. + /// In this case, all IP numbers from 1.2.3.0 to 1.2.3.255 will match. The bit width MUST be valid for the IP version. + /// + /// User equipment port. + /// is null. + public Ipv4Address(string ipv4, int port) + { + Argument.AssertNotNull(ipv4, nameof(ipv4)); + + Ipv4 = ipv4; + Port = port; + } + + /// Initializes a new instance of . + /// + /// IPv4 address may be specified in form <address/mask> as: + /// - address - an IPv4 number in dotted-quad form 1.2.3.4. Only this exact IP number will match the flow control rule. + /// - address/mask - an IP number as above with a mask width of the form 1.2.3.4/24. + /// In this case, all IP numbers from 1.2.3.0 to 1.2.3.255 will match. The bit width MUST be valid for the IP version. + /// + /// User equipment port. + /// Keeps track of any properties unknown to the library. + internal Ipv4Address(string ipv4, int port, IDictionary serializedAdditionalRawData) + { + Ipv4 = ipv4; + Port = port; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Ipv4Address() + { + } + + /// + /// IPv4 address may be specified in form <address/mask> as: + /// - address - an IPv4 number in dotted-quad form 1.2.3.4. Only this exact IP number will match the flow control rule. + /// - address/mask - an IP number as above with a mask width of the form 1.2.3.4/24. + /// In this case, all IP numbers from 1.2.3.0 to 1.2.3.255 will match. The bit width MUST be valid for the IP version. + /// + public string Ipv4 { get; } + /// User equipment port. + public int Port { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv6Address.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv6Address.Serialization.cs new file mode 100644 index 0000000000000..0321238f78916 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv6Address.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class Ipv6Address : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Ipv6Address)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("ipv6"u8); + writer.WriteStringValue(Ipv6); + writer.WritePropertyName("port"u8); + writer.WriteNumberValue(Port); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Ipv6Address IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Ipv6Address)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIpv6Address(document.RootElement, options); + } + + internal static Ipv6Address DeserializeIpv6Address(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string ipv6 = default; + int port = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ipv6"u8)) + { + ipv6 = property.Value.GetString(); + continue; + } + if (property.NameEquals("port"u8)) + { + port = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new Ipv6Address(ipv6, port, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Ipv6Address)} does not support '{options.Format}' format."); + } + } + + Ipv6Address IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeIpv6Address(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Ipv6Address)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Ipv6Address FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeIpv6Address(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv6Address.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv6Address.cs new file mode 100644 index 0000000000000..a4bdf322aca45 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/Ipv6Address.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// IPv6 device indicator. + public partial class Ipv6Address + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// IPv6 address, following IETF 5952 format, may be specified in form <address/mask> as: + /// - address - The /128 subnet is optional for single addresses: + /// - 2001:db8:85a3:8d3:1319:8a2e:370:7344 + /// - 2001:db8:85a3:8d3:1319:8a2e:370:7344/128 + /// - address/mask - an IP v6 number with a mask: + /// - 2001:db8:85a3:8d3::0/64 + /// - 2001:db8:85a3:8d3::/64 + /// + /// User equipment port. + /// is null. + public Ipv6Address(string ipv6, int port) + { + Argument.AssertNotNull(ipv6, nameof(ipv6)); + + Ipv6 = ipv6; + Port = port; + } + + /// Initializes a new instance of . + /// + /// IPv6 address, following IETF 5952 format, may be specified in form <address/mask> as: + /// - address - The /128 subnet is optional for single addresses: + /// - 2001:db8:85a3:8d3:1319:8a2e:370:7344 + /// - 2001:db8:85a3:8d3:1319:8a2e:370:7344/128 + /// - address/mask - an IP v6 number with a mask: + /// - 2001:db8:85a3:8d3::0/64 + /// - 2001:db8:85a3:8d3::/64 + /// + /// User equipment port. + /// Keeps track of any properties unknown to the library. + internal Ipv6Address(string ipv6, int port, IDictionary serializedAdditionalRawData) + { + Ipv6 = ipv6; + Port = port; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Ipv6Address() + { + } + + /// + /// IPv6 address, following IETF 5952 format, may be specified in form <address/mask> as: + /// - address - The /128 subnet is optional for single addresses: + /// - 2001:db8:85a3:8d3:1319:8a2e:370:7344 + /// - 2001:db8:85a3:8d3:1319:8a2e:370:7344/128 + /// - address/mask - an IP v6 number with a mask: + /// - 2001:db8:85a3:8d3::0/64 + /// - 2001:db8:85a3:8d3::/64 + /// + public string Ipv6 { get; } + /// User equipment port. + public int Port { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/LocationDevice.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/LocationDevice.Serialization.cs new file mode 100644 index 0000000000000..4e039ee13f39e --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/LocationDevice.Serialization.cs @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class LocationDevice : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocationDevice)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NetworkAccessIdentifier)) + { + writer.WritePropertyName("networkAccessIdentifier"u8); + writer.WriteStringValue(NetworkAccessIdentifier); + } + if (Optional.IsDefined(PhoneNumber)) + { + writer.WritePropertyName("phoneNumber"u8); + writer.WriteStringValue(PhoneNumber); + } + if (Optional.IsDefined(Ipv4Address)) + { + writer.WritePropertyName("ipv4Address"u8); + writer.WriteObjectValue(Ipv4Address); + } + if (Optional.IsDefined(Ipv6Address)) + { + writer.WritePropertyName("ipv6Address"u8); + writer.WriteObjectValue(Ipv6Address); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + LocationDevice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocationDevice)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocationDevice(document.RootElement, options); + } + + internal static LocationDevice DeserializeLocationDevice(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional networkAccessIdentifier = default; + Optional phoneNumber = default; + Optional ipv4Address = default; + Optional ipv6Address = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("networkAccessIdentifier"u8)) + { + networkAccessIdentifier = property.Value.GetString(); + continue; + } + if (property.NameEquals("phoneNumber"u8)) + { + phoneNumber = property.Value.GetString(); + continue; + } + if (property.NameEquals("ipv4Address"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + ipv4Address = Ipv4Address.DeserializeIpv4Address(property.Value); + continue; + } + if (property.NameEquals("ipv6Address"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + ipv6Address = Ipv6Address.DeserializeIpv6Address(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new LocationDevice(networkAccessIdentifier.Value, phoneNumber.Value, ipv4Address.Value, ipv6Address.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(LocationDevice)} does not support '{options.Format}' format."); + } + } + + LocationDevice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeLocationDevice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocationDevice)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static LocationDevice FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeLocationDevice(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/LocationDevice.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/LocationDevice.cs new file mode 100644 index 0000000000000..6748649f211bc --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/LocationDevice.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Device information needed by operator to provide location information. Include exactly one of these properties to identify your device. + public partial class LocationDevice + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public LocationDevice() + { + } + + /// Initializes a new instance of . + /// External identifier or network access identifier of the device. + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// The Ipv4 address. + /// The Ipv6 address. + /// Keeps track of any properties unknown to the library. + internal LocationDevice(string networkAccessIdentifier, string phoneNumber, Ipv4Address ipv4Address, Ipv6Address ipv6Address, IDictionary serializedAdditionalRawData) + { + NetworkAccessIdentifier = networkAccessIdentifier; + PhoneNumber = phoneNumber; + Ipv4Address = ipv4Address; + Ipv6Address = ipv6Address; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// External identifier or network access identifier of the device. + public string NetworkAccessIdentifier { get; set; } + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + public string PhoneNumber { get; set; } + /// The Ipv4 address. + public Ipv4Address Ipv4Address { get; set; } + /// The Ipv6 address. + public Ipv6Address Ipv6Address { get; set; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkIdentifier.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkIdentifier.Serialization.cs new file mode 100644 index 0000000000000..fffed005d68f9 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkIdentifier.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class NetworkIdentifier : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkIdentifier)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("identifierType"u8); + writer.WriteStringValue(IdentifierType); + writer.WritePropertyName("identifier"u8); + writer.WriteStringValue(Identifier); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkIdentifier IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkIdentifier)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkIdentifier(document.RootElement, options); + } + + internal static NetworkIdentifier DeserializeNetworkIdentifier(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string identifierType = default; + string identifier = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("identifierType"u8)) + { + identifierType = property.Value.GetString(); + continue; + } + if (property.NameEquals("identifier"u8)) + { + identifier = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new NetworkIdentifier(identifierType, identifier, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NetworkIdentifier)} does not support '{options.Format}' format."); + } + } + + NetworkIdentifier IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkIdentifier(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkIdentifier)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static NetworkIdentifier FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeNetworkIdentifier(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkIdentifier.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkIdentifier.cs new file mode 100644 index 0000000000000..775ef4e2ebb10 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkIdentifier.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Identifier for the network to be queried. + public partial class NetworkIdentifier + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The type of identifier for the network. one of: 'IPv4', 'IPv6', 'NetworkCode'. + /// + /// The network identifier in a format matching the type above: + /// - IPv4 of a device in dotted-quad form 1.2.3.4. + /// - IPv6 of a device in IETF 5952 format. + /// - NetworkCode matching our documentation or an output from /Network:retrieve." + /// + /// or is null. + public NetworkIdentifier(string identifierType, string identifier) + { + Argument.AssertNotNull(identifierType, nameof(identifierType)); + Argument.AssertNotNull(identifier, nameof(identifier)); + + IdentifierType = identifierType; + Identifier = identifier; + } + + /// Initializes a new instance of . + /// The type of identifier for the network. one of: 'IPv4', 'IPv6', 'NetworkCode'. + /// + /// The network identifier in a format matching the type above: + /// - IPv4 of a device in dotted-quad form 1.2.3.4. + /// - IPv6 of a device in IETF 5952 format. + /// - NetworkCode matching our documentation or an output from /Network:retrieve." + /// + /// Keeps track of any properties unknown to the library. + internal NetworkIdentifier(string identifierType, string identifier, IDictionary serializedAdditionalRawData) + { + IdentifierType = identifierType; + Identifier = identifier; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NetworkIdentifier() + { + } + + /// The type of identifier for the network. one of: 'IPv4', 'IPv6', 'NetworkCode'. + public string IdentifierType { get; } + /// + /// The network identifier in a format matching the type above: + /// - IPv4 of a device in dotted-quad form 1.2.3.4. + /// - IPv6 of a device in IETF 5952 format. + /// - NetworkCode matching our documentation or an output from /Network:retrieve." + /// + public string Identifier { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkRetrievalResult.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkRetrievalResult.Serialization.cs new file mode 100644 index 0000000000000..4d913ed13af46 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkRetrievalResult.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class NetworkRetrievalResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkRetrievalResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("networkCode"u8); + writer.WriteStringValue(NetworkCode); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkRetrievalResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkRetrievalResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkRetrievalResult(document.RootElement, options); + } + + internal static NetworkRetrievalResult DeserializeNetworkRetrievalResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string networkCode = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("networkCode"u8)) + { + networkCode = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new NetworkRetrievalResult(networkCode, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NetworkRetrievalResult)} does not support '{options.Format}' format."); + } + } + + NetworkRetrievalResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkRetrievalResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkRetrievalResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static NetworkRetrievalResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeNetworkRetrievalResult(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkRetrievalResult.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkRetrievalResult.cs new file mode 100644 index 0000000000000..71696d2a447d5 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NetworkRetrievalResult.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// The network that the device is on. + public partial class NetworkRetrievalResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier for the network. This can be used as the networkIdentifier for the service APIs. + /// is null. + internal NetworkRetrievalResult(string networkCode) + { + Argument.AssertNotNull(networkCode, nameof(networkCode)); + + NetworkCode = networkCode; + } + + /// Initializes a new instance of . + /// The identifier for the network. This can be used as the networkIdentifier for the service APIs. + /// Keeps track of any properties unknown to the library. + internal NetworkRetrievalResult(string networkCode, IDictionary serializedAdditionalRawData) + { + NetworkCode = networkCode; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NetworkRetrievalResult() + { + } + + /// The identifier for the network. This can be used as the networkIdentifier for the service APIs. + public string NetworkCode { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalContent.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalContent.Serialization.cs new file mode 100644 index 0000000000000..1e2d3ed704005 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalContent.Serialization.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class NumberRetrievalContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NumberRetrievalContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("networkIdentifier"u8); + writer.WriteObjectValue(NetworkIdentifier); + if (Optional.IsDefined(ApcCode)) + { + writer.WritePropertyName("apcCode"u8); + writer.WriteStringValue(ApcCode); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NumberRetrievalContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NumberRetrievalContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNumberRetrievalContent(document.RootElement, options); + } + + internal static NumberRetrievalContent DeserializeNumberRetrievalContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NetworkIdentifier networkIdentifier = default; + Optional apcCode = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("networkIdentifier"u8)) + { + networkIdentifier = NetworkIdentifier.DeserializeNetworkIdentifier(property.Value); + continue; + } + if (property.NameEquals("apcCode"u8)) + { + apcCode = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new NumberRetrievalContent(networkIdentifier, apcCode.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NumberRetrievalContent)} does not support '{options.Format}' format."); + } + } + + NumberRetrievalContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNumberRetrievalContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NumberRetrievalContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static NumberRetrievalContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeNumberRetrievalContent(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalContent.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalContent.cs new file mode 100644 index 0000000000000..9796394baffd6 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalContent.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Request to retrieve number of device. + public partial class NumberRetrievalContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Identifier for the network to query for this device. + /// is null. + public NumberRetrievalContent(NetworkIdentifier networkIdentifier) + { + Argument.AssertNotNull(networkIdentifier, nameof(networkIdentifier)); + + NetworkIdentifier = networkIdentifier; + } + + /// Initializes a new instance of . + /// Identifier for the network to query for this device. + /// The code provided by APC is exchange for the operator code. + /// Keeps track of any properties unknown to the library. + internal NumberRetrievalContent(NetworkIdentifier networkIdentifier, string apcCode, IDictionary serializedAdditionalRawData) + { + NetworkIdentifier = networkIdentifier; + ApcCode = apcCode; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NumberRetrievalContent() + { + } + + /// Identifier for the network to query for this device. + public NetworkIdentifier NetworkIdentifier { get; } + /// The code provided by APC is exchange for the operator code. + public string ApcCode { get; set; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalResult.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalResult.Serialization.cs new file mode 100644 index 0000000000000..ed98622f3ca26 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalResult.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class NumberRetrievalResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NumberRetrievalResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("phoneNumber"u8); + writer.WriteStringValue(PhoneNumber); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NumberRetrievalResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NumberRetrievalResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNumberRetrievalResult(document.RootElement, options); + } + + internal static NumberRetrievalResult DeserializeNumberRetrievalResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string phoneNumber = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("phoneNumber"u8)) + { + phoneNumber = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new NumberRetrievalResult(phoneNumber, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NumberRetrievalResult)} does not support '{options.Format}' format."); + } + } + + NumberRetrievalResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNumberRetrievalResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NumberRetrievalResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static NumberRetrievalResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeNumberRetrievalResult(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalResult.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalResult.cs new file mode 100644 index 0000000000000..65736585e091a --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberRetrievalResult.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Response with number of device. + public partial class NumberRetrievalResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// is null. + internal NumberRetrievalResult(string phoneNumber) + { + Argument.AssertNotNull(phoneNumber, nameof(phoneNumber)); + + PhoneNumber = phoneNumber; + } + + /// Initializes a new instance of . + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// Keeps track of any properties unknown to the library. + internal NumberRetrievalResult(string phoneNumber, IDictionary serializedAdditionalRawData) + { + PhoneNumber = phoneNumber; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NumberRetrievalResult() + { + } + + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + public string PhoneNumber { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerification.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerification.cs new file mode 100644 index 0000000000000..18e9646182212 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerification.cs @@ -0,0 +1,617 @@ +// 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; + +namespace Azure.Communication.ProgrammableConnectivity +{ + // Data plane generated sub-client. + /// + /// Number operations include Frontend Authentication. + /// + /// Users must first make a call to triggerFrontendAuthentication, which redirects the device + /// to the device's Network to authenticate directly. The Network responds with a token. + /// + /// This redirects the device to APC, where the token is used to verify / retrieve + /// the device number. The second response is a 200 containing the result of the query. + /// + /// This flow requires some manual interaction from the developer between receiving the 302 redirect, + /// and making a second call to obtain the number verification result. This has therefore been + /// split into two operations, one for the redirect, and one for the result. + /// + public partial class NumberVerification + { + private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com//.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of NumberVerification for mocking. + protected NumberVerification() + { + } + + /// Initializes a new instance of NumberVerification. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// An Azure Programmable Connectivity Endpoint providing access to Network APIs, for example https://{region}.apcgatewayapi.azure.com. + /// The API version to use for this operation. + internal NumberVerification(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Verifies the phone number (MSISDN) associated with a device. As part of the frontend authorisation flow, the device is redirected to the operator network to authenticate directly. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to verify number of device. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> VerifyWithoutCodeAsync(string apcGatewayId, NumberVerificationContent numberVerificationContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(numberVerificationContent, nameof(numberVerificationContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = numberVerificationContent.ToRequestContent(); + Response response = await VerifyWithoutCodeAsync(apcGatewayId, content, context).ConfigureAwait(false); + return Response.FromValue(EmptyResponse.FromResponse(response), response); + } + + /// Verifies the phone number (MSISDN) associated with a device. As part of the frontend authorisation flow, the device is redirected to the operator network to authenticate directly. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to verify number of device. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response VerifyWithoutCode(string apcGatewayId, NumberVerificationContent numberVerificationContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(numberVerificationContent, nameof(numberVerificationContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = numberVerificationContent.ToRequestContent(); + Response response = VerifyWithoutCode(apcGatewayId, content, context); + return Response.FromValue(EmptyResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Verifies the phone number (MSISDN) associated with a device. As part of the frontend authorisation flow, the device is redirected to the operator network to authenticate directly. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task VerifyWithoutCodeAsync(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("NumberVerification.VerifyWithoutCode"); + scope.Start(); + try + { + using HttpMessage message = CreateVerifyWithoutCodeRequest(apcGatewayId, content, context); + RedirectPolicy.SetAllowAutoRedirect(message, true); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Verifies the phone number (MSISDN) associated with a device. As part of the frontend authorisation flow, the device is redirected to the operator network to authenticate directly. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response VerifyWithoutCode(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("NumberVerification.VerifyWithoutCode"); + scope.Start(); + try + { + using HttpMessage message = CreateVerifyWithoutCodeRequest(apcGatewayId, content, context); + RedirectPolicy.SetAllowAutoRedirect(message, true); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Verifies the phone number (MSISDN) associated with a device. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to verify number of device. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> VerifyWithCodeAsync(string apcGatewayId, NumberVerificationContent numberVerificationContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(numberVerificationContent, nameof(numberVerificationContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = numberVerificationContent.ToRequestContent(); + Response response = await VerifyWithCodeAsync(apcGatewayId, content, context).ConfigureAwait(false); + return Response.FromValue(NumberVerificationResult.FromResponse(response), response); + } + + /// Verifies the phone number (MSISDN) associated with a device. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to verify number of device. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response VerifyWithCode(string apcGatewayId, NumberVerificationContent numberVerificationContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(numberVerificationContent, nameof(numberVerificationContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = numberVerificationContent.ToRequestContent(); + Response response = VerifyWithCode(apcGatewayId, content, context); + return Response.FromValue(NumberVerificationResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Verifies the phone number (MSISDN) associated with a device. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task VerifyWithCodeAsync(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("NumberVerification.VerifyWithCode"); + scope.Start(); + try + { + using HttpMessage message = CreateVerifyWithCodeRequest(apcGatewayId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Verifies the phone number (MSISDN) associated with a device. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response VerifyWithCode(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("NumberVerification.VerifyWithCode"); + scope.Start(); + try + { + using HttpMessage message = CreateVerifyWithCodeRequest(apcGatewayId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves the phone number (MSISDN) associated with a device. As part of the frontend authorisation flow, the device is redirected to the operator network to authenticate directly. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to retrieve number of device. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> RetrieveWithoutCodeAsync(string apcGatewayId, NumberRetrievalContent numberRetrievalContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(numberRetrievalContent, nameof(numberRetrievalContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = numberRetrievalContent.ToRequestContent(); + Response response = await RetrieveWithoutCodeAsync(apcGatewayId, content, context).ConfigureAwait(false); + return Response.FromValue(EmptyResponse.FromResponse(response), response); + } + + /// Retrieves the phone number (MSISDN) associated with a device. As part of the frontend authorisation flow, the device is redirected to the operator network to authenticate directly. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to retrieve number of device. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response RetrieveWithoutCode(string apcGatewayId, NumberRetrievalContent numberRetrievalContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(numberRetrievalContent, nameof(numberRetrievalContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = numberRetrievalContent.ToRequestContent(); + Response response = RetrieveWithoutCode(apcGatewayId, content, context); + return Response.FromValue(EmptyResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves the phone number (MSISDN) associated with a device. As part of the frontend authorisation flow, the device is redirected to the operator network to authenticate directly. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task RetrieveWithoutCodeAsync(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("NumberVerification.RetrieveWithoutCode"); + scope.Start(); + try + { + using HttpMessage message = CreateRetrieveWithoutCodeRequest(apcGatewayId, content, context); + RedirectPolicy.SetAllowAutoRedirect(message, true); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves the phone number (MSISDN) associated with a device. As part of the frontend authorisation flow, the device is redirected to the operator network to authenticate directly. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response RetrieveWithoutCode(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("NumberVerification.RetrieveWithoutCode"); + scope.Start(); + try + { + using HttpMessage message = CreateRetrieveWithoutCodeRequest(apcGatewayId, content, context); + RedirectPolicy.SetAllowAutoRedirect(message, true); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves the phone number (MSISDN) associated with a device. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to retrieve number of device. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> RetrieveWithCodeAsync(string apcGatewayId, NumberRetrievalContent numberRetrievalContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(numberRetrievalContent, nameof(numberRetrievalContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = numberRetrievalContent.ToRequestContent(); + Response response = await RetrieveWithCodeAsync(apcGatewayId, content, context).ConfigureAwait(false); + return Response.FromValue(NumberRetrievalResult.FromResponse(response), response); + } + + /// Retrieves the phone number (MSISDN) associated with a device. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to retrieve number of device. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response RetrieveWithCode(string apcGatewayId, NumberRetrievalContent numberRetrievalContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(numberRetrievalContent, nameof(numberRetrievalContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = numberRetrievalContent.ToRequestContent(); + Response response = RetrieveWithCode(apcGatewayId, content, context); + return Response.FromValue(NumberRetrievalResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves the phone number (MSISDN) associated with a device. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task RetrieveWithCodeAsync(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("NumberVerification.RetrieveWithCode"); + scope.Start(); + try + { + using HttpMessage message = CreateRetrieveWithCodeRequest(apcGatewayId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves the phone number (MSISDN) associated with a device. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response RetrieveWithCode(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("NumberVerification.RetrieveWithCode"); + scope.Start(); + try + { + using HttpMessage message = CreateRetrieveWithCodeRequest(apcGatewayId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateVerifyWithoutCodeRequest(string apcGatewayId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier302); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/number-verification/number:verify", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("apc-gateway-id", apcGatewayId); + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateVerifyWithCodeRequest(string apcGatewayId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/number-verification/number:verify", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("apc-gateway-id", apcGatewayId); + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateRetrieveWithoutCodeRequest(string apcGatewayId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier302); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/number-verification/number:retrieve", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("apc-gateway-id", apcGatewayId); + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateRetrieveWithCodeRequest(string apcGatewayId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/number-verification/number:retrieve", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("apc-gateway-id", apcGatewayId); + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier302; + private static ResponseClassifier ResponseClassifier302 => _responseClassifier302 ??= new StatusCodeClassifier(stackalloc ushort[] { 302 }); + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationContent.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationContent.Serialization.cs new file mode 100644 index 0000000000000..e47636b84e001 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationContent.Serialization.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class NumberVerificationContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NumberVerificationContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("networkIdentifier"u8); + writer.WriteObjectValue(NetworkIdentifier); + if (Optional.IsDefined(PhoneNumber)) + { + writer.WritePropertyName("phoneNumber"u8); + writer.WriteStringValue(PhoneNumber); + } + if (Optional.IsDefined(HashedPhoneNumber)) + { + writer.WritePropertyName("hashedPhoneNumber"u8); + writer.WriteStringValue(HashedPhoneNumber); + } + if (Optional.IsDefined(ApcCode)) + { + writer.WritePropertyName("apcCode"u8); + writer.WriteStringValue(ApcCode); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NumberVerificationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NumberVerificationContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNumberVerificationContent(document.RootElement, options); + } + + internal static NumberVerificationContent DeserializeNumberVerificationContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NetworkIdentifier networkIdentifier = default; + Optional phoneNumber = default; + Optional hashedPhoneNumber = default; + Optional apcCode = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("networkIdentifier"u8)) + { + networkIdentifier = NetworkIdentifier.DeserializeNetworkIdentifier(property.Value); + continue; + } + if (property.NameEquals("phoneNumber"u8)) + { + phoneNumber = property.Value.GetString(); + continue; + } + if (property.NameEquals("hashedPhoneNumber"u8)) + { + hashedPhoneNumber = property.Value.GetString(); + continue; + } + if (property.NameEquals("apcCode"u8)) + { + apcCode = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new NumberVerificationContent(networkIdentifier, phoneNumber.Value, hashedPhoneNumber.Value, apcCode.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NumberVerificationContent)} does not support '{options.Format}' format."); + } + } + + NumberVerificationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNumberVerificationContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NumberVerificationContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static NumberVerificationContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeNumberVerificationContent(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationContent.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationContent.cs new file mode 100644 index 0000000000000..c5085e7a401a5 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationContent.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Request to verify number of device. + public partial class NumberVerificationContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Identifier for the network to query for this device. + /// is null. + public NumberVerificationContent(NetworkIdentifier networkIdentifier) + { + Argument.AssertNotNull(networkIdentifier, nameof(networkIdentifier)); + + NetworkIdentifier = networkIdentifier; + } + + /// Initializes a new instance of . + /// Identifier for the network to query for this device. + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// Hashed phone number. SHA-256 (in hexadecimal representation) of the mobile phone number in **E.164 format (starting with country code)**. Optionally prefixed with '+'. + /// The code provided by APC is exchange for the operator code. + /// Keeps track of any properties unknown to the library. + internal NumberVerificationContent(NetworkIdentifier networkIdentifier, string phoneNumber, string hashedPhoneNumber, string apcCode, IDictionary serializedAdditionalRawData) + { + NetworkIdentifier = networkIdentifier; + PhoneNumber = phoneNumber; + HashedPhoneNumber = hashedPhoneNumber; + ApcCode = apcCode; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NumberVerificationContent() + { + } + + /// Identifier for the network to query for this device. + public NetworkIdentifier NetworkIdentifier { get; } + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + public string PhoneNumber { get; set; } + /// Hashed phone number. SHA-256 (in hexadecimal representation) of the mobile phone number in **E.164 format (starting with country code)**. Optionally prefixed with '+'. + public string HashedPhoneNumber { get; set; } + /// The code provided by APC is exchange for the operator code. + public string ApcCode { get; set; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationResult.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationResult.Serialization.cs new file mode 100644 index 0000000000000..81974742c262f --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationResult.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class NumberVerificationResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NumberVerificationResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("verificationResult"u8); + writer.WriteBooleanValue(VerificationResult); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NumberVerificationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NumberVerificationResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNumberVerificationResult(document.RootElement, options); + } + + internal static NumberVerificationResult DeserializeNumberVerificationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool verificationResult = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("verificationResult"u8)) + { + verificationResult = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new NumberVerificationResult(verificationResult, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NumberVerificationResult)} does not support '{options.Format}' format."); + } + } + + NumberVerificationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNumberVerificationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NumberVerificationResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static NumberVerificationResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeNumberVerificationResult(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationResult.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationResult.cs new file mode 100644 index 0000000000000..eb64683bbfcf0 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/NumberVerificationResult.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Response verifying number of device. + public partial class NumberVerificationResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// True if number if the phone number matches the device, False otherwise. + internal NumberVerificationResult(bool verificationResult) + { + VerificationResult = verificationResult; + } + + /// Initializes a new instance of . + /// True if number if the phone number matches the device, False otherwise. + /// Keeps track of any properties unknown to the library. + internal NumberVerificationResult(bool verificationResult, IDictionary serializedAdditionalRawData) + { + VerificationResult = verificationResult; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NumberVerificationResult() + { + } + + /// True if number if the phone number matches the device, False otherwise. + public bool VerificationResult { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/ProgrammableConnectivityClient.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/ProgrammableConnectivityClient.cs new file mode 100644 index 0000000000000..7ae25fd38da9f --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/ProgrammableConnectivityClient.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Communication.ProgrammableConnectivity +{ + // Data plane generated client. + /// The ProgrammableConnectivity service client. + public partial class ProgrammableConnectivityClient + { + private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com//.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of ProgrammableConnectivityClient for mocking. + protected ProgrammableConnectivityClient() + { + } + + /// Initializes a new instance of ProgrammableConnectivityClient. + /// An Azure Programmable Connectivity Endpoint providing access to Network APIs, for example https://{region}.apcgatewayapi.azure.com. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public ProgrammableConnectivityClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new ProgrammableConnectivityClientOptions()) + { + } + + /// Initializes a new instance of ProgrammableConnectivityClient. + /// An Azure Programmable Connectivity Endpoint providing access to Network APIs, for example https://{region}.apcgatewayapi.azure.com. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public ProgrammableConnectivityClient(Uri endpoint, TokenCredential credential, ProgrammableConnectivityClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new ProgrammableConnectivityClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + /// Initializes a new instance of DeviceLocation. + /// The API version to use for this operation. + /// is null. + public virtual DeviceLocation GetDeviceLocationClient(string apiVersion = "v2024_01_09_preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new DeviceLocation(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of DeviceNetwork. + /// The API version to use for this operation. + /// is null. + public virtual DeviceNetwork GetDeviceNetworkClient(string apiVersion = "v2024_01_09_preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new DeviceNetwork(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of NumberVerification. + /// The API version to use for this operation. + /// is null. + public virtual NumberVerification GetNumberVerificationClient(string apiVersion = "v2024_01_09_preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new NumberVerification(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of SimSwap. + /// The API version to use for this operation. + /// is null. + public virtual SimSwap GetSimSwapClient(string apiVersion = "v2024_01_09_preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new SimSwap(ClientDiagnostics, _pipeline, _tokenCredential, _endpoint, apiVersion); + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/ProgrammableConnectivityClientOptions.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/ProgrammableConnectivityClientOptions.cs new file mode 100644 index 0000000000000..9a12e082324be --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/ProgrammableConnectivityClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Client options for ProgrammableConnectivityClient. + public partial class ProgrammableConnectivityClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_01_09_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "v2024_01_09_preview". + V2024_01_09_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of ProgrammableConnectivityClientOptions. + public ProgrammableConnectivityClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_01_09_Preview => "v2024_01_09_preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwap.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwap.cs new file mode 100644 index 0000000000000..bf07f73c1e7bb --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwap.cs @@ -0,0 +1,333 @@ +// 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; + +namespace Azure.Communication.ProgrammableConnectivity +{ + // Data plane generated sub-client. + /// SIM Swap API provides the customer the ability to obtain information on any recent SIM pairing change related to the User's mobile account. + public partial class SimSwap + { + private static readonly string[] AuthorizationScopes = new string[] { "https://management.azure.com//.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of SimSwap for mocking. + protected SimSwap() + { + } + + /// Initializes a new instance of SimSwap. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The token credential to copy. + /// An Azure Programmable Connectivity Endpoint providing access to Network APIs, for example https://{region}.apcgatewayapi.azure.com. + /// The API version to use for this operation. + internal SimSwap(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Provides timestamp of latest SIM swap. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to retrieve SimSwap date. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> RetrieveAsync(string apcGatewayId, SimSwapRetrievalContent simSwapRetrievalContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(simSwapRetrievalContent, nameof(simSwapRetrievalContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = simSwapRetrievalContent.ToRequestContent(); + Response response = await RetrieveAsync(apcGatewayId, content, context).ConfigureAwait(false); + return Response.FromValue(SimSwapRetrievalResult.FromResponse(response), response); + } + + /// Provides timestamp of latest SIM swap. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to retrieve SimSwap date. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response Retrieve(string apcGatewayId, SimSwapRetrievalContent simSwapRetrievalContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(simSwapRetrievalContent, nameof(simSwapRetrievalContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = simSwapRetrievalContent.ToRequestContent(); + Response response = Retrieve(apcGatewayId, content, context); + return Response.FromValue(SimSwapRetrievalResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Provides timestamp of latest SIM swap + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task RetrieveAsync(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("SimSwap.Retrieve"); + scope.Start(); + try + { + using HttpMessage message = CreateRetrieveRequest(apcGatewayId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Provides timestamp of latest SIM swap + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Retrieve(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("SimSwap.Retrieve"); + scope.Start(); + try + { + using HttpMessage message = CreateRetrieveRequest(apcGatewayId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Verifies if a SIM swap has been performed during a past period (defined in the request with 'maxAgeHours' attribute). Returns 'True' if a SIM swap has occured. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to verify SimSwap in period. + /// The cancellation token to use. + /// or is null. + /// + public virtual async Task> VerifyAsync(string apcGatewayId, SimSwapVerificationContent simSwapVerificationContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(simSwapVerificationContent, nameof(simSwapVerificationContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = simSwapVerificationContent.ToRequestContent(); + Response response = await VerifyAsync(apcGatewayId, content, context).ConfigureAwait(false); + return Response.FromValue(SimSwapVerificationResult.FromResponse(response), response); + } + + /// Verifies if a SIM swap has been performed during a past period (defined in the request with 'maxAgeHours' attribute). Returns 'True' if a SIM swap has occured. + /// The identifier of the APC Gateway resource which should handle this request. + /// Request to verify SimSwap in period. + /// The cancellation token to use. + /// or is null. + /// + public virtual Response Verify(string apcGatewayId, SimSwapVerificationContent simSwapVerificationContent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(simSwapVerificationContent, nameof(simSwapVerificationContent)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = simSwapVerificationContent.ToRequestContent(); + Response response = Verify(apcGatewayId, content, context); + return Response.FromValue(SimSwapVerificationResult.FromResponse(response), response); + } + + /// + /// [Protocol Method] Verifies if a SIM swap has been performed during a past period (defined in the request with 'maxAgeHours' attribute). Returns 'True' if a SIM swap has occured. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task VerifyAsync(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("SimSwap.Verify"); + scope.Start(); + try + { + using HttpMessage message = CreateVerifyRequest(apcGatewayId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Verifies if a SIM swap has been performed during a past period (defined in the request with 'maxAgeHours' attribute). Returns 'True' if a SIM swap has occured. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The identifier of the APC Gateway resource which should handle this request. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Verify(string apcGatewayId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(apcGatewayId, nameof(apcGatewayId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("SimSwap.Verify"); + scope.Start(); + try + { + using HttpMessage message = CreateVerifyRequest(apcGatewayId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateRetrieveRequest(string apcGatewayId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/sim-swap/sim-swap:retrieve", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("apc-gateway-id", apcGatewayId); + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateVerifyRequest(string apcGatewayId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/sim-swap/sim-swap:verify", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("apc-gateway-id", apcGatewayId); + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalContent.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalContent.Serialization.cs new file mode 100644 index 0000000000000..dca5f70bb922a --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalContent.Serialization.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class SimSwapRetrievalContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SimSwapRetrievalContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(PhoneNumber)) + { + writer.WritePropertyName("phoneNumber"u8); + writer.WriteStringValue(PhoneNumber); + } + writer.WritePropertyName("networkIdentifier"u8); + writer.WriteObjectValue(NetworkIdentifier); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SimSwapRetrievalContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SimSwapRetrievalContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSimSwapRetrievalContent(document.RootElement, options); + } + + internal static SimSwapRetrievalContent DeserializeSimSwapRetrievalContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional phoneNumber = default; + NetworkIdentifier networkIdentifier = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("phoneNumber"u8)) + { + phoneNumber = property.Value.GetString(); + continue; + } + if (property.NameEquals("networkIdentifier"u8)) + { + networkIdentifier = NetworkIdentifier.DeserializeNetworkIdentifier(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SimSwapRetrievalContent(phoneNumber.Value, networkIdentifier, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SimSwapRetrievalContent)} does not support '{options.Format}' format."); + } + } + + SimSwapRetrievalContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSimSwapRetrievalContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SimSwapRetrievalContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SimSwapRetrievalContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSimSwapRetrievalContent(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalContent.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalContent.cs new file mode 100644 index 0000000000000..dbacb15efe2bd --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalContent.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Request to retrieve SimSwap date. + public partial class SimSwapRetrievalContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Network to query for this device. + /// is null. + public SimSwapRetrievalContent(NetworkIdentifier networkIdentifier) + { + Argument.AssertNotNull(networkIdentifier, nameof(networkIdentifier)); + + NetworkIdentifier = networkIdentifier; + } + + /// Initializes a new instance of . + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// Network to query for this device. + /// Keeps track of any properties unknown to the library. + internal SimSwapRetrievalContent(string phoneNumber, NetworkIdentifier networkIdentifier, IDictionary serializedAdditionalRawData) + { + PhoneNumber = phoneNumber; + NetworkIdentifier = networkIdentifier; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SimSwapRetrievalContent() + { + } + + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + public string PhoneNumber { get; set; } + /// Network to query for this device. + public NetworkIdentifier NetworkIdentifier { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalResult.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalResult.Serialization.cs new file mode 100644 index 0000000000000..5fd1b2192a65c --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalResult.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class SimSwapRetrievalResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SimSwapRetrievalResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("date"u8); + writer.WriteStringValue(Date, "O"); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SimSwapRetrievalResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SimSwapRetrievalResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSimSwapRetrievalResult(document.RootElement, options); + } + + internal static SimSwapRetrievalResult DeserializeSimSwapRetrievalResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset date = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("date"u8)) + { + date = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SimSwapRetrievalResult(date, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SimSwapRetrievalResult)} does not support '{options.Format}' format."); + } + } + + SimSwapRetrievalResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSimSwapRetrievalResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SimSwapRetrievalResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SimSwapRetrievalResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSimSwapRetrievalResult(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalResult.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalResult.cs new file mode 100644 index 0000000000000..d43be9ddf0aad --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapRetrievalResult.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Response with SimSwap date. + public partial class SimSwapRetrievalResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Datetime of most recent swap for SIM. + internal SimSwapRetrievalResult(DateTimeOffset date) + { + Date = date; + } + + /// Initializes a new instance of . + /// Datetime of most recent swap for SIM. + /// Keeps track of any properties unknown to the library. + internal SimSwapRetrievalResult(DateTimeOffset date, IDictionary serializedAdditionalRawData) + { + Date = date; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SimSwapRetrievalResult() + { + } + + /// Datetime of most recent swap for SIM. + public DateTimeOffset Date { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationContent.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationContent.Serialization.cs new file mode 100644 index 0000000000000..5344b1ab6bdd8 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationContent.Serialization.cs @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class SimSwapVerificationContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SimSwapVerificationContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(PhoneNumber)) + { + writer.WritePropertyName("phoneNumber"u8); + writer.WriteStringValue(PhoneNumber); + } + if (Optional.IsDefined(MaxAgeHours)) + { + writer.WritePropertyName("maxAgeHours"u8); + writer.WriteNumberValue(MaxAgeHours.Value); + } + writer.WritePropertyName("networkIdentifier"u8); + writer.WriteObjectValue(NetworkIdentifier); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SimSwapVerificationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SimSwapVerificationContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSimSwapVerificationContent(document.RootElement, options); + } + + internal static SimSwapVerificationContent DeserializeSimSwapVerificationContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional phoneNumber = default; + Optional maxAgeHours = default; + NetworkIdentifier networkIdentifier = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("phoneNumber"u8)) + { + phoneNumber = property.Value.GetString(); + continue; + } + if (property.NameEquals("maxAgeHours"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxAgeHours = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("networkIdentifier"u8)) + { + networkIdentifier = NetworkIdentifier.DeserializeNetworkIdentifier(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SimSwapVerificationContent(phoneNumber.Value, Optional.ToNullable(maxAgeHours), networkIdentifier, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SimSwapVerificationContent)} does not support '{options.Format}' format."); + } + } + + SimSwapVerificationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSimSwapVerificationContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SimSwapVerificationContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SimSwapVerificationContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSimSwapVerificationContent(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationContent.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationContent.cs new file mode 100644 index 0000000000000..d79531b07a0ca --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationContent.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Request to verify SimSwap in period. + public partial class SimSwapVerificationContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Identifier for the network to query for this device. + /// is null. + public SimSwapVerificationContent(NetworkIdentifier networkIdentifier) + { + Argument.AssertNotNull(networkIdentifier, nameof(networkIdentifier)); + + NetworkIdentifier = networkIdentifier; + } + + /// Initializes a new instance of . + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + /// Maximum lookback for SimSwap verification. + /// Identifier for the network to query for this device. + /// Keeps track of any properties unknown to the library. + internal SimSwapVerificationContent(string phoneNumber, int? maxAgeHours, NetworkIdentifier networkIdentifier, IDictionary serializedAdditionalRawData) + { + PhoneNumber = phoneNumber; + MaxAgeHours = maxAgeHours; + NetworkIdentifier = networkIdentifier; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SimSwapVerificationContent() + { + } + + /// Phone number in E.164 format (starting with country code), and optionally prefixed with '+'. + public string PhoneNumber { get; set; } + /// Maximum lookback for SimSwap verification. + public int? MaxAgeHours { get; set; } + /// Identifier for the network to query for this device. + public NetworkIdentifier NetworkIdentifier { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationResult.Serialization.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationResult.Serialization.cs new file mode 100644 index 0000000000000..db18f820109e7 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationResult.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.Communication.ProgrammableConnectivity +{ + public partial class SimSwapVerificationResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SimSwapVerificationResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("verificationResult"u8); + writer.WriteBooleanValue(VerificationResult); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SimSwapVerificationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SimSwapVerificationResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSimSwapVerificationResult(document.RootElement, options); + } + + internal static SimSwapVerificationResult DeserializeSimSwapVerificationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool verificationResult = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("verificationResult"u8)) + { + verificationResult = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SimSwapVerificationResult(verificationResult, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SimSwapVerificationResult)} does not support '{options.Format}' format."); + } + } + + SimSwapVerificationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSimSwapVerificationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SimSwapVerificationResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SimSwapVerificationResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSimSwapVerificationResult(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationResult.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationResult.cs new file mode 100644 index 0000000000000..b10fbb9d29f42 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Generated/SimSwapVerificationResult.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Communication.ProgrammableConnectivity +{ + /// Response verifying SimSwap in period. + public partial class SimSwapVerificationResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// True if the SIM has swapped in the specified period, False otherwise. + internal SimSwapVerificationResult(bool verificationResult) + { + VerificationResult = verificationResult; + } + + /// Initializes a new instance of . + /// True if the SIM has swapped in the specified period, False otherwise. + /// Keeps track of any properties unknown to the library. + internal SimSwapVerificationResult(bool verificationResult, IDictionary serializedAdditionalRawData) + { + VerificationResult = verificationResult; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SimSwapVerificationResult() + { + } + + /// True if the SIM has swapped in the specified period, False otherwise. + public bool VerificationResult { get; } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Properties/AssemblyInfo.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..6c0244ae17786 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.Communication.ProgrammableConnectivity.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Azure.Communication.ProgrammableConnectivity.Tests.csproj b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Azure.Communication.ProgrammableConnectivity.Tests.csproj new file mode 100644 index 0000000000000..4f7e5f50fc342 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Azure.Communication.ProgrammableConnectivity.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_DeviceLocation.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_DeviceLocation.cs new file mode 100644 index 0000000000000..64038f2663a84 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_DeviceLocation.cs @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.Communication.ProgrammableConnectivity; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.Communication.ProgrammableConnectivity.Samples +{ + public partial class Samples_DeviceLocation + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeviceLocation_Verify_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + latitude = 123.45, + longitude = 123.45, + accuracy = 1234, + locationDevice = new object(), + }); + Response response = client.Verify("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeviceLocation_Verify_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + latitude = 123.45, + longitude = 123.45, + accuracy = 1234, + locationDevice = new object(), + }); + Response response = await client.VerifyAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeviceLocation_Verify_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + + DeviceLocationVerificationContent deviceLocationVerificationContent = new DeviceLocationVerificationContent(new NetworkIdentifier("", ""), 123.45, 123.45, 1234, new LocationDevice()); + Response response = client.Verify("", deviceLocationVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeviceLocation_Verify_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + + DeviceLocationVerificationContent deviceLocationVerificationContent = new DeviceLocationVerificationContent(new NetworkIdentifier("", ""), 123.45, 123.45, 1234, new LocationDevice()); + Response response = await client.VerifyAsync("", deviceLocationVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeviceLocation_Verify_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + latitude = 123.45, + longitude = 123.45, + accuracy = 1234, + locationDevice = new + { + networkAccessIdentifier = "", + phoneNumber = "", + ipv4Address = new + { + ipv4 = "", + port = 1234, + }, + ipv6Address = new + { + ipv6 = "", + port = 1234, + }, + }, + }); + Response response = client.Verify("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeviceLocation_Verify_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + latitude = 123.45, + longitude = 123.45, + accuracy = 1234, + locationDevice = new + { + networkAccessIdentifier = "", + phoneNumber = "", + ipv4Address = new + { + ipv4 = "", + port = 1234, + }, + ipv6Address = new + { + ipv6 = "", + port = 1234, + }, + }, + }); + Response response = await client.VerifyAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeviceLocation_Verify_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + + DeviceLocationVerificationContent deviceLocationVerificationContent = new DeviceLocationVerificationContent(new NetworkIdentifier("", ""), 123.45, 123.45, 1234, new LocationDevice + { + NetworkAccessIdentifier = "", + PhoneNumber = "", + Ipv4Address = new Ipv4Address("", 1234), + Ipv6Address = new Ipv6Address("", 1234), + }); + Response response = client.Verify("", deviceLocationVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeviceLocation_Verify_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceLocation client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceLocationClient(apiVersion: "v2024_01_09_preview"); + + DeviceLocationVerificationContent deviceLocationVerificationContent = new DeviceLocationVerificationContent(new NetworkIdentifier("", ""), 123.45, 123.45, 1234, new LocationDevice + { + NetworkAccessIdentifier = "", + PhoneNumber = "", + Ipv4Address = new Ipv4Address("", 1234), + Ipv6Address = new Ipv6Address("", 1234), + }); + Response response = await client.VerifyAsync("", deviceLocationVerificationContent); + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_DeviceNetwork.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_DeviceNetwork.cs new file mode 100644 index 0000000000000..1d429ee3f148d --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_DeviceNetwork.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.Communication.ProgrammableConnectivity; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.Communication.ProgrammableConnectivity.Samples +{ + public partial class Samples_DeviceNetwork + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeviceNetwork_Retrieve_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + identifierType = "", + identifier = "", + }); + Response response = client.Retrieve("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("networkCode").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeviceNetwork_Retrieve_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + identifierType = "", + identifier = "", + }); + Response response = await client.RetrieveAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("networkCode").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeviceNetwork_Retrieve_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + + NetworkIdentifier networkIdentifier = new NetworkIdentifier("", ""); + Response response = client.Retrieve("", networkIdentifier); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeviceNetwork_Retrieve_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + + NetworkIdentifier networkIdentifier = new NetworkIdentifier("", ""); + Response response = await client.RetrieveAsync("", networkIdentifier); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeviceNetwork_Retrieve_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + identifierType = "", + identifier = "", + }); + Response response = client.Retrieve("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("networkCode").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeviceNetwork_Retrieve_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + identifierType = "", + identifier = "", + }); + Response response = await client.RetrieveAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("networkCode").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_DeviceNetwork_Retrieve_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + + NetworkIdentifier networkIdentifier = new NetworkIdentifier("", ""); + Response response = client.Retrieve("", networkIdentifier); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_DeviceNetwork_Retrieve_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + DeviceNetwork client = new ProgrammableConnectivityClient(endpoint, credential).GetDeviceNetworkClient(apiVersion: "v2024_01_09_preview"); + + NetworkIdentifier networkIdentifier = new NetworkIdentifier("", ""); + Response response = await client.RetrieveAsync("", networkIdentifier); + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_NumberVerification.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_NumberVerification.cs new file mode 100644 index 0000000000000..59bd69a5fd87e --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_NumberVerification.cs @@ -0,0 +1,613 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.Communication.ProgrammableConnectivity; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.Communication.ProgrammableConnectivity.Samples +{ + public partial class Samples_NumberVerification + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_VerifyWithoutCode_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = client.VerifyWithoutCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_VerifyWithoutCode_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = await client.VerifyWithoutCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_VerifyWithoutCode_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")); + Response response = client.VerifyWithoutCode("", numberVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_VerifyWithoutCode_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")); + Response response = await client.VerifyWithoutCodeAsync("", numberVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_VerifyWithoutCode_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + phoneNumber = "", + hashedPhoneNumber = "", + apcCode = "", + }); + Response response = client.VerifyWithoutCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("content").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_VerifyWithoutCode_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + phoneNumber = "", + hashedPhoneNumber = "", + apcCode = "", + }); + Response response = await client.VerifyWithoutCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("content").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_VerifyWithoutCode_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")) + { + PhoneNumber = "", + HashedPhoneNumber = "", + ApcCode = "", + }; + Response response = client.VerifyWithoutCode("", numberVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_VerifyWithoutCode_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")) + { + PhoneNumber = "", + HashedPhoneNumber = "", + ApcCode = "", + }; + Response response = await client.VerifyWithoutCodeAsync("", numberVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_VerifyWithCode_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = client.VerifyWithCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_VerifyWithCode_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = await client.VerifyWithCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_VerifyWithCode_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")); + Response response = client.VerifyWithCode("", numberVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_VerifyWithCode_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")); + Response response = await client.VerifyWithCodeAsync("", numberVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_VerifyWithCode_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + phoneNumber = "", + hashedPhoneNumber = "", + apcCode = "", + }); + Response response = client.VerifyWithCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_VerifyWithCode_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + phoneNumber = "", + hashedPhoneNumber = "", + apcCode = "", + }); + Response response = await client.VerifyWithCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_VerifyWithCode_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")) + { + PhoneNumber = "", + HashedPhoneNumber = "", + ApcCode = "", + }; + Response response = client.VerifyWithCode("", numberVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_VerifyWithCode_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberVerificationContent numberVerificationContent = new NumberVerificationContent(new NetworkIdentifier("", "")) + { + PhoneNumber = "", + HashedPhoneNumber = "", + ApcCode = "", + }; + Response response = await client.VerifyWithCodeAsync("", numberVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_RetrieveWithoutCode_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = client.RetrieveWithoutCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_RetrieveWithoutCode_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = await client.RetrieveWithoutCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_RetrieveWithoutCode_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")); + Response response = client.RetrieveWithoutCode("", numberRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_RetrieveWithoutCode_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")); + Response response = await client.RetrieveWithoutCodeAsync("", numberRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_RetrieveWithoutCode_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + apcCode = "", + }); + Response response = client.RetrieveWithoutCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("content").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_RetrieveWithoutCode_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + apcCode = "", + }); + Response response = await client.RetrieveWithoutCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("content").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_RetrieveWithoutCode_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")) + { + ApcCode = "", + }; + Response response = client.RetrieveWithoutCode("", numberRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_RetrieveWithoutCode_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")) + { + ApcCode = "", + }; + Response response = await client.RetrieveWithoutCodeAsync("", numberRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_RetrieveWithCode_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = client.RetrieveWithCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("phoneNumber").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_RetrieveWithCode_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = await client.RetrieveWithCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("phoneNumber").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_RetrieveWithCode_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")); + Response response = client.RetrieveWithCode("", numberRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_RetrieveWithCode_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")); + Response response = await client.RetrieveWithCodeAsync("", numberRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_RetrieveWithCode_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + apcCode = "", + }); + Response response = client.RetrieveWithCode("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("phoneNumber").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_RetrieveWithCode_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + apcCode = "", + }); + Response response = await client.RetrieveWithCodeAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("phoneNumber").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_NumberVerification_RetrieveWithCode_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")) + { + ApcCode = "", + }; + Response response = client.RetrieveWithCode("", numberRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_NumberVerification_RetrieveWithCode_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + NumberVerification client = new ProgrammableConnectivityClient(endpoint, credential).GetNumberVerificationClient(apiVersion: "v2024_01_09_preview"); + + NumberRetrievalContent numberRetrievalContent = new NumberRetrievalContent(new NetworkIdentifier("", "")) + { + ApcCode = "", + }; + Response response = await client.RetrieveWithCodeAsync("", numberRetrievalContent); + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_SimSwap.cs b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_SimSwap.cs new file mode 100644 index 0000000000000..89493aaa21f80 --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tests/Generated/Samples/Samples_SimSwap.cs @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.Communication.ProgrammableConnectivity; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.Communication.ProgrammableConnectivity.Samples +{ + public partial class Samples_SimSwap + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SimSwap_Retrieve_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = client.Retrieve("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("date").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SimSwap_Retrieve_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = await client.RetrieveAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("date").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SimSwap_Retrieve_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + SimSwapRetrievalContent simSwapRetrievalContent = new SimSwapRetrievalContent(new NetworkIdentifier("", "")); + Response response = client.Retrieve("", simSwapRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SimSwap_Retrieve_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + SimSwapRetrievalContent simSwapRetrievalContent = new SimSwapRetrievalContent(new NetworkIdentifier("", "")); + Response response = await client.RetrieveAsync("", simSwapRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SimSwap_Retrieve_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + phoneNumber = "", + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = client.Retrieve("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("date").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SimSwap_Retrieve_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + phoneNumber = "", + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = await client.RetrieveAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("date").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SimSwap_Retrieve_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + SimSwapRetrievalContent simSwapRetrievalContent = new SimSwapRetrievalContent(new NetworkIdentifier("", "")) + { + PhoneNumber = "", + }; + Response response = client.Retrieve("", simSwapRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SimSwap_Retrieve_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + SimSwapRetrievalContent simSwapRetrievalContent = new SimSwapRetrievalContent(new NetworkIdentifier("", "")) + { + PhoneNumber = "", + }; + Response response = await client.RetrieveAsync("", simSwapRetrievalContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SimSwap_Verify_ShortVersion() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = client.Verify("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SimSwap_Verify_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = await client.VerifyAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SimSwap_Verify_ShortVersion_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + SimSwapVerificationContent simSwapVerificationContent = new SimSwapVerificationContent(new NetworkIdentifier("", "")); + Response response = client.Verify("", simSwapVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SimSwap_Verify_ShortVersion_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + SimSwapVerificationContent simSwapVerificationContent = new SimSwapVerificationContent(new NetworkIdentifier("", "")); + Response response = await client.VerifyAsync("", simSwapVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SimSwap_Verify_AllParameters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + phoneNumber = "", + maxAgeHours = 1234, + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = client.Verify("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SimSwap_Verify_AllParameters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + using RequestContent content = RequestContent.Create(new + { + phoneNumber = "", + maxAgeHours = 1234, + networkIdentifier = new + { + identifierType = "", + identifier = "", + }, + }); + Response response = await client.VerifyAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("verificationResult").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SimSwap_Verify_AllParameters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + SimSwapVerificationContent simSwapVerificationContent = new SimSwapVerificationContent(new NetworkIdentifier("", "")) + { + PhoneNumber = "", + MaxAgeHours = 1234, + }; + Response response = client.Verify("", simSwapVerificationContent); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SimSwap_Verify_AllParameters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + SimSwap client = new ProgrammableConnectivityClient(endpoint, credential).GetSimSwapClient(apiVersion: "v2024_01_09_preview"); + + SimSwapVerificationContent simSwapVerificationContent = new SimSwapVerificationContent(new NetworkIdentifier("", "")) + { + PhoneNumber = "", + MaxAgeHours = 1234, + }; + Response response = await client.VerifyAsync("", simSwapVerificationContent); + } + } +} diff --git a/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tsp-location.yaml b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tsp-location.yaml new file mode 100644 index 0000000000000..16126be8a0e6b --- /dev/null +++ b/sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity/tsp-location.yaml @@ -0,0 +1,5 @@ +directory: specification/programmableconnectivity/Azure.ProgrammableConnectivity +repo: Azure/azure-rest-api-specs +additionalDirectories: [] +commit: 0598dffad76fccca04023cdca0433e6497c3719f + diff --git a/sdk/programmableconnectivity/ci.yml b/sdk/programmableconnectivity/ci.yml new file mode 100644 index 0000000000000..aeb7233b0c5ff --- /dev/null +++ b/sdk/programmableconnectivity/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/programmableconnectivity + - sdk/programmableconnectivity/ci.yml + - sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/programmableconnectivity + - sdk/programmableconnectivity/ci.yml + - sdk/programmableconnectivity/Azure.Communication.ProgrammableConnectivity + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: programmableconnectivity + ArtifactName: packages + Artifacts: + - name: Azure.Communication.ProgrammableConnectivity + safeName: AzureCommunicationProgrammableConnectivity