< Summary

Class:Azure.ResourceManager.KeyVault.RestOperations
Assembly:Azure.ResourceManager.KeyVault
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.ResourceManager.KeyVault\src\Generated\RestOperations.cs
Covered lines:0
Uncovered lines:62
Coverable lines:62
Total lines:165
Line coverage:0% (0 of 62)
Covered branches:0
Total branches:16
Branch coverage:0% (0 of 16)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
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\keyvault\Azure.ResourceManager.KeyVault\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.KeyVault.Models;
 16
 17namespace Azure.ResourceManager.KeyVault
 18{
 19    internal partial class RestOperations
 20    {
 21        private Uri endpoint;
 22        private string apiVersion;
 23        private ClientDiagnostics _clientDiagnostics;
 24        private HttpPipeline _pipeline;
 25
 26        /// <summary> Initializes a new instance of RestOperations. </summary>
 27        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 28        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 29        /// <param name="endpoint"> server parameter. </param>
 30        /// <param name="apiVersion"> Api Version. </param>
 31        /// <exception cref="ArgumentNullException"> <paramref name="apiVersion"/> is null. </exception>
 032        public RestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null, string ap
 33        {
 034            endpoint ??= new Uri("https://management.azure.com");
 035            if (apiVersion == null)
 36            {
 037                throw new ArgumentNullException(nameof(apiVersion));
 38            }
 39
 040            this.endpoint = endpoint;
 041            this.apiVersion = apiVersion;
 042            _clientDiagnostics = clientDiagnostics;
 043            _pipeline = pipeline;
 044        }
 45
 46        internal HttpMessage CreateListRequest()
 47        {
 048            var message = _pipeline.CreateMessage();
 049            var request = message.Request;
 050            request.Method = RequestMethod.Get;
 051            var uri = new RawRequestUriBuilder();
 052            uri.Reset(endpoint);
 053            uri.AppendPath("/providers/Microsoft.KeyVault/operations", false);
 054            uri.AppendQuery("api-version", apiVersion, true);
 055            request.Uri = uri;
 056            return message;
 57        }
 58
 59        /// <summary> Lists all of the available Key Vault Rest API operations. </summary>
 60        /// <param name="cancellationToken"> The cancellation token to use. </param>
 61        public async Task<Response<OperationListResult>> ListAsync(CancellationToken cancellationToken = default)
 62        {
 063            using var message = CreateListRequest();
 064            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 065            switch (message.Response.Status)
 66            {
 67                case 200:
 68                    {
 69                        OperationListResult value = default;
 070                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 071                        value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 072                        return Response.FromValue(value, message.Response);
 73                    }
 74                default:
 075                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 76            }
 077        }
 78
 79        /// <summary> Lists all of the available Key Vault Rest API operations. </summary>
 80        /// <param name="cancellationToken"> The cancellation token to use. </param>
 81        public Response<OperationListResult> List(CancellationToken cancellationToken = default)
 82        {
 083            using var message = CreateListRequest();
 084            _pipeline.Send(message, cancellationToken);
 085            switch (message.Response.Status)
 86            {
 87                case 200:
 88                    {
 89                        OperationListResult value = default;
 090                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 091                        value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 092                        return Response.FromValue(value, message.Response);
 93                    }
 94                default:
 095                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 96            }
 097        }
 98
 99        internal HttpMessage CreateListNextPageRequest(string nextLink)
 100        {
 0101            var message = _pipeline.CreateMessage();
 0102            var request = message.Request;
 0103            request.Method = RequestMethod.Get;
 0104            var uri = new RawRequestUriBuilder();
 0105            uri.Reset(endpoint);
 0106            uri.AppendRawNextLink(nextLink, false);
 0107            request.Uri = uri;
 0108            return message;
 109        }
 110
 111        /// <summary> Lists all of the available Key Vault Rest API operations. </summary>
 112        /// <param name="nextLink"> The URL to the next page of results. </param>
 113        /// <param name="cancellationToken"> The cancellation token to use. </param>
 114        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 115        public async Task<Response<OperationListResult>> ListNextPageAsync(string nextLink, CancellationToken cancellati
 116        {
 0117            if (nextLink == null)
 118            {
 0119                throw new ArgumentNullException(nameof(nextLink));
 120            }
 121
 0122            using var message = CreateListNextPageRequest(nextLink);
 0123            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0124            switch (message.Response.Status)
 125            {
 126                case 200:
 127                    {
 128                        OperationListResult value = default;
 0129                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0130                        value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 0131                        return Response.FromValue(value, message.Response);
 132                    }
 133                default:
 0134                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 135            }
 0136        }
 137
 138        /// <summary> Lists all of the available Key Vault Rest API operations. </summary>
 139        /// <param name="nextLink"> The URL to the next page of results. </param>
 140        /// <param name="cancellationToken"> The cancellation token to use. </param>
 141        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 142        public Response<OperationListResult> ListNextPage(string nextLink, CancellationToken cancellationToken = default
 143        {
 0144            if (nextLink == null)
 145            {
 0146                throw new ArgumentNullException(nameof(nextLink));
 147            }
 148
 0149            using var message = CreateListNextPageRequest(nextLink);
 0150            _pipeline.Send(message, cancellationToken);
 0151            switch (message.Response.Status)
 152            {
 153                case 200:
 154                    {
 155                        OperationListResult value = default;
 0156                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0157                        value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 0158                        return Response.FromValue(value, message.Response);
 159                    }
 160                default:
 0161                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 162            }
 0163        }
 164    }
 165}