< Summary

Class:Azure.ResourceManager.Network.ServiceAssociationLinksRestOperations
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\ServiceAssociationLinksRestOperations.cs
Covered lines:0
Uncovered lines:60
Coverable lines:60
Total lines:153
Line coverage:0% (0 of 60)
Covered branches:0
Total branches:24
Branch coverage:0% (0 of 24)

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\ServiceAssociationLinksRestOperations.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 ServiceAssociationLinksRestOperations
 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 ServiceAssociationLinksRestOperations. </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 ServiceAssociationLinksRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string 
 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 resourceGroupName, string virtualNetworkName, string subnetName)
 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("/resourceGroups/", false);
 056            uri.AppendPath(resourceGroupName, true);
 057            uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false);
 058            uri.AppendPath(virtualNetworkName, true);
 059            uri.AppendPath("/subnets/", false);
 060            uri.AppendPath(subnetName, true);
 061            uri.AppendPath("/ServiceAssociationLinks", false);
 062            uri.AppendQuery("api-version", "2020-04-01", true);
 063            request.Uri = uri;
 064            return message;
 65        }
 66
 67        /// <summary> Gets a list of service association links for a subnet. </summary>
 68        /// <param name="resourceGroupName"> The name of the resource group. </param>
 69        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 70        /// <param name="subnetName"> The name of the subnet. </param>
 71        /// <param name="cancellationToken"> The cancellation token to use. </param>
 72        public async Task<Response<ServiceAssociationLinksListResult>> ListAsync(string resourceGroupName, string virtua
 73        {
 074            if (resourceGroupName == null)
 75            {
 076                throw new ArgumentNullException(nameof(resourceGroupName));
 77            }
 078            if (virtualNetworkName == null)
 79            {
 080                throw new ArgumentNullException(nameof(virtualNetworkName));
 81            }
 082            if (subnetName == null)
 83            {
 084                throw new ArgumentNullException(nameof(subnetName));
 85            }
 86
 087            using var message = CreateListRequest(resourceGroupName, virtualNetworkName, subnetName);
 088            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 089            switch (message.Response.Status)
 90            {
 91                case 200:
 92                    {
 093                        ServiceAssociationLinksListResult value = default;
 094                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 095                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 96                        {
 097                            value = null;
 98                        }
 99                        else
 100                        {
 0101                            value = ServiceAssociationLinksListResult.DeserializeServiceAssociationLinksListResult(docum
 102                        }
 0103                        return Response.FromValue(value, message.Response);
 104                    }
 105                default:
 0106                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 107            }
 0108        }
 109
 110        /// <summary> Gets a list of service association links for a subnet. </summary>
 111        /// <param name="resourceGroupName"> The name of the resource group. </param>
 112        /// <param name="virtualNetworkName"> The name of the virtual network. </param>
 113        /// <param name="subnetName"> The name of the subnet. </param>
 114        /// <param name="cancellationToken"> The cancellation token to use. </param>
 115        public Response<ServiceAssociationLinksListResult> List(string resourceGroupName, string virtualNetworkName, str
 116        {
 0117            if (resourceGroupName == null)
 118            {
 0119                throw new ArgumentNullException(nameof(resourceGroupName));
 120            }
 0121            if (virtualNetworkName == null)
 122            {
 0123                throw new ArgumentNullException(nameof(virtualNetworkName));
 124            }
 0125            if (subnetName == null)
 126            {
 0127                throw new ArgumentNullException(nameof(subnetName));
 128            }
 129
 0130            using var message = CreateListRequest(resourceGroupName, virtualNetworkName, subnetName);
 0131            _pipeline.Send(message, cancellationToken);
 0132            switch (message.Response.Status)
 133            {
 134                case 200:
 135                    {
 0136                        ServiceAssociationLinksListResult value = default;
 0137                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0138                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 139                        {
 0140                            value = null;
 141                        }
 142                        else
 143                        {
 0144                            value = ServiceAssociationLinksListResult.DeserializeServiceAssociationLinksListResult(docum
 145                        }
 0146                        return Response.FromValue(value, message.Response);
 147                    }
 148                default:
 0149                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 150            }
 0151        }
 152    }
 153}