< Summary

Class:Azure.ResourceManager.AppConfiguration.RestOperations
Assembly:Azure.ResourceManager.AppConfiguration
File(s):C:\Git\azure-sdk-for-net\sdk\appconfiguration\Azure.ResourceManager.AppConfiguration\src\Generated\RestOperations.cs
Covered lines:73
Uncovered lines:47
Coverable lines:120
Total lines:291
Line coverage:60.8% (73 of 120)
Covered branches:14
Total branches:40
Branch coverage:35% (14 of 40)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
CreateCheckNameAvailabilityRequest(...)-100%100%
CheckNameAvailabilityAsync()-76.92%50%
CheckNameAvailability(...)-76.92%50%
CreateListRequest(...)-90.91%50%
ListAsync()-81.82%50%
List(...)-81.82%50%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\appconfiguration\Azure.ResourceManager.AppConfiguration\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.AppConfiguration.Models;
 16
 17namespace Azure.ResourceManager.AppConfiguration
 18{
 19    internal partial class RestOperations
 20    {
 21        private string subscriptionId;
 22        private Uri endpoint;
 23        private string apiVersion;
 24        private ClientDiagnostics _clientDiagnostics;
 25        private HttpPipeline _pipeline;
 26
 27        /// <summary> Initializes a new instance of RestOperations. </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="subscriptionId"> The Microsoft Azure subscription ID. </param>
 31        /// <param name="endpoint"> server parameter. </param>
 32        /// <param name="apiVersion"> Api Version. </param>
 33        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 834        public RestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri end
 35        {
 836            if (subscriptionId == null)
 37            {
 038                throw new ArgumentNullException(nameof(subscriptionId));
 39            }
 840            endpoint ??= new Uri("https://management.azure.com");
 841            if (apiVersion == null)
 42            {
 043                throw new ArgumentNullException(nameof(apiVersion));
 44            }
 45
 846            this.subscriptionId = subscriptionId;
 847            this.endpoint = endpoint;
 848            this.apiVersion = apiVersion;
 849            _clientDiagnostics = clientDiagnostics;
 850            _pipeline = pipeline;
 851        }
 52
 53        internal HttpMessage CreateCheckNameAvailabilityRequest(CheckNameAvailabilityParameters checkNameAvailabilityPar
 54        {
 455            var message = _pipeline.CreateMessage();
 456            var request = message.Request;
 457            request.Method = RequestMethod.Post;
 458            var uri = new RawRequestUriBuilder();
 459            uri.Reset(endpoint);
 460            uri.AppendPath("/subscriptions/", false);
 461            uri.AppendPath(subscriptionId, true);
 462            uri.AppendPath("/providers/Microsoft.AppConfiguration/checkNameAvailability", false);
 463            uri.AppendQuery("api-version", apiVersion, true);
 464            request.Uri = uri;
 465            request.Headers.Add("Content-Type", "application/json");
 466            var content = new Utf8JsonRequestContent();
 467            content.JsonWriter.WriteObjectValue(checkNameAvailabilityParameters);
 468            request.Content = content;
 469            return message;
 70        }
 71
 72        /// <summary> Checks whether the configuration store name is available for use. </summary>
 73        /// <param name="checkNameAvailabilityParameters"> The object containing information for the availability reques
 74        /// <param name="cancellationToken"> The cancellation token to use. </param>
 75        public async Task<Response<NameAvailabilityStatus>> CheckNameAvailabilityAsync(CheckNameAvailabilityParameters c
 76        {
 277            if (checkNameAvailabilityParameters == null)
 78            {
 079                throw new ArgumentNullException(nameof(checkNameAvailabilityParameters));
 80            }
 81
 282            using var message = CreateCheckNameAvailabilityRequest(checkNameAvailabilityParameters);
 283            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 284            switch (message.Response.Status)
 85            {
 86                case 200:
 87                    {
 288                        NameAvailabilityStatus value = default;
 289                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 290                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 91                        {
 092                            value = null;
 93                        }
 94                        else
 95                        {
 296                            value = NameAvailabilityStatus.DeserializeNameAvailabilityStatus(document.RootElement);
 97                        }
 298                        return Response.FromValue(value, message.Response);
 99                    }
 100                default:
 0101                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 102            }
 2103        }
 104
 105        /// <summary> Checks whether the configuration store name is available for use. </summary>
 106        /// <param name="checkNameAvailabilityParameters"> The object containing information for the availability reques
 107        /// <param name="cancellationToken"> The cancellation token to use. </param>
 108        public Response<NameAvailabilityStatus> CheckNameAvailability(CheckNameAvailabilityParameters checkNameAvailabil
 109        {
 2110            if (checkNameAvailabilityParameters == null)
 111            {
 0112                throw new ArgumentNullException(nameof(checkNameAvailabilityParameters));
 113            }
 114
 2115            using var message = CreateCheckNameAvailabilityRequest(checkNameAvailabilityParameters);
 2116            _pipeline.Send(message, cancellationToken);
 2117            switch (message.Response.Status)
 118            {
 119                case 200:
 120                    {
 2121                        NameAvailabilityStatus value = default;
 2122                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2123                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 124                        {
 0125                            value = null;
 126                        }
 127                        else
 128                        {
 2129                            value = NameAvailabilityStatus.DeserializeNameAvailabilityStatus(document.RootElement);
 130                        }
 2131                        return Response.FromValue(value, message.Response);
 132                    }
 133                default:
 0134                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 135            }
 2136        }
 137
 138        internal HttpMessage CreateListRequest(string skipToken)
 139        {
 4140            var message = _pipeline.CreateMessage();
 4141            var request = message.Request;
 4142            request.Method = RequestMethod.Get;
 4143            var uri = new RawRequestUriBuilder();
 4144            uri.Reset(endpoint);
 4145            uri.AppendPath("/providers/Microsoft.AppConfiguration/operations", false);
 4146            uri.AppendQuery("api-version", apiVersion, true);
 4147            if (skipToken != null)
 148            {
 0149                uri.AppendQuery("$skipToken", skipToken, true);
 150            }
 4151            request.Uri = uri;
 4152            return message;
 153        }
 154
 155        /// <summary> Lists the operations available from this provider. </summary>
 156        /// <param name="skipToken"> A skip token is used to continue retrieving items after an operation returns a part
 157        /// <param name="cancellationToken"> The cancellation token to use. </param>
 158        public async Task<Response<OperationDefinitionListResult>> ListAsync(string skipToken = null, CancellationToken 
 159        {
 2160            using var message = CreateListRequest(skipToken);
 2161            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2162            switch (message.Response.Status)
 163            {
 164                case 200:
 165                    {
 2166                        OperationDefinitionListResult value = default;
 2167                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2168                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 169                        {
 0170                            value = null;
 171                        }
 172                        else
 173                        {
 2174                            value = OperationDefinitionListResult.DeserializeOperationDefinitionListResult(document.Root
 175                        }
 2176                        return Response.FromValue(value, message.Response);
 177                    }
 178                default:
 0179                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 180            }
 2181        }
 182
 183        /// <summary> Lists the operations available from this provider. </summary>
 184        /// <param name="skipToken"> A skip token is used to continue retrieving items after an operation returns a part
 185        /// <param name="cancellationToken"> The cancellation token to use. </param>
 186        public Response<OperationDefinitionListResult> List(string skipToken = null, CancellationToken cancellationToken
 187        {
 2188            using var message = CreateListRequest(skipToken);
 2189            _pipeline.Send(message, cancellationToken);
 2190            switch (message.Response.Status)
 191            {
 192                case 200:
 193                    {
 2194                        OperationDefinitionListResult value = default;
 2195                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2196                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 197                        {
 0198                            value = null;
 199                        }
 200                        else
 201                        {
 2202                            value = OperationDefinitionListResult.DeserializeOperationDefinitionListResult(document.Root
 203                        }
 2204                        return Response.FromValue(value, message.Response);
 205                    }
 206                default:
 0207                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 208            }
 2209        }
 210
 211        internal HttpMessage CreateListNextPageRequest(string nextLink, string skipToken)
 212        {
 0213            var message = _pipeline.CreateMessage();
 0214            var request = message.Request;
 0215            request.Method = RequestMethod.Get;
 0216            var uri = new RawRequestUriBuilder();
 0217            uri.Reset(endpoint);
 0218            uri.AppendRawNextLink(nextLink, false);
 0219            request.Uri = uri;
 0220            return message;
 221        }
 222
 223        /// <summary> Lists the operations available from this provider. </summary>
 224        /// <param name="nextLink"> The URL to the next page of results. </param>
 225        /// <param name="skipToken"> A skip token is used to continue retrieving items after an operation returns a part
 226        /// <param name="cancellationToken"> The cancellation token to use. </param>
 227        public async Task<Response<OperationDefinitionListResult>> ListNextPageAsync(string nextLink, string skipToken =
 228        {
 0229            if (nextLink == null)
 230            {
 0231                throw new ArgumentNullException(nameof(nextLink));
 232            }
 233
 0234            using var message = CreateListNextPageRequest(nextLink, skipToken);
 0235            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0236            switch (message.Response.Status)
 237            {
 238                case 200:
 239                    {
 0240                        OperationDefinitionListResult value = default;
 0241                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0242                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 243                        {
 0244                            value = null;
 245                        }
 246                        else
 247                        {
 0248                            value = OperationDefinitionListResult.DeserializeOperationDefinitionListResult(document.Root
 249                        }
 0250                        return Response.FromValue(value, message.Response);
 251                    }
 252                default:
 0253                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 254            }
 0255        }
 256
 257        /// <summary> Lists the operations available from this provider. </summary>
 258        /// <param name="nextLink"> The URL to the next page of results. </param>
 259        /// <param name="skipToken"> A skip token is used to continue retrieving items after an operation returns a part
 260        /// <param name="cancellationToken"> The cancellation token to use. </param>
 261        public Response<OperationDefinitionListResult> ListNextPage(string nextLink, string skipToken = null, Cancellati
 262        {
 0263            if (nextLink == null)
 264            {
 0265                throw new ArgumentNullException(nameof(nextLink));
 266            }
 267
 0268            using var message = CreateListNextPageRequest(nextLink, skipToken);
 0269            _pipeline.Send(message, cancellationToken);
 0270            switch (message.Response.Status)
 271            {
 272                case 200:
 273                    {
 0274                        OperationDefinitionListResult value = default;
 0275                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0276                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 277                        {
 0278                            value = null;
 279                        }
 280                        else
 281                        {
 0282                            value = OperationDefinitionListResult.DeserializeOperationDefinitionListResult(document.Root
 283                        }
 0284                        return Response.FromValue(value, message.Response);
 285                    }
 286                default:
 0287                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 288            }
 0289        }
 290    }
 291}