< Summary

Class:Azure.Iot.Hub.Service.JobsRestClient
Assembly:Azure.Iot.Hub.Service
File(s):C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\JobsRestClient.cs
Covered lines:0
Uncovered lines:263
Coverable lines:263
Total lines:605
Line coverage:0% (0 of 263)
Covered branches:0
Total branches:76
Branch coverage:0% (0 of 76)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateCreateImportExportJobRequest(...)-0%100%
CreateImportExportJobAsync()-0%0%
CreateImportExportJob(...)-0%0%
CreateGetImportExportJobsRequest()-0%100%
GetImportExportJobsAsync()-0%0%
GetImportExportJobs(...)-0%0%
CreateGetImportExportJobRequest(...)-0%100%
GetImportExportJobAsync()-0%0%
GetImportExportJob(...)-0%0%
CreateCancelImportExportJobRequest(...)-0%100%
CancelImportExportJobAsync()-0%0%
CancelImportExportJob(...)-0%0%
CreateGetScheduledJobRequest(...)-0%100%
GetScheduledJobAsync()-0%0%
GetScheduledJob(...)-0%0%
CreateCreateScheduledJobRequest(...)-0%100%
CreateScheduledJobAsync()-0%0%
CreateScheduledJob(...)-0%0%
CreateCancelScheduledJobRequest(...)-0%100%
CancelScheduledJobAsync()-0%0%
CancelScheduledJob(...)-0%0%
CreateQueryScheduledJobsRequest(...)-0%0%
QueryScheduledJobsAsync()-0%0%
QueryScheduledJobs(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\JobsRestClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using System.Text.Json;
 11using System.Threading;
 12using System.Threading.Tasks;
 13using Azure;
 14using Azure.Core;
 15using Azure.Core.Pipeline;
 16using Azure.Iot.Hub.Service.Models;
 17
 18namespace Azure.Iot.Hub.Service
 19{
 20    internal partial class JobsRestClient
 21    {
 22        private Uri endpoint;
 23        private string apiVersion;
 24        private ClientDiagnostics _clientDiagnostics;
 25        private HttpPipeline _pipeline;
 26
 27        /// <summary> Initializes a new instance of JobsRestClient. </summary>
 28        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 29        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <param name="apiVersion"> Api Version. </param>
 32        /// <exception cref="ArgumentNullException"> <paramref name="apiVersion"/> is null. </exception>
 033        public JobsRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null, string ap
 34        {
 035            endpoint ??= new Uri("https://fully-qualified-iothubname.azure-devices.net");
 036            if (apiVersion == null)
 37            {
 038                throw new ArgumentNullException(nameof(apiVersion));
 39            }
 40
 041            this.endpoint = endpoint;
 042            this.apiVersion = apiVersion;
 043            _clientDiagnostics = clientDiagnostics;
 044            _pipeline = pipeline;
 045        }
 46
 47        internal HttpMessage CreateCreateImportExportJobRequest(JobProperties jobProperties)
 48        {
 049            var message = _pipeline.CreateMessage();
 050            var request = message.Request;
 051            request.Method = RequestMethod.Post;
 052            var uri = new RawRequestUriBuilder();
 053            uri.Reset(endpoint);
 054            uri.AppendPath("/jobs/create", false);
 055            uri.AppendQuery("api-version", apiVersion, true);
 056            request.Uri = uri;
 057            request.Headers.Add("Content-Type", "application/json");
 058            var content = new Utf8JsonRequestContent();
 059            content.JsonWriter.WriteObjectValue(jobProperties);
 060            request.Content = content;
 061            return message;
 62        }
 63
 64        /// <summary> Creates a new import or export job on the IoT Hub. See https://docs.microsoft.com/en-us/azure/iot-
 65        /// <param name="jobProperties"> The job specifications. </param>
 66        /// <param name="cancellationToken"> The cancellation token to use. </param>
 67        /// <exception cref="ArgumentNullException"> <paramref name="jobProperties"/> is null. </exception>
 68        public async Task<Response<JobProperties>> CreateImportExportJobAsync(JobProperties jobProperties, CancellationT
 69        {
 070            if (jobProperties == null)
 71            {
 072                throw new ArgumentNullException(nameof(jobProperties));
 73            }
 74
 075            using var message = CreateCreateImportExportJobRequest(jobProperties);
 076            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 077            switch (message.Response.Status)
 78            {
 79                case 200:
 80                    {
 81                        JobProperties value = default;
 082                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 083                        value = JobProperties.DeserializeJobProperties(document.RootElement);
 084                        return Response.FromValue(value, message.Response);
 85                    }
 86                default:
 087                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 88            }
 089        }
 90
 91        /// <summary> Creates a new import or export job on the IoT Hub. See https://docs.microsoft.com/en-us/azure/iot-
 92        /// <param name="jobProperties"> The job specifications. </param>
 93        /// <param name="cancellationToken"> The cancellation token to use. </param>
 94        /// <exception cref="ArgumentNullException"> <paramref name="jobProperties"/> is null. </exception>
 95        public Response<JobProperties> CreateImportExportJob(JobProperties jobProperties, CancellationToken cancellation
 96        {
 097            if (jobProperties == null)
 98            {
 099                throw new ArgumentNullException(nameof(jobProperties));
 100            }
 101
 0102            using var message = CreateCreateImportExportJobRequest(jobProperties);
 0103            _pipeline.Send(message, cancellationToken);
 0104            switch (message.Response.Status)
 105            {
 106                case 200:
 107                    {
 108                        JobProperties value = default;
 0109                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0110                        value = JobProperties.DeserializeJobProperties(document.RootElement);
 0111                        return Response.FromValue(value, message.Response);
 112                    }
 113                default:
 0114                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 115            }
 0116        }
 117
 118        internal HttpMessage CreateGetImportExportJobsRequest()
 119        {
 0120            var message = _pipeline.CreateMessage();
 0121            var request = message.Request;
 0122            request.Method = RequestMethod.Get;
 0123            var uri = new RawRequestUriBuilder();
 0124            uri.Reset(endpoint);
 0125            uri.AppendPath("/jobs", false);
 0126            uri.AppendQuery("api-version", apiVersion, true);
 0127            request.Uri = uri;
 0128            return message;
 129        }
 130
 131        /// <summary> Gets the status of all import and export jobs in the IoT Hub. See https://docs.microsoft.com/en-us
 132        /// <param name="cancellationToken"> The cancellation token to use. </param>
 133        public async Task<Response<IReadOnlyList<JobProperties>>> GetImportExportJobsAsync(CancellationToken cancellatio
 134        {
 0135            using var message = CreateGetImportExportJobsRequest();
 0136            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0137            switch (message.Response.Status)
 138            {
 139                case 200:
 140                    {
 141                        IReadOnlyList<JobProperties> value = default;
 0142                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0143                        List<JobProperties> array = new List<JobProperties>();
 0144                        foreach (var item in document.RootElement.EnumerateArray())
 145                        {
 0146                            array.Add(JobProperties.DeserializeJobProperties(item));
 147                        }
 0148                        value = array;
 0149                        return Response.FromValue(value, message.Response);
 150                    }
 151                default:
 0152                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 153            }
 0154        }
 155
 156        /// <summary> Gets the status of all import and export jobs in the IoT Hub. See https://docs.microsoft.com/en-us
 157        /// <param name="cancellationToken"> The cancellation token to use. </param>
 158        public Response<IReadOnlyList<JobProperties>> GetImportExportJobs(CancellationToken cancellationToken = default)
 159        {
 0160            using var message = CreateGetImportExportJobsRequest();
 0161            _pipeline.Send(message, cancellationToken);
 0162            switch (message.Response.Status)
 163            {
 164                case 200:
 165                    {
 166                        IReadOnlyList<JobProperties> value = default;
 0167                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0168                        List<JobProperties> array = new List<JobProperties>();
 0169                        foreach (var item in document.RootElement.EnumerateArray())
 170                        {
 0171                            array.Add(JobProperties.DeserializeJobProperties(item));
 172                        }
 0173                        value = array;
 0174                        return Response.FromValue(value, message.Response);
 175                    }
 176                default:
 0177                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 178            }
 0179        }
 180
 181        internal HttpMessage CreateGetImportExportJobRequest(string id)
 182        {
 0183            var message = _pipeline.CreateMessage();
 0184            var request = message.Request;
 0185            request.Method = RequestMethod.Get;
 0186            var uri = new RawRequestUriBuilder();
 0187            uri.Reset(endpoint);
 0188            uri.AppendPath("/jobs/", false);
 0189            uri.AppendPath(id, true);
 0190            uri.AppendQuery("api-version", apiVersion, true);
 0191            request.Uri = uri;
 0192            return message;
 193        }
 194
 195        /// <summary> Gets the status of an import or export job in the IoT Hub. See https://docs.microsoft.com/en-us/az
 196        /// <param name="id"> The unique identifier of the job. </param>
 197        /// <param name="cancellationToken"> The cancellation token to use. </param>
 198        /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception>
 199        public async Task<Response<JobProperties>> GetImportExportJobAsync(string id, CancellationToken cancellationToke
 200        {
 0201            if (id == null)
 202            {
 0203                throw new ArgumentNullException(nameof(id));
 204            }
 205
 0206            using var message = CreateGetImportExportJobRequest(id);
 0207            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0208            switch (message.Response.Status)
 209            {
 210                case 200:
 211                    {
 212                        JobProperties value = default;
 0213                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0214                        value = JobProperties.DeserializeJobProperties(document.RootElement);
 0215                        return Response.FromValue(value, message.Response);
 216                    }
 217                default:
 0218                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 219            }
 0220        }
 221
 222        /// <summary> Gets the status of an import or export job in the IoT Hub. See https://docs.microsoft.com/en-us/az
 223        /// <param name="id"> The unique identifier of the job. </param>
 224        /// <param name="cancellationToken"> The cancellation token to use. </param>
 225        /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception>
 226        public Response<JobProperties> GetImportExportJob(string id, CancellationToken cancellationToken = default)
 227        {
 0228            if (id == null)
 229            {
 0230                throw new ArgumentNullException(nameof(id));
 231            }
 232
 0233            using var message = CreateGetImportExportJobRequest(id);
 0234            _pipeline.Send(message, cancellationToken);
 0235            switch (message.Response.Status)
 236            {
 237                case 200:
 238                    {
 239                        JobProperties value = default;
 0240                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0241                        value = JobProperties.DeserializeJobProperties(document.RootElement);
 0242                        return Response.FromValue(value, message.Response);
 243                    }
 244                default:
 0245                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 246            }
 0247        }
 248
 249        internal HttpMessage CreateCancelImportExportJobRequest(string id)
 250        {
 0251            var message = _pipeline.CreateMessage();
 0252            var request = message.Request;
 0253            request.Method = RequestMethod.Delete;
 0254            var uri = new RawRequestUriBuilder();
 0255            uri.Reset(endpoint);
 0256            uri.AppendPath("/jobs/", false);
 0257            uri.AppendPath(id, true);
 0258            uri.AppendQuery("api-version", apiVersion, true);
 0259            request.Uri = uri;
 0260            return message;
 261        }
 262
 263        /// <summary> Cancels an import or export job in the IoT Hub. </summary>
 264        /// <param name="id"> The unique identifier of the job. </param>
 265        /// <param name="cancellationToken"> The cancellation token to use. </param>
 266        /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception>
 267        public async Task<Response<object>> CancelImportExportJobAsync(string id, CancellationToken cancellationToken = 
 268        {
 0269            if (id == null)
 270            {
 0271                throw new ArgumentNullException(nameof(id));
 272            }
 273
 0274            using var message = CreateCancelImportExportJobRequest(id);
 0275            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0276            switch (message.Response.Status)
 277            {
 278                case 200:
 279                    {
 280                        object value = default;
 0281                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0282                        value = document.RootElement.GetObject();
 0283                        return Response.FromValue(value, message.Response);
 284                    }
 285                case 204:
 0286                    return Response.FromValue<object>(null, message.Response);
 287                default:
 0288                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 289            }
 0290        }
 291
 292        /// <summary> Cancels an import or export job in the IoT Hub. </summary>
 293        /// <param name="id"> The unique identifier of the job. </param>
 294        /// <param name="cancellationToken"> The cancellation token to use. </param>
 295        /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception>
 296        public Response<object> CancelImportExportJob(string id, CancellationToken cancellationToken = default)
 297        {
 0298            if (id == null)
 299            {
 0300                throw new ArgumentNullException(nameof(id));
 301            }
 302
 0303            using var message = CreateCancelImportExportJobRequest(id);
 0304            _pipeline.Send(message, cancellationToken);
 0305            switch (message.Response.Status)
 306            {
 307                case 200:
 308                    {
 309                        object value = default;
 0310                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0311                        value = document.RootElement.GetObject();
 0312                        return Response.FromValue(value, message.Response);
 313                    }
 314                case 204:
 0315                    return Response.FromValue<object>(null, message.Response);
 316                default:
 0317                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 318            }
 0319        }
 320
 321        internal HttpMessage CreateGetScheduledJobRequest(string id)
 322        {
 0323            var message = _pipeline.CreateMessage();
 0324            var request = message.Request;
 0325            request.Method = RequestMethod.Get;
 0326            var uri = new RawRequestUriBuilder();
 0327            uri.Reset(endpoint);
 0328            uri.AppendPath("/jobs/v2/", false);
 0329            uri.AppendPath(id, true);
 0330            uri.AppendQuery("api-version", apiVersion, true);
 0331            request.Uri = uri;
 0332            return message;
 333        }
 334
 335        /// <summary> Gets details of a scheduled job from the IoT Hub. See https://docs.microsoft.com/en-us/azure/iot-h
 336        /// <param name="id"> The unique identifier of the job. </param>
 337        /// <param name="cancellationToken"> The cancellation token to use. </param>
 338        /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception>
 339        public async Task<Response<JobResponse>> GetScheduledJobAsync(string id, CancellationToken cancellationToken = d
 340        {
 0341            if (id == null)
 342            {
 0343                throw new ArgumentNullException(nameof(id));
 344            }
 345
 0346            using var message = CreateGetScheduledJobRequest(id);
 0347            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0348            switch (message.Response.Status)
 349            {
 350                case 200:
 351                    {
 352                        JobResponse value = default;
 0353                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0354                        value = JobResponse.DeserializeJobResponse(document.RootElement);
 0355                        return Response.FromValue(value, message.Response);
 356                    }
 357                default:
 0358                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 359            }
 0360        }
 361
 362        /// <summary> Gets details of a scheduled job from the IoT Hub. See https://docs.microsoft.com/en-us/azure/iot-h
 363        /// <param name="id"> The unique identifier of the job. </param>
 364        /// <param name="cancellationToken"> The cancellation token to use. </param>
 365        /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception>
 366        public Response<JobResponse> GetScheduledJob(string id, CancellationToken cancellationToken = default)
 367        {
 0368            if (id == null)
 369            {
 0370                throw new ArgumentNullException(nameof(id));
 371            }
 372
 0373            using var message = CreateGetScheduledJobRequest(id);
 0374            _pipeline.Send(message, cancellationToken);
 0375            switch (message.Response.Status)
 376            {
 377                case 200:
 378                    {
 379                        JobResponse value = default;
 0380                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0381                        value = JobResponse.DeserializeJobResponse(document.RootElement);
 0382                        return Response.FromValue(value, message.Response);
 383                    }
 384                default:
 0385                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 386            }
 0387        }
 388
 389        internal HttpMessage CreateCreateScheduledJobRequest(string id, JobRequest jobRequest)
 390        {
 0391            var message = _pipeline.CreateMessage();
 0392            var request = message.Request;
 0393            request.Method = RequestMethod.Put;
 0394            var uri = new RawRequestUriBuilder();
 0395            uri.Reset(endpoint);
 0396            uri.AppendPath("/jobs/v2/", false);
 0397            uri.AppendPath(id, true);
 0398            uri.AppendQuery("api-version", apiVersion, true);
 0399            request.Uri = uri;
 0400            request.Headers.Add("Content-Type", "application/json");
 0401            var content = new Utf8JsonRequestContent();
 0402            content.JsonWriter.WriteObjectValue(jobRequest);
 0403            request.Content = content;
 0404            return message;
 405        }
 406
 407        /// <summary> Creates a new job to schedule twin updates or direct methods on the IoT Hub at a scheduled time. S
 408        /// <param name="id"> The unique identifier of the job. </param>
 409        /// <param name="jobRequest"> The job request info. </param>
 410        /// <param name="cancellationToken"> The cancellation token to use. </param>
 411        /// <exception cref="ArgumentNullException"> <paramref name="id"/> or <paramref name="jobRequest"/> is null. </e
 412        public async Task<Response<JobResponse>> CreateScheduledJobAsync(string id, JobRequest jobRequest, CancellationT
 413        {
 0414            if (id == null)
 415            {
 0416                throw new ArgumentNullException(nameof(id));
 417            }
 0418            if (jobRequest == null)
 419            {
 0420                throw new ArgumentNullException(nameof(jobRequest));
 421            }
 422
 0423            using var message = CreateCreateScheduledJobRequest(id, jobRequest);
 0424            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0425            switch (message.Response.Status)
 426            {
 427                case 200:
 428                    {
 429                        JobResponse value = default;
 0430                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0431                        value = JobResponse.DeserializeJobResponse(document.RootElement);
 0432                        return Response.FromValue(value, message.Response);
 433                    }
 434                default:
 0435                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 436            }
 0437        }
 438
 439        /// <summary> Creates a new job to schedule twin updates or direct methods on the IoT Hub at a scheduled time. S
 440        /// <param name="id"> The unique identifier of the job. </param>
 441        /// <param name="jobRequest"> The job request info. </param>
 442        /// <param name="cancellationToken"> The cancellation token to use. </param>
 443        /// <exception cref="ArgumentNullException"> <paramref name="id"/> or <paramref name="jobRequest"/> is null. </e
 444        public Response<JobResponse> CreateScheduledJob(string id, JobRequest jobRequest, CancellationToken cancellation
 445        {
 0446            if (id == null)
 447            {
 0448                throw new ArgumentNullException(nameof(id));
 449            }
 0450            if (jobRequest == null)
 451            {
 0452                throw new ArgumentNullException(nameof(jobRequest));
 453            }
 454
 0455            using var message = CreateCreateScheduledJobRequest(id, jobRequest);
 0456            _pipeline.Send(message, cancellationToken);
 0457            switch (message.Response.Status)
 458            {
 459                case 200:
 460                    {
 461                        JobResponse value = default;
 0462                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0463                        value = JobResponse.DeserializeJobResponse(document.RootElement);
 0464                        return Response.FromValue(value, message.Response);
 465                    }
 466                default:
 0467                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 468            }
 0469        }
 470
 471        internal HttpMessage CreateCancelScheduledJobRequest(string id)
 472        {
 0473            var message = _pipeline.CreateMessage();
 0474            var request = message.Request;
 0475            request.Method = RequestMethod.Post;
 0476            var uri = new RawRequestUriBuilder();
 0477            uri.Reset(endpoint);
 0478            uri.AppendPath("/jobs/v2/", false);
 0479            uri.AppendPath(id, true);
 0480            uri.AppendPath("/cancel", false);
 0481            uri.AppendQuery("api-version", apiVersion, true);
 0482            request.Uri = uri;
 0483            return message;
 484        }
 485
 486        /// <summary> Cancels a scheduled job on the IoT Hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub
 487        /// <param name="id"> The unique identifier of the job. </param>
 488        /// <param name="cancellationToken"> The cancellation token to use. </param>
 489        /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception>
 490        public async Task<Response<JobResponse>> CancelScheduledJobAsync(string id, CancellationToken cancellationToken 
 491        {
 0492            if (id == null)
 493            {
 0494                throw new ArgumentNullException(nameof(id));
 495            }
 496
 0497            using var message = CreateCancelScheduledJobRequest(id);
 0498            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0499            switch (message.Response.Status)
 500            {
 501                case 200:
 502                    {
 503                        JobResponse value = default;
 0504                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0505                        value = JobResponse.DeserializeJobResponse(document.RootElement);
 0506                        return Response.FromValue(value, message.Response);
 507                    }
 508                default:
 0509                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 510            }
 0511        }
 512
 513        /// <summary> Cancels a scheduled job on the IoT Hub. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub
 514        /// <param name="id"> The unique identifier of the job. </param>
 515        /// <param name="cancellationToken"> The cancellation token to use. </param>
 516        /// <exception cref="ArgumentNullException"> <paramref name="id"/> is null. </exception>
 517        public Response<JobResponse> CancelScheduledJob(string id, CancellationToken cancellationToken = default)
 518        {
 0519            if (id == null)
 520            {
 0521                throw new ArgumentNullException(nameof(id));
 522            }
 523
 0524            using var message = CreateCancelScheduledJobRequest(id);
 0525            _pipeline.Send(message, cancellationToken);
 0526            switch (message.Response.Status)
 527            {
 528                case 200:
 529                    {
 530                        JobResponse value = default;
 0531                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0532                        value = JobResponse.DeserializeJobResponse(document.RootElement);
 0533                        return Response.FromValue(value, message.Response);
 534                    }
 535                default:
 0536                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 537            }
 0538        }
 539
 540        internal HttpMessage CreateQueryScheduledJobsRequest(string jobType, string jobStatus)
 541        {
 0542            var message = _pipeline.CreateMessage();
 0543            var request = message.Request;
 0544            request.Method = RequestMethod.Get;
 0545            var uri = new RawRequestUriBuilder();
 0546            uri.Reset(endpoint);
 0547            uri.AppendPath("/jobs/v2/query", false);
 0548            if (jobType != null)
 549            {
 0550                uri.AppendQuery("jobType", jobType, true);
 551            }
 0552            if (jobStatus != null)
 553            {
 0554                uri.AppendQuery("jobStatus", jobStatus, true);
 555            }
 0556            uri.AppendQuery("api-version", apiVersion, true);
 0557            request.Uri = uri;
 0558            return message;
 559        }
 560
 561        /// <summary> Gets the information about jobs using an IoT Hub query. See https://docs.microsoft.com/azure/iot-h
 562        /// <param name="jobType"> The job type. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-job
 563        /// <param name="jobStatus"> The job status. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide
 564        /// <param name="cancellationToken"> The cancellation token to use. </param>
 565        public async Task<Response<QueryResult>> QueryScheduledJobsAsync(string jobType = null, string jobStatus = null,
 566        {
 0567            using var message = CreateQueryScheduledJobsRequest(jobType, jobStatus);
 0568            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0569            switch (message.Response.Status)
 570            {
 571                case 200:
 572                    {
 573                        QueryResult value = default;
 0574                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0575                        value = QueryResult.DeserializeQueryResult(document.RootElement);
 0576                        return Response.FromValue(value, message.Response);
 577                    }
 578                default:
 0579                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 580            }
 0581        }
 582
 583        /// <summary> Gets the information about jobs using an IoT Hub query. See https://docs.microsoft.com/azure/iot-h
 584        /// <param name="jobType"> The job type. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-job
 585        /// <param name="jobStatus"> The job status. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide
 586        /// <param name="cancellationToken"> The cancellation token to use. </param>
 587        public Response<QueryResult> QueryScheduledJobs(string jobType = null, string jobStatus = null, CancellationToke
 588        {
 0589            using var message = CreateQueryScheduledJobsRequest(jobType, jobStatus);
 0590            _pipeline.Send(message, cancellationToken);
 0591            switch (message.Response.Status)
 592            {
 593                case 200:
 594                    {
 595                        QueryResult value = default;
 0596                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0597                        value = QueryResult.DeserializeQueryResult(document.RootElement);
 0598                        return Response.FromValue(value, message.Response);
 599                    }
 600                default:
 0601                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 602            }
 0603        }
 604    }
 605}