< Summary

Class:Azure.ResourceManager.Network.ServiceTagsRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ServiceTagsRestOperations.cs
Covered lines:0
Uncovered lines:48
Coverable lines:48
Total lines:129
Line coverage:0% (0 of 48)
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%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ServiceTagsRestOperations.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.Network.Models;
 16
 17namespace Azure.ResourceManager.Network
 18{
 19    internal partial class ServiceTagsRestOperations
 20    {
 21        private string subscriptionId;
 22        private Uri endpoint;
 23        private ClientDiagnostics _clientDiagnostics;
 24        private HttpPipeline _pipeline;
 25
 26        /// <summary> Initializes a new instance of ServiceTagsRestOperations. </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="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 032        public ServiceTagsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription
 33        {
 034            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 038            endpoint ??= new Uri("https://management.azure.com");
 39
 040            this.subscriptionId = subscriptionId;
 041            this.endpoint = endpoint;
 042            _clientDiagnostics = clientDiagnostics;
 043            _pipeline = pipeline;
 044        }
 45
 46        internal HttpMessage CreateListRequest(string location)
 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("/subscriptions/", false);
 054            uri.AppendPath(subscriptionId, true);
 055            uri.AppendPath("/providers/Microsoft.Network/locations/", false);
 056            uri.AppendPath(location, true);
 057            uri.AppendPath("/serviceTags", false);
 058            uri.AppendQuery("api-version", "2020-04-01", true);
 059            request.Uri = uri;
 060            return message;
 61        }
 62
 63        /// <summary> Gets a list of service tag information resources. </summary>
 64        /// <param name="location"> The location that will be used as a reference for version (not as a filter based on 
 65        /// <param name="cancellationToken"> The cancellation token to use. </param>
 66        public async Task<Response<ServiceTagsListResult>> ListAsync(string location, CancellationToken cancellationToke
 67        {
 068            if (location == null)
 69            {
 070                throw new ArgumentNullException(nameof(location));
 71            }
 72
 073            using var message = CreateListRequest(location);
 074            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 075            switch (message.Response.Status)
 76            {
 77                case 200:
 78                    {
 079                        ServiceTagsListResult value = default;
 080                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 081                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 82                        {
 083                            value = null;
 84                        }
 85                        else
 86                        {
 087                            value = ServiceTagsListResult.DeserializeServiceTagsListResult(document.RootElement);
 88                        }
 089                        return Response.FromValue(value, message.Response);
 90                    }
 91                default:
 092                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 93            }
 094        }
 95
 96        /// <summary> Gets a list of service tag information resources. </summary>
 97        /// <param name="location"> The location that will be used as a reference for version (not as a filter based on 
 98        /// <param name="cancellationToken"> The cancellation token to use. </param>
 99        public Response<ServiceTagsListResult> List(string location, CancellationToken cancellationToken = default)
 100        {
 0101            if (location == null)
 102            {
 0103                throw new ArgumentNullException(nameof(location));
 104            }
 105
 0106            using var message = CreateListRequest(location);
 0107            _pipeline.Send(message, cancellationToken);
 0108            switch (message.Response.Status)
 109            {
 110                case 200:
 111                    {
 0112                        ServiceTagsListResult value = default;
 0113                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0114                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 115                        {
 0116                            value = null;
 117                        }
 118                        else
 119                        {
 0120                            value = ServiceTagsListResult.DeserializeServiceTagsListResult(document.RootElement);
 121                        }
 0122                        return Response.FromValue(value, message.Response);
 123                    }
 124                default:
 0125                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 126            }
 0127        }
 128    }
 129}