< Summary

Class:Azure.ResourceManager.EventHubs.RestOperations
Assembly:Azure.ResourceManager.EventHubs
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.ResourceManager.EventHubs\src\Generated\RestOperations.cs
Covered lines:6
Uncovered lines:65
Coverable lines:71
Total lines:183
Line coverage:8.4% (6 of 71)
Covered branches:1
Total branches:22
Branch coverage:4.5% (1 of 22)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%50%
CreateListRequest()-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.ResourceManager.EventHubs\src\Generated\RestOperations.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.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Core;
 14using Azure.Core.Pipeline;
 15using Azure.ResourceManager.EventHubs.Models;
 16
 17namespace Azure.ResourceManager.EventHubs
 18{
 19    internal partial class RestOperations
 20    {
 21        private Uri endpoint;
 22        private ClientDiagnostics _clientDiagnostics;
 23        private HttpPipeline _pipeline;
 24
 25        /// <summary> Initializes a new instance of RestOperations. </summary>
 26        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 27        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 28        /// <param name="endpoint"> server parameter. </param>
 4829        public RestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null)
 30        {
 4831            endpoint ??= new Uri("https://management.azure.com");
 32
 4833            this.endpoint = endpoint;
 4834            _clientDiagnostics = clientDiagnostics;
 4835            _pipeline = pipeline;
 4836        }
 37
 38        internal HttpMessage CreateListRequest()
 39        {
 040            var message = _pipeline.CreateMessage();
 041            var request = message.Request;
 042            request.Method = RequestMethod.Get;
 043            var uri = new RawRequestUriBuilder();
 044            uri.Reset(endpoint);
 045            uri.AppendPath("/providers/Microsoft.EventHub/operations", false);
 046            uri.AppendQuery("api-version", "2017-04-01", true);
 047            request.Uri = uri;
 048            return message;
 49        }
 50
 51        /// <summary> Lists all of the available Event Hub REST API operations. </summary>
 52        /// <param name="cancellationToken"> The cancellation token to use. </param>
 53        public async Task<Response<OperationListResult>> ListAsync(CancellationToken cancellationToken = default)
 54        {
 055            using var message = CreateListRequest();
 056            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 057            switch (message.Response.Status)
 58            {
 59                case 200:
 60                    {
 061                        OperationListResult value = default;
 062                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 063                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 64                        {
 065                            value = null;
 66                        }
 67                        else
 68                        {
 069                            value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 70                        }
 071                        return Response.FromValue(value, message.Response);
 72                    }
 73                default:
 074                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 75            }
 076        }
 77
 78        /// <summary> Lists all of the available Event Hub REST API operations. </summary>
 79        /// <param name="cancellationToken"> The cancellation token to use. </param>
 80        public Response<OperationListResult> List(CancellationToken cancellationToken = default)
 81        {
 082            using var message = CreateListRequest();
 083            _pipeline.Send(message, cancellationToken);
 084            switch (message.Response.Status)
 85            {
 86                case 200:
 87                    {
 088                        OperationListResult value = default;
 089                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 090                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 91                        {
 092                            value = null;
 93                        }
 94                        else
 95                        {
 096                            value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 97                        }
 098                        return Response.FromValue(value, message.Response);
 99                    }
 100                default:
 0101                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 102            }
 0103        }
 104
 105        internal HttpMessage CreateListNextPageRequest(string nextLink)
 106        {
 0107            var message = _pipeline.CreateMessage();
 0108            var request = message.Request;
 0109            request.Method = RequestMethod.Get;
 0110            var uri = new RawRequestUriBuilder();
 0111            uri.Reset(endpoint);
 0112            uri.AppendRawNextLink(nextLink, false);
 0113            request.Uri = uri;
 0114            return message;
 115        }
 116
 117        /// <summary> Lists all of the available Event Hub REST API operations. </summary>
 118        /// <param name="nextLink"> The URL to the next page of results. </param>
 119        /// <param name="cancellationToken"> The cancellation token to use. </param>
 120        public async Task<Response<OperationListResult>> ListNextPageAsync(string nextLink, CancellationToken cancellati
 121        {
 0122            if (nextLink == null)
 123            {
 0124                throw new ArgumentNullException(nameof(nextLink));
 125            }
 126
 0127            using var message = CreateListNextPageRequest(nextLink);
 0128            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0129            switch (message.Response.Status)
 130            {
 131                case 200:
 132                    {
 0133                        OperationListResult value = default;
 0134                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0135                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 136                        {
 0137                            value = null;
 138                        }
 139                        else
 140                        {
 0141                            value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 142                        }
 0143                        return Response.FromValue(value, message.Response);
 144                    }
 145                default:
 0146                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 147            }
 0148        }
 149
 150        /// <summary> Lists all of the available Event Hub REST API operations. </summary>
 151        /// <param name="nextLink"> The URL to the next page of results. </param>
 152        /// <param name="cancellationToken"> The cancellation token to use. </param>
 153        public Response<OperationListResult> ListNextPage(string nextLink, CancellationToken cancellationToken = default
 154        {
 0155            if (nextLink == null)
 156            {
 0157                throw new ArgumentNullException(nameof(nextLink));
 158            }
 159
 0160            using var message = CreateListNextPageRequest(nextLink);
 0161            _pipeline.Send(message, cancellationToken);
 0162            switch (message.Response.Status)
 163            {
 164                case 200:
 165                    {
 0166                        OperationListResult value = default;
 0167                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0168                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 169                        {
 0170                            value = null;
 171                        }
 172                        else
 173                        {
 0174                            value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 175                        }
 0176                        return Response.FromValue(value, message.Response);
 177                    }
 178                default:
 0179                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 180            }
 0181        }
 182    }
 183}