// 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 import and export job operations
    /// <summary> Azure Notification Hubs import and export job operations. </summary>
    public partial class NotificationHubJobsClient
    {
        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 NotificationHubJobsClient for mocking. </summary>
        protected NotificationHubJobsClient()
        {
        }

        /// <summary> Initializes a new instance of NotificationHubJobsClient. </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 NotificationHubJobsClient(string namespaceName, string hubName) : this(namespaceName, hubName, new NotificationhubsClientOptions())
        {
        }

        /// <summary> Initializes a new instance of NotificationHubJobsClient. </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 NotificationHubJobsClient(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 import/export Azure Notification Hubs job. </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 with required request content, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new NotificationHubJobsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {
        ///     type = "ExportRegistrations",
        ///     outputContainerUrl = "<outputContainerUrl>",
        /// };
        /// 
        /// Response response = await client.CreateAsync(RequestContent.Create(data));
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("type").ToString());
        /// Console.WriteLine(result.GetProperty("outputContainerUrl").ToString());
        /// ]]></code>
        /// This sample shows how to call CreateAsync with all request content, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new NotificationHubJobsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {
        ///     jobId = "<jobId>",
        ///     outputFileName = "<outputFileName>",
        ///     failuresFileName = "<failuresFileName>",
        ///     progress = 123.45d,
        ///     type = "ExportRegistrations",
        ///     status = "Started",
        ///     outputContainerUrl = "<outputContainerUrl>",
        ///     importFileUrl = "<importFileUrl>",
        ///     inputProperties = new {
        ///         key = "<String>",
        ///     },
        ///     failure = "<failure>",
        ///     outputProperties = new {
        ///         key = "<String>",
        ///     },
        ///     createdAt = "2022-05-10T14:57:31.2311892-04:00",
        ///     updatedAt = "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("jobId").ToString());
        /// Console.WriteLine(result.GetProperty("outputFileName").ToString());
        /// Console.WriteLine(result.GetProperty("failuresFileName").ToString());
        /// Console.WriteLine(result.GetProperty("progress").ToString());
        /// Console.WriteLine(result.GetProperty("type").ToString());
        /// Console.WriteLine(result.GetProperty("status").ToString());
        /// Console.WriteLine(result.GetProperty("outputContainerUrl").ToString());
        /// Console.WriteLine(result.GetProperty("importFileUrl").ToString());
        /// Console.WriteLine(result.GetProperty("inputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("failure").ToString());
        /// Console.WriteLine(result.GetProperty("outputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("createdAt").ToString());
        /// Console.WriteLine(result.GetProperty("updatedAt").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the request and response payloads.
        /// 
        /// Request Body:
        /// 
        /// Schema for <c>NotificationHubJob</c>:
        /// <code>{
        ///   jobId: string, # Optional.
        ///   outputFileName: string, # Optional.
        ///   failuresFileName: string, # Optional.
        ///   progress: number, # Optional.
        ///   type: &quot;ExportRegistrations&quot; | &quot;ImportCreateRegistrations&quot; | &quot;ImportUpdateRegistrations&quot; | &quot;ImportDeleteRegistrations&quot; | &quot;ImportUpsertRegistrations&quot;, # Required.
        ///   status: &quot;Started&quot; | &quot;Running&quot; | &quot;Completed&quot; | &quot;Failed&quot;, # Optional.
        ///   outputContainerUrl: string, # Required.
        ///   importFileUrl: string, # Optional.
        ///   inputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   failure: string, # Optional.
        ///   outputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   createdAt: string (date &amp; time), # Optional.
        ///   updatedAt: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>NotificationHubJob</c>:
        /// <code>{
        ///   jobId: string, # Optional.
        ///   outputFileName: string, # Optional.
        ///   failuresFileName: string, # Optional.
        ///   progress: number, # Optional.
        ///   type: &quot;ExportRegistrations&quot; | &quot;ImportCreateRegistrations&quot; | &quot;ImportUpdateRegistrations&quot; | &quot;ImportDeleteRegistrations&quot; | &quot;ImportUpsertRegistrations&quot;, # Required.
        ///   status: &quot;Started&quot; | &quot;Running&quot; | &quot;Completed&quot; | &quot;Failed&quot;, # Optional.
        ///   outputContainerUrl: string, # Required.
        ///   importFileUrl: string, # Optional.
        ///   inputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   failure: string, # Optional.
        ///   outputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   createdAt: string (date &amp; time), # Optional.
        ///   updatedAt: 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("NotificationHubJobsClient.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 import/export Azure Notification Hubs job. </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 with required request content, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new NotificationHubJobsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {
        ///     type = "ExportRegistrations",
        ///     outputContainerUrl = "<outputContainerUrl>",
        /// };
        /// 
        /// Response response = client.Create(RequestContent.Create(data));
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("type").ToString());
        /// Console.WriteLine(result.GetProperty("outputContainerUrl").ToString());
        /// ]]></code>
        /// This sample shows how to call Create with all request content, and how to parse the result.
        /// <code><![CDATA[
        /// var client = new NotificationHubJobsClient("<namespaceName>", "<hubName>");
        /// 
        /// var data = new {
        ///     jobId = "<jobId>",
        ///     outputFileName = "<outputFileName>",
        ///     failuresFileName = "<failuresFileName>",
        ///     progress = 123.45d,
        ///     type = "ExportRegistrations",
        ///     status = "Started",
        ///     outputContainerUrl = "<outputContainerUrl>",
        ///     importFileUrl = "<importFileUrl>",
        ///     inputProperties = new {
        ///         key = "<String>",
        ///     },
        ///     failure = "<failure>",
        ///     outputProperties = new {
        ///         key = "<String>",
        ///     },
        ///     createdAt = "2022-05-10T14:57:31.2311892-04:00",
        ///     updatedAt = "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("jobId").ToString());
        /// Console.WriteLine(result.GetProperty("outputFileName").ToString());
        /// Console.WriteLine(result.GetProperty("failuresFileName").ToString());
        /// Console.WriteLine(result.GetProperty("progress").ToString());
        /// Console.WriteLine(result.GetProperty("type").ToString());
        /// Console.WriteLine(result.GetProperty("status").ToString());
        /// Console.WriteLine(result.GetProperty("outputContainerUrl").ToString());
        /// Console.WriteLine(result.GetProperty("importFileUrl").ToString());
        /// Console.WriteLine(result.GetProperty("inputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("failure").ToString());
        /// Console.WriteLine(result.GetProperty("outputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("createdAt").ToString());
        /// Console.WriteLine(result.GetProperty("updatedAt").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the request and response payloads.
        /// 
        /// Request Body:
        /// 
        /// Schema for <c>NotificationHubJob</c>:
        /// <code>{
        ///   jobId: string, # Optional.
        ///   outputFileName: string, # Optional.
        ///   failuresFileName: string, # Optional.
        ///   progress: number, # Optional.
        ///   type: &quot;ExportRegistrations&quot; | &quot;ImportCreateRegistrations&quot; | &quot;ImportUpdateRegistrations&quot; | &quot;ImportDeleteRegistrations&quot; | &quot;ImportUpsertRegistrations&quot;, # Required.
        ///   status: &quot;Started&quot; | &quot;Running&quot; | &quot;Completed&quot; | &quot;Failed&quot;, # Optional.
        ///   outputContainerUrl: string, # Required.
        ///   importFileUrl: string, # Optional.
        ///   inputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   failure: string, # Optional.
        ///   outputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   createdAt: string (date &amp; time), # Optional.
        ///   updatedAt: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>NotificationHubJob</c>:
        /// <code>{
        ///   jobId: string, # Optional.
        ///   outputFileName: string, # Optional.
        ///   failuresFileName: string, # Optional.
        ///   progress: number, # Optional.
        ///   type: &quot;ExportRegistrations&quot; | &quot;ImportCreateRegistrations&quot; | &quot;ImportUpdateRegistrations&quot; | &quot;ImportDeleteRegistrations&quot; | &quot;ImportUpsertRegistrations&quot;, # Required.
        ///   status: &quot;Started&quot; | &quot;Running&quot; | &quot;Completed&quot; | &quot;Failed&quot;, # Optional.
        ///   outputContainerUrl: string, # Required.
        ///   importFileUrl: string, # Optional.
        ///   inputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   failure: string, # Optional.
        ///   outputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   createdAt: string (date &amp; time), # Optional.
        ///   updatedAt: 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("NotificationHubJobsClient.Create");
            scope.Start();
            try
            {
                using HttpMessage message = CreateCreateRequest(content, context);
                return _pipeline.ProcessMessage(message, context);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> Get an import/export Azure Notification Hubs job. </summary>
        /// <param name="jobId"> The job 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="jobId"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="jobId"/> 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 NotificationHubJobsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = await client.GetAsync("<jobId>");
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("jobId").ToString());
        /// Console.WriteLine(result.GetProperty("outputFileName").ToString());
        /// Console.WriteLine(result.GetProperty("failuresFileName").ToString());
        /// Console.WriteLine(result.GetProperty("progress").ToString());
        /// Console.WriteLine(result.GetProperty("type").ToString());
        /// Console.WriteLine(result.GetProperty("status").ToString());
        /// Console.WriteLine(result.GetProperty("outputContainerUrl").ToString());
        /// Console.WriteLine(result.GetProperty("importFileUrl").ToString());
        /// Console.WriteLine(result.GetProperty("inputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("failure").ToString());
        /// Console.WriteLine(result.GetProperty("outputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("createdAt").ToString());
        /// Console.WriteLine(result.GetProperty("updatedAt").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the response payload.
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>NotificationHubJob</c>:
        /// <code>{
        ///   jobId: string, # Optional.
        ///   outputFileName: string, # Optional.
        ///   failuresFileName: string, # Optional.
        ///   progress: number, # Optional.
        ///   type: &quot;ExportRegistrations&quot; | &quot;ImportCreateRegistrations&quot; | &quot;ImportUpdateRegistrations&quot; | &quot;ImportDeleteRegistrations&quot; | &quot;ImportUpsertRegistrations&quot;, # Required.
        ///   status: &quot;Started&quot; | &quot;Running&quot; | &quot;Completed&quot; | &quot;Failed&quot;, # Optional.
        ///   outputContainerUrl: string, # Required.
        ///   importFileUrl: string, # Optional.
        ///   inputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   failure: string, # Optional.
        ///   outputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   createdAt: string (date &amp; time), # Optional.
        ///   updatedAt: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual async Task<Response> GetAsync(string jobId, RequestContext context = null)
        {
            Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));

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

        /// <summary> Get an import/export Azure Notification Hubs job. </summary>
        /// <param name="jobId"> The job 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="jobId"/> is null. </exception>
        /// <exception cref="ArgumentException"> <paramref name="jobId"/> 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 NotificationHubJobsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = client.Get("<jobId>");
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result.GetProperty("jobId").ToString());
        /// Console.WriteLine(result.GetProperty("outputFileName").ToString());
        /// Console.WriteLine(result.GetProperty("failuresFileName").ToString());
        /// Console.WriteLine(result.GetProperty("progress").ToString());
        /// Console.WriteLine(result.GetProperty("type").ToString());
        /// Console.WriteLine(result.GetProperty("status").ToString());
        /// Console.WriteLine(result.GetProperty("outputContainerUrl").ToString());
        /// Console.WriteLine(result.GetProperty("importFileUrl").ToString());
        /// Console.WriteLine(result.GetProperty("inputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("failure").ToString());
        /// Console.WriteLine(result.GetProperty("outputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result.GetProperty("createdAt").ToString());
        /// Console.WriteLine(result.GetProperty("updatedAt").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the response payload.
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>NotificationHubJob</c>:
        /// <code>{
        ///   jobId: string, # Optional.
        ///   outputFileName: string, # Optional.
        ///   failuresFileName: string, # Optional.
        ///   progress: number, # Optional.
        ///   type: &quot;ExportRegistrations&quot; | &quot;ImportCreateRegistrations&quot; | &quot;ImportUpdateRegistrations&quot; | &quot;ImportDeleteRegistrations&quot; | &quot;ImportUpsertRegistrations&quot;, # Required.
        ///   status: &quot;Started&quot; | &quot;Running&quot; | &quot;Completed&quot; | &quot;Failed&quot;, # Optional.
        ///   outputContainerUrl: string, # Required.
        ///   importFileUrl: string, # Optional.
        ///   inputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   failure: string, # Optional.
        ///   outputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   createdAt: string (date &amp; time), # Optional.
        ///   updatedAt: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual Response Get(string jobId, RequestContext context = null)
        {
            Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));

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

        /// <summary> List all import/export Azure Notification Hubs jobs. </summary>
        /// <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 NotificationHubJobsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = await client.ListAsync();
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result[0].GetProperty("jobId").ToString());
        /// Console.WriteLine(result[0].GetProperty("outputFileName").ToString());
        /// Console.WriteLine(result[0].GetProperty("failuresFileName").ToString());
        /// Console.WriteLine(result[0].GetProperty("progress").ToString());
        /// Console.WriteLine(result[0].GetProperty("type").ToString());
        /// Console.WriteLine(result[0].GetProperty("status").ToString());
        /// Console.WriteLine(result[0].GetProperty("outputContainerUrl").ToString());
        /// Console.WriteLine(result[0].GetProperty("importFileUrl").ToString());
        /// Console.WriteLine(result[0].GetProperty("inputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result[0].GetProperty("failure").ToString());
        /// Console.WriteLine(result[0].GetProperty("outputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result[0].GetProperty("createdAt").ToString());
        /// Console.WriteLine(result[0].GetProperty("updatedAt").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the response payload.
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>NotificationHubJob</c>:
        /// <code>{
        ///   jobId: string, # Optional.
        ///   outputFileName: string, # Optional.
        ///   failuresFileName: string, # Optional.
        ///   progress: number, # Optional.
        ///   type: &quot;ExportRegistrations&quot; | &quot;ImportCreateRegistrations&quot; | &quot;ImportUpdateRegistrations&quot; | &quot;ImportDeleteRegistrations&quot; | &quot;ImportUpsertRegistrations&quot;, # Required.
        ///   status: &quot;Started&quot; | &quot;Running&quot; | &quot;Completed&quot; | &quot;Failed&quot;, # Optional.
        ///   outputContainerUrl: string, # Required.
        ///   importFileUrl: string, # Optional.
        ///   inputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   failure: string, # Optional.
        ///   outputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   createdAt: string (date &amp; time), # Optional.
        ///   updatedAt: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual async Task<Response> ListAsync(RequestContext context = null)
        {
            using var scope = ClientDiagnostics.CreateScope("NotificationHubJobsClient.List");
            scope.Start();
            try
            {
                using HttpMessage message = CreateListRequest(context);
                return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> List all import/export Azure Notification Hubs jobs. </summary>
        /// <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 NotificationHubJobsClient("<namespaceName>", "<hubName>");
        /// 
        /// Response response = client.List();
        /// 
        /// JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
        /// Console.WriteLine(result[0].GetProperty("jobId").ToString());
        /// Console.WriteLine(result[0].GetProperty("outputFileName").ToString());
        /// Console.WriteLine(result[0].GetProperty("failuresFileName").ToString());
        /// Console.WriteLine(result[0].GetProperty("progress").ToString());
        /// Console.WriteLine(result[0].GetProperty("type").ToString());
        /// Console.WriteLine(result[0].GetProperty("status").ToString());
        /// Console.WriteLine(result[0].GetProperty("outputContainerUrl").ToString());
        /// Console.WriteLine(result[0].GetProperty("importFileUrl").ToString());
        /// Console.WriteLine(result[0].GetProperty("inputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result[0].GetProperty("failure").ToString());
        /// Console.WriteLine(result[0].GetProperty("outputProperties").GetProperty("<test>").ToString());
        /// Console.WriteLine(result[0].GetProperty("createdAt").ToString());
        /// Console.WriteLine(result[0].GetProperty("updatedAt").ToString());
        /// ]]></code>
        /// </example>
        /// <remarks>
        /// Below is the JSON schema for the response payload.
        /// 
        /// Response Body:
        /// 
        /// Schema for <c>NotificationHubJob</c>:
        /// <code>{
        ///   jobId: string, # Optional.
        ///   outputFileName: string, # Optional.
        ///   failuresFileName: string, # Optional.
        ///   progress: number, # Optional.
        ///   type: &quot;ExportRegistrations&quot; | &quot;ImportCreateRegistrations&quot; | &quot;ImportUpdateRegistrations&quot; | &quot;ImportDeleteRegistrations&quot; | &quot;ImportUpsertRegistrations&quot;, # Required.
        ///   status: &quot;Started&quot; | &quot;Running&quot; | &quot;Completed&quot; | &quot;Failed&quot;, # Optional.
        ///   outputContainerUrl: string, # Required.
        ///   importFileUrl: string, # Optional.
        ///   inputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   failure: string, # Optional.
        ///   outputProperties: Dictionary&lt;string, string&gt;, # Optional.
        ///   createdAt: string (date &amp; time), # Optional.
        ///   updatedAt: string (date &amp; time), # Optional.
        /// }
        /// </code>
        /// 
        /// </remarks>
        public virtual Response List(RequestContext context = null)
        {
            using var scope = ClientDiagnostics.CreateScope("NotificationHubJobsClient.List");
            scope.Start();
            try
            {
                using HttpMessage message = CreateListRequest(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("/jobs", 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 CreateGetRequest(string jobId, 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("/jobs/", false);
            uri.AppendPath(jobId, true);
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            return message;
        }

        internal HttpMessage CreateListRequest(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("/jobs", false);
            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 });
    }
}
