< Summary

Class:Azure.ResourceManager.Storage.RestOperations
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\RestOperations.cs
Covered lines:0
Uncovered lines:40
Coverable lines:40
Total lines:113
Line coverage:0% (0 of 40)
Covered branches:0
Total branches:12
Branch coverage:0% (0 of 12)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\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.Storage.Models;
 16
 17namespace Azure.ResourceManager.Storage
 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"> This occurs when one of the required arguments 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.Storage/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 Storage 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                    {
 069                        OperationListResult value = default;
 070                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 071                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 72                        {
 073                            value = null;
 74                        }
 75                        else
 76                        {
 077                            value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 78                        }
 079                        return Response.FromValue(value, message.Response);
 80                    }
 81                default:
 082                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 83            }
 084        }
 85
 86        /// <summary> Lists all of the available Storage Rest API operations. </summary>
 87        /// <param name="cancellationToken"> The cancellation token to use. </param>
 88        public Response<OperationListResult> List(CancellationToken cancellationToken = default)
 89        {
 090            using var message = CreateListRequest();
 091            _pipeline.Send(message, cancellationToken);
 092            switch (message.Response.Status)
 93            {
 94                case 200:
 95                    {
 096                        OperationListResult value = default;
 097                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 098                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 99                        {
 0100                            value = null;
 101                        }
 102                        else
 103                        {
 0104                            value = OperationListResult.DeserializeOperationListResult(document.RootElement);
 105                        }
 0106                        return Response.FromValue(value, message.Response);
 107                    }
 108                default:
 0109                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 110            }
 0111        }
 112    }
 113}