<gh_stars>0// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// <auto-generated/>

#nullable disable

using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;

namespace Microsoft.Azure.NotificationHubs
{
    // Data plane generated client. Azure Notification Hubs registration description operations
    /// <summary> Azure Notification Hubs registration description operations. </summary>
    public partial class RegistrationsClient
    {
        private readonly HttpPipeline _pipeline;
        private readonly string _namespaceName;
        private readonly string _hubName;
        private readonly string _apiVersion;

        /// <summary> The ClientDiagnostics is used to provide tracing support for the client library. </summary>
        internal ClientDiagnostics ClientDiagnostics { get; }

        /// <summary> The HTTP pipeline for sending and receiving REST requests and responses. </summary>
        public virtual HttpPipeline Pipeline => _pipeline;

        /// <summary> Initializes a new instance of RegistrationsClient for mocking. </summary>
        protected RegistrationsClient()
        {
        }

        /// <summary> Initializes a new instance of RegistrationsClient. </summary>
        /// <param name="namespaceName"> Notification Hubs Namespace. </param>
        /// <param name="hubName"> Notification Hub Name. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="namespaceName"/> or <paramref name="hubName"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="namespaceName"/> or <paramref name="hubName"/> is an empty string, and was expected to be non-empty. </exception>
        public RegistrationsClient(string namespaceName, string hubName) : this(namespaceName, hubName, new NotificationhubsClientOptions())
        {
        }

        /// <summary> Initializes a new instance of RegistrationsClient. </summary>
        /// <param name="namespaceName"> Notification Hubs Namespace. </param>
        /// <param name="hubName"> Notification Hub Name. </param>
        /// <param name="options"> The options for configuring the client. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="namespaceName"/> or <paramref name="hubName"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="namespaceName"/> or <paramref name="hubName"/> is an empty string, and was expected to be non-empty. </exception>
        public RegistrationsClient(string namespaceName, string hubName, NotificationhubsClientOptions options)
        {
            Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName));
            Argument.AssertNotNullOrEmpty(hubName, nameof(hubName));
            options ??= new NotificationhubsClientOptions();

            ClientDiagnostics = new ClientDiagnostics(options, true);
            _pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), Array.Empty<HttpPipelinePolicy>(), new ResponseClassifier());
            _namespaceName = namespaceName;
            _hubName = hubName;
            _apiVersion = options.Version;
        }

        /// <summary> Create an Azure Notification Hubs registration description. </summary>
        /// <param name="content"> The content to send as the body of the request. Details of the request body schema are in the Remarks section below. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
        /// <example>
        /// This sample shows how to call CreateAsync and parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {};
        /// 
        /// Response response = await client.CreateAsync(RequestContent.Create(data));
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.ToString());
        /// ]]></code>
        /// This sample shows how to call CreateAsync with all request content, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {
        ///     registrationId = "<registrationId>",
        ///     tags = "<tags>",
        ///     etag = "<etag>",
        ///     pushVariables = new {
        ///         key = "<String>",
        ///     },
        ///     expirationTime = "2022-05-10T14:57:31.2311892-04:00",
        /// };
        /// 
        /// Response response = await client.CreateAsync(RequestContent.Create(data));
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("registrationId").ToString());
        /// Console.WriteLine(result.GetProperty("tags").ToString());
        /// Console.WriteLine(result.GetProperty("etag").ToString());
        /// Console.WriteLine(result.GetProperty("pushVariables").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("expirationTime").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the request and response payloads.
        /// 
        /// Request Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual async Task<Response> CreateAsync(RequestContent content, RequestContext context = null)
        {
            Argument.AssertNotNull(content, nameof(content));

            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.Create");
            scope.Start();
            try
            {
                using HttpMessage message = CreateCreateRequest(content, context);
                return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> Create an Azure Notification Hubs registration description. </summary>
        /// <param name="content"> The content to send as the body of the request. Details of the request body schema are in the Remarks section below. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
        /// <example>
        /// This sample shows how to call Create and parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {};
        /// 
        /// Response response = client.Create(RequestContent.Create(data));
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.ToString());
        /// ]]></code>
        /// This sample shows how to call Create with all request content, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {
        ///     registrationId = "<registrationId>",
        ///     tags = "<tags>",
        ///     etag = "<etag>",
        ///     pushVariables = new {
        ///         key = "<String>",
        ///     },
        ///     expirationTime = "2022-05-10T14:57:31.2311892-04:00",
        /// };
        /// 
        /// Response response = client.Create(RequestContent.Create(data));
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("registrationId").ToString());
        /// Console.WriteLine(result.GetProperty("tags").ToString());
        /// Console.WriteLine(result.GetProperty("etag").ToString());
        /// Console.WriteLine(result.GetProperty("pushVariables").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("expirationTime").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the request and response payloads.
        /// 
        /// Request Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual Response Create(RequestContent content, RequestContext context = null)
        {
            Argument.AssertNotNull(content, nameof(content));

            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.Create");
            scope.Start();
            try
            {
                using HttpMessage message = CreateCreateRequest(content, context);
                return _pipeline.ProcessMessage(message, context);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> Create or update an Azure Notification Hubs registration description. </summary>
        /// <param name="registrationId"> The registration ID. </param>
        /// <param name="content"> The content to send as the body of the request. Details of the request body schema are in the Remarks section below. </param>
        /// <param name="eTag"> The If-Match HTTP header. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="registrationId"/> or <paramref name="content"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="registrationId"/> is an empty string, and was expected to be non-empty. </exception>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
        /// <example>
        /// This sample shows how to call CreateOrUpdateAsync with required parameters and parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {};
        /// 
        /// Response response = await client.CreateOrUpdateAsync("<registrationId>", RequestContent.Create(data));
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.ToString());
        /// ]]></code>
        /// This sample shows how to call CreateOrUpdateAsync with all parameters and request content, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {
        ///     registrationId = "<registrationId>",
        ///     tags = "<tags>",
        ///     etag = "<etag>",
        ///     pushVariables = new {
        ///         key = "<String>",
        ///     },
        ///     expirationTime = "2022-05-10T14:57:31.2311892-04:00",
        /// };
        /// 
        /// Response response = await client.CreateOrUpdateAsync("<registrationId>", RequestContent.Create(data), null);
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("registrationId").ToString());
        /// Console.WriteLine(result.GetProperty("tags").ToString());
        /// Console.WriteLine(result.GetProperty("etag").ToString());
        /// Console.WriteLine(result.GetProperty("pushVariables").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("expirationTime").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the request and response payloads.
        /// 
        /// Request Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual async Task<Response> CreateOrUpdateAsync(string registrationId, RequestContent content, ETag? eTag = null, RequestContext context = null)
        {
            Argument.AssertNotNullOrEmpty(registrationId, nameof(registrationId));
            Argument.AssertNotNull(content, nameof(content));

            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.CreateOrUpdate");
            scope.Start();
            try
            {
                using HttpMessage message = CreateCreateOrUpdateRequest(registrationId, content, eTag, context);
                return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> Create or update an Azure Notification Hubs registration description. </summary>
        /// <param name="registrationId"> The registration ID. </param>
        /// <param name="content"> The content to send as the body of the request. Details of the request body schema are in the Remarks section below. </param>
        /// <param name="eTag"> The If-Match HTTP header. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="registrationId"/> or <paramref name="content"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="registrationId"/> is an empty string, and was expected to be non-empty. </exception>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
        /// <example>
        /// This sample shows how to call CreateOrUpdate with required parameters and parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {};
        /// 
        /// Response response = client.CreateOrUpdate("<registrationId>", RequestContent.Create(data));
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.ToString());
        /// ]]></code>
        /// This sample shows how to call CreateOrUpdate with all parameters and request content, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {
        ///     registrationId = "<registrationId>",
        ///     tags = "<tags>",
        ///     etag = "<etag>",
        ///     pushVariables = new {
        ///         key = "<String>",
        ///     },
        ///     expirationTime = "2022-05-10T14:57:31.2311892-04:00",
        /// };
        /// 
        /// Response response = client.CreateOrUpdate("<registrationId>", RequestContent.Create(data), null);
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("registrationId").ToString());
        /// Console.WriteLine(result.GetProperty("tags").ToString());
        /// Console.WriteLine(result.GetProperty("etag").ToString());
        /// Console.WriteLine(result.GetProperty("pushVariables").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("expirationTime").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the request and response payloads.
        /// 
        /// Request Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual Response CreateOrUpdate(string registrationId, RequestContent content, ETag? eTag = null, RequestContext context = null)
        {
            Argument.AssertNotNullOrEmpty(registrationId, nameof(registrationId));
            Argument.AssertNotNull(content, nameof(content));

            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.CreateOrUpdate");
            scope.Start();
            try
            {
                using HttpMessage message = CreateCreateOrUpdateRequest(registrationId, content, eTag, context);
                return _pipeline.ProcessMessage(message, context);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> Delete an Azure Notification Hubs registration description. </summary>
        /// <param name="registrationId"> The registration ID. </param>
        /// <param name="eTag"> The If-Match HTTP header. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="registrationId"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="registrationId"/> is an empty string, and was expected to be non-empty. </exception>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. </returns>
        /// <example>
        /// This sample shows how to call DeleteAsync with required parameters.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = await client.DeleteAsync("<registrationId>");
        /// Console.WriteLine(response.Status);
        /// ]]></code>
        /// This sample shows how to call DeleteAsync with all parameters.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = await client.DeleteAsync("<registrationId>", null);
        /// Console.WriteLine(response.Status);
        /// ]]></code>
        /// </example>
        public virtual async Task<Response> DeleteAsync(string registrationId, ETag? eTag = null, RequestContext context = null)
        {
            Argument.AssertNotNullOrEmpty(registrationId, nameof(registrationId));

            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.Delete");
            scope.Start();
            try
            {
                using HttpMessage message = CreateDeleteRequest(registrationId, eTag, context);
                return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> Delete an Azure Notification Hubs registration description. </summary>
        /// <param name="registrationId"> The registration ID. </param>
        /// <param name="eTag"> The If-Match HTTP header. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="registrationId"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="registrationId"/> is an empty string, and was expected to be non-empty. </exception>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. </returns>
        /// <example>
        /// This sample shows how to call Delete with required parameters.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = client.Delete("<registrationId>");
        /// Console.WriteLine(response.Status);
        /// ]]></code>
        /// This sample shows how to call Delete with all parameters.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = client.Delete("<registrationId>", null);
        /// Console.WriteLine(response.Status);
        /// ]]></code>
        /// </example>
        public virtual Response Delete(string registrationId, ETag? eTag = null, RequestContext context = null)
        {
            Argument.AssertNotNullOrEmpty(registrationId, nameof(registrationId));

            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.Delete");
            scope.Start();
            try
            {
                using HttpMessage message = CreateDeleteRequest(registrationId, eTag, context);
                return _pipeline.ProcessMessage(message, context);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> Get an Azure Notification Hubs registration description. </summary>
        /// <param name="registrationId"> The registration ID. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="registrationId"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="registrationId"/> is an empty string, and was expected to be non-empty. </exception>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
        /// <example>
        /// This sample shows how to call GetAsync with required parameters and parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = await client.GetAsync("<registrationId>");
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("registrationId").ToString());
        /// Console.WriteLine(result.GetProperty("tags").ToString());
        /// Console.WriteLine(result.GetProperty("etag").ToString());
        /// Console.WriteLine(result.GetProperty("pushVariables").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("expirationTime").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the response payload.
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual async Task<Response> GetAsync(string registrationId, RequestContext context = null)
        {
            Argument.AssertNotNullOrEmpty(registrationId, nameof(registrationId));

            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.Get");
            scope.Start();
            try
            {
                using HttpMessage message = CreateGetRequest(registrationId, context);
                return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> Get an Azure Notification Hubs registration description. </summary>
        /// <param name="registrationId"> The registration ID. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="registrationId"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="registrationId"/> is an empty string, and was expected to be non-empty. </exception>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
        /// <example>
        /// This sample shows how to call Get with required parameters and parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = client.Get("<registrationId>");
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("registrationId").ToString());
        /// Console.WriteLine(result.GetProperty("tags").ToString());
        /// Console.WriteLine(result.GetProperty("etag").ToString());
        /// Console.WriteLine(result.GetProperty("pushVariables").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("expirationTime").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the response payload.
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual Response Get(string registrationId, RequestContext context = null)
        {
            Argument.AssertNotNullOrEmpty(registrationId, nameof(registrationId));

            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.Get");
            scope.Start();
            try
            {
                using HttpMessage message = CreateGetRequest(registrationId, context);
                return _pipeline.ProcessMessage(message, context);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> List Azure Notification Hubs registration descriptions. </summary>
        /// <param name="top"> The limit to the number of records to retrieve. </param>
        /// <param name="filter"> The filter query to find registrations. </param>
        /// <param name="continuationToken"> The continuation token for more results. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
        /// <example>
        /// This sample shows how to call ListAsync and parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = await client.ListAsync();
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result[0].ToString());
        /// ]]></code>
        /// This sample shows how to call ListAsync with all parameters, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = await client.ListAsync("<top>", "<filter>", "<continuationToken>");
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result[0].GetProperty("registrationId").ToString());
        /// Console.WriteLine(result[0].GetProperty("tags").ToString());
        /// Console.WriteLine(result[0].GetProperty("etag").ToString());
        /// Console.WriteLine(result[0].GetProperty("pushVariables").GetProperty("<test>").ToString());
        /// Console.WriteLine(result[0].GetProperty("expirationTime").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the response payload.
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual async Task<Response> ListAsync(string top = null, string filter = null, string continuationToken = null, RequestContext context = null)
        {
            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.List");
            scope.Start();
            try
            {
                using HttpMessage message = CreateListRequest(top, filter, continuationToken, context);
                return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> List Azure Notification Hubs registration descriptions. </summary>
        /// <param name="top"> The limit to the number of records to retrieve. </param>
        /// <param name="filter"> The filter query to find registrations. </param>
        /// <param name="continuationToken"> The continuation token for more results. </param>
        /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
        /// <example>
        /// This sample shows how to call List and parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = client.List();
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result[0].ToString());
        /// ]]></code>
        /// This sample shows how to call List with all parameters, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new RegistrationsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = client.List("<top>", "<filter>", "<continuationToken>");
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result[0].GetProperty("registrationId").ToString());
        /// Console.WriteLine(result[0].GetProperty("tags").ToString());
        /// Console.WriteLine(result[0].GetProperty("etag").ToString());
        /// Console.WriteLine(result[0].GetProperty("pushVariables").GetProperty("<test>").ToString());
        /// Console.WriteLine(result[0].GetProperty("expirationTime").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the response payload.
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>RegistrationDescription</c>:
        /// <code>{
        ///   registrationId: string, # Optional.
        ///   tags: string, # Optional.
        ///   etag: string, # Optional.
        ///   pushVariables: Dictionary&lt;string, string&gt;, # Optional.
        ///   expirationTime: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual Response List(string top = null, string filter = null, string continuationToken = null, RequestContext context = null)
        {
            using var scope = ClientDiagnostics.CreateScope("RegistrationsClient.List");
            scope.Start();
            try
            {
                using HttpMessage message = CreateListRequest(top, filter, continuationToken, context);
                return _pipeline.ProcessMessage(message, context);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        internal HttpMessage CreateCreateRequest(RequestContent content, RequestContext context)
        {
            var message = _pipeline.CreateMessage(context, ResponseClassifier201);
            var request = message.Request;
            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw("https://", false);
            uri.AppendRaw(_namespaceName, true);
            uri.AppendRaw(".servicebus.windows.net/", false);
            uri.AppendRaw(_hubName, true);
            uri.AppendPath("/registrations", false);
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
            request.Content = content;
            return message;
        }

        internal HttpMessage CreateCreateOrUpdateRequest(string registrationId, RequestContent content, ETag? eTag, RequestContext context)
        {
            var message = _pipeline.CreateMessage(context, ResponseClassifier201);
            var request = message.Request;
            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw("https://", false);
            uri.AppendRaw(_namespaceName, true);
            uri.AppendRaw(".servicebus.windows.net/", false);
            uri.AppendRaw(_hubName, true);
            uri.AppendPath("/registrations/", false);
            uri.AppendPath(registrationId, true);
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            if (eTag != null)
            {
                request.Headers.Add("If-Match", eTag.Value);
            }
            request.Headers.Add("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
            request.Content = content;
            return message;
        }

        internal HttpMessage CreateDeleteRequest(string registrationId, ETag? eTag, RequestContext context)
        {
            var message = _pipeline.CreateMessage(context, ResponseClassifier200);
            var request = message.Request;
            request.Method = RequestMethod.Delete;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw("https://", false);
            uri.AppendRaw(_namespaceName, true);
            uri.AppendRaw(".servicebus.windows.net/", false);
            uri.AppendRaw(_hubName, true);
            uri.AppendPath("/registrations/", false);
            uri.AppendPath(registrationId, true);
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            if (eTag != null)
            {
                request.Headers.Add("If-Match", eTag.Value);
            }
            return message;
        }

        internal HttpMessage CreateGetRequest(string registrationId, RequestContext context)
        {
            var message = _pipeline.CreateMessage(context, ResponseClassifier200);
            var request = message.Request;
            request.Method = RequestMethod.Get;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw("https://", false);
            uri.AppendRaw(_namespaceName, true);
            uri.AppendRaw(".servicebus.windows.net/", false);
            uri.AppendRaw(_hubName, true);
            uri.AppendPath("/registrations/", false);
            uri.AppendPath(registrationId, true);
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            return message;
        }

        internal HttpMessage CreateListRequest(string top, string filter, string continuationToken, RequestContext context)
        {
            var message = _pipeline.CreateMessage(context, ResponseClassifier200);
            var request = message.Request;
            request.Method = RequestMethod.Get;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw("https://", false);
            uri.AppendRaw(_namespaceName, true);
            uri.AppendRaw(".servicebus.windows.net/", false);
            uri.AppendRaw(_hubName, true);
            uri.AppendPath("/registrations", false);
            if (top != null)
            {
                uri.AppendQuery("$top", top, true);
            }
            if (filter != null)
            {
                uri.AppendQuery("$fitler", filter, true);
            }
            if (continuationToken != null)
            {
                uri.AppendQuery("continuationToken", continuationToken, true);
            }
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            return message;
        }

        private static ResponseClassifier _responseClassifier201;
        private static ResponseClassifier ResponseClassifier201 => _responseClassifier201 ??= new StatusCodeClassifier(stackalloc ushort[] { 201 });
        private static ResponseClassifier _responseClassifier200;
        private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 });
    }
}
