< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateReceiveFeedbackNotificationRequest()-0%100%
ReceiveFeedbackNotificationAsync()-0%0%
ReceiveFeedbackNotification(...)-0%0%
CreateCompleteFeedbackNotificationRequest(...)-0%100%
CompleteFeedbackNotificationAsync()-0%0%
CompleteFeedbackNotification(...)-0%0%
CreateAbandonFeedbackNotificationRequest(...)-0%100%
AbandonFeedbackNotificationAsync()-0%0%
AbandonFeedbackNotification(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\CloudToDeviceMessagesRestClient.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.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Core;
 13using Azure.Core.Pipeline;
 14
 15namespace Azure.Iot.Hub.Service
 16{
 17    internal partial class CloudToDeviceMessagesRestClient
 18    {
 19        private Uri endpoint;
 20        private string apiVersion;
 21        private ClientDiagnostics _clientDiagnostics;
 22        private HttpPipeline _pipeline;
 23
 24        /// <summary> Initializes a new instance of CloudToDeviceMessagesRestClient. </summary>
 25        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 26        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 27        /// <param name="endpoint"> server parameter. </param>
 28        /// <param name="apiVersion"> Api Version. </param>
 29        /// <exception cref="ArgumentNullException"> <paramref name="apiVersion"/> is null. </exception>
 030        public CloudToDeviceMessagesRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint 
 31        {
 032            endpoint ??= new Uri("https://fully-qualified-iothubname.azure-devices.net");
 033            if (apiVersion == null)
 34            {
 035                throw new ArgumentNullException(nameof(apiVersion));
 36            }
 37
 038            this.endpoint = endpoint;
 039            this.apiVersion = apiVersion;
 040            _clientDiagnostics = clientDiagnostics;
 041            _pipeline = pipeline;
 042        }
 43
 44        internal HttpMessage CreateReceiveFeedbackNotificationRequest()
 45        {
 046            var message = _pipeline.CreateMessage();
 047            var request = message.Request;
 048            request.Method = RequestMethod.Get;
 049            var uri = new RawRequestUriBuilder();
 050            uri.Reset(endpoint);
 051            uri.AppendPath("/messages/serviceBound/feedback", false);
 052            uri.AppendQuery("api-version", apiVersion, true);
 053            request.Uri = uri;
 054            return message;
 55        }
 56
 57        /// <summary> Gets the feedback for cloud-to-device messages. See https://docs.microsoft.com/azure/iot-hub/iot-h
 58        /// <param name="cancellationToken"> The cancellation token to use. </param>
 59        public async Task<Response> ReceiveFeedbackNotificationAsync(CancellationToken cancellationToken = default)
 60        {
 061            using var message = CreateReceiveFeedbackNotificationRequest();
 062            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 063            switch (message.Response.Status)
 64            {
 65                case 200:
 66                case 204:
 067                    return message.Response;
 68                default:
 069                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 70            }
 071        }
 72
 73        /// <summary> Gets the feedback for cloud-to-device messages. See https://docs.microsoft.com/azure/iot-hub/iot-h
 74        /// <param name="cancellationToken"> The cancellation token to use. </param>
 75        public Response ReceiveFeedbackNotification(CancellationToken cancellationToken = default)
 76        {
 077            using var message = CreateReceiveFeedbackNotificationRequest();
 078            _pipeline.Send(message, cancellationToken);
 079            switch (message.Response.Status)
 80            {
 81                case 200:
 82                case 204:
 083                    return message.Response;
 84                default:
 085                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 86            }
 087        }
 88
 89        internal HttpMessage CreateCompleteFeedbackNotificationRequest(string lockToken)
 90        {
 091            var message = _pipeline.CreateMessage();
 092            var request = message.Request;
 093            request.Method = RequestMethod.Delete;
 094            var uri = new RawRequestUriBuilder();
 095            uri.Reset(endpoint);
 096            uri.AppendPath("/messages/serviceBound/feedback/", false);
 097            uri.AppendPath(lockToken, true);
 098            uri.AppendQuery("api-version", apiVersion, true);
 099            request.Uri = uri;
 0100            return message;
 101        }
 102
 103        /// <summary> Completes the cloud-to-device feedback message. A completed message is deleted from the feedback q
 104        /// <param name="lockToken"> The lock token obtained when the cloud-to-device message is received. This is used 
 105        /// <param name="cancellationToken"> The cancellation token to use. </param>
 106        /// <exception cref="ArgumentNullException"> <paramref name="lockToken"/> is null. </exception>
 107        public async Task<Response> CompleteFeedbackNotificationAsync(string lockToken, CancellationToken cancellationTo
 108        {
 0109            if (lockToken == null)
 110            {
 0111                throw new ArgumentNullException(nameof(lockToken));
 112            }
 113
 0114            using var message = CreateCompleteFeedbackNotificationRequest(lockToken);
 0115            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0116            switch (message.Response.Status)
 117            {
 118                case 204:
 0119                    return message.Response;
 120                default:
 0121                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 122            }
 0123        }
 124
 125        /// <summary> Completes the cloud-to-device feedback message. A completed message is deleted from the feedback q
 126        /// <param name="lockToken"> The lock token obtained when the cloud-to-device message is received. This is used 
 127        /// <param name="cancellationToken"> The cancellation token to use. </param>
 128        /// <exception cref="ArgumentNullException"> <paramref name="lockToken"/> is null. </exception>
 129        public Response CompleteFeedbackNotification(string lockToken, CancellationToken cancellationToken = default)
 130        {
 0131            if (lockToken == null)
 132            {
 0133                throw new ArgumentNullException(nameof(lockToken));
 134            }
 135
 0136            using var message = CreateCompleteFeedbackNotificationRequest(lockToken);
 0137            _pipeline.Send(message, cancellationToken);
 0138            switch (message.Response.Status)
 139            {
 140                case 204:
 0141                    return message.Response;
 142                default:
 0143                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 144            }
 0145        }
 146
 147        internal HttpMessage CreateAbandonFeedbackNotificationRequest(string lockToken)
 148        {
 0149            var message = _pipeline.CreateMessage();
 0150            var request = message.Request;
 0151            request.Method = RequestMethod.Post;
 0152            var uri = new RawRequestUriBuilder();
 0153            uri.Reset(endpoint);
 0154            uri.AppendPath("/messages/serviceBound/feedback/", false);
 0155            uri.AppendPath(lockToken, true);
 0156            uri.AppendPath("/abandon", false);
 0157            uri.AppendQuery("api-version", apiVersion, true);
 0158            request.Uri = uri;
 0159            return message;
 160        }
 161
 162        /// <summary> Abandons a cloud-to-device feedback message. An abandoned message is deleted from the feedback que
 163        /// <param name="lockToken"> The lock token obtained when the cloud-to-device message is received. This is used 
 164        /// <param name="cancellationToken"> The cancellation token to use. </param>
 165        /// <exception cref="ArgumentNullException"> <paramref name="lockToken"/> is null. </exception>
 166        public async Task<Response> AbandonFeedbackNotificationAsync(string lockToken, CancellationToken cancellationTok
 167        {
 0168            if (lockToken == null)
 169            {
 0170                throw new ArgumentNullException(nameof(lockToken));
 171            }
 172
 0173            using var message = CreateAbandonFeedbackNotificationRequest(lockToken);
 0174            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0175            switch (message.Response.Status)
 176            {
 177                case 204:
 0178                    return message.Response;
 179                default:
 0180                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 181            }
 0182        }
 183
 184        /// <summary> Abandons a cloud-to-device feedback message. An abandoned message is deleted from the feedback que
 185        /// <param name="lockToken"> The lock token obtained when the cloud-to-device message is received. This is used 
 186        /// <param name="cancellationToken"> The cancellation token to use. </param>
 187        /// <exception cref="ArgumentNullException"> <paramref name="lockToken"/> is null. </exception>
 188        public Response AbandonFeedbackNotification(string lockToken, CancellationToken cancellationToken = default)
 189        {
 0190            if (lockToken == null)
 191            {
 0192                throw new ArgumentNullException(nameof(lockToken));
 193            }
 194
 0195            using var message = CreateAbandonFeedbackNotificationRequest(lockToken);
 0196            _pipeline.Send(message, cancellationToken);
 0197            switch (message.Response.Status)
 198            {
 199                case 204:
 0200                    return message.Response;
 201                default:
 0202                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 203            }
 0204        }
 205    }
 206}