< Summary

Class:Azure.ResourceManager.Storage.PrivateLinkResourcesRestOperations
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\PrivateLinkResourcesRestOperations.cs
Covered lines:47
Uncovered lines:10
Coverable lines:57
Total lines:148
Line coverage:82.4% (47 of 57)
Covered branches:11
Total branches:22
Branch coverage:50% (11 of 22)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
CreateListByStorageAccountRequest(...)-100%100%
ListByStorageAccountAsync()-73.33%50%
ListByStorageAccount(...)-73.33%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\PrivateLinkResourcesRestOperations.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 PrivateLinkResourcesRestOperations
 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 PrivateLinkResourcesRestOperations. </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 ID of the target subscription. </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
 24034        public PrivateLinkResourcesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub
 35        {
 24036            if (subscriptionId == null)
 37            {
 038                throw new ArgumentNullException(nameof(subscriptionId));
 39            }
 24040            endpoint ??= new Uri("https://management.azure.com");
 24041            if (apiVersion == null)
 42            {
 043                throw new ArgumentNullException(nameof(apiVersion));
 44            }
 45
 24046            this.subscriptionId = subscriptionId;
 24047            this.endpoint = endpoint;
 24048            this.apiVersion = apiVersion;
 24049            _clientDiagnostics = clientDiagnostics;
 24050            _pipeline = pipeline;
 24051        }
 52
 53        internal HttpMessage CreateListByStorageAccountRequest(string resourceGroupName, string accountName)
 54        {
 455            var message = _pipeline.CreateMessage();
 456            var request = message.Request;
 457            request.Method = RequestMethod.Get;
 458            var uri = new RawRequestUriBuilder();
 459            uri.Reset(endpoint);
 460            uri.AppendPath("/subscriptions/", false);
 461            uri.AppendPath(subscriptionId, true);
 462            uri.AppendPath("/resourceGroups/", false);
 463            uri.AppendPath(resourceGroupName, true);
 464            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 465            uri.AppendPath(accountName, true);
 466            uri.AppendPath("/privateLinkResources", false);
 467            uri.AppendQuery("api-version", apiVersion, true);
 468            request.Uri = uri;
 469            return message;
 70        }
 71
 72        /// <summary> Gets the private link resources that need to be created for a storage account. </summary>
 73        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 74        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        public async Task<Response<PrivateLinkResourceListResult>> ListByStorageAccountAsync(string resourceGroupName, s
 77        {
 278            if (resourceGroupName == null)
 79            {
 080                throw new ArgumentNullException(nameof(resourceGroupName));
 81            }
 282            if (accountName == null)
 83            {
 084                throw new ArgumentNullException(nameof(accountName));
 85            }
 86
 287            using var message = CreateListByStorageAccountRequest(resourceGroupName, accountName);
 288            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 289            switch (message.Response.Status)
 90            {
 91                case 200:
 92                    {
 293                        PrivateLinkResourceListResult value = default;
 294                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 295                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 96                        {
 097                            value = null;
 98                        }
 99                        else
 100                        {
 2101                            value = PrivateLinkResourceListResult.DeserializePrivateLinkResourceListResult(document.Root
 102                        }
 2103                        return Response.FromValue(value, message.Response);
 104                    }
 105                default:
 0106                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 107            }
 2108        }
 109
 110        /// <summary> Gets the private link resources that need to be created for a storage account. </summary>
 111        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 112        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 113        /// <param name="cancellationToken"> The cancellation token to use. </param>
 114        public Response<PrivateLinkResourceListResult> ListByStorageAccount(string resourceGroupName, string accountName
 115        {
 2116            if (resourceGroupName == null)
 117            {
 0118                throw new ArgumentNullException(nameof(resourceGroupName));
 119            }
 2120            if (accountName == null)
 121            {
 0122                throw new ArgumentNullException(nameof(accountName));
 123            }
 124
 2125            using var message = CreateListByStorageAccountRequest(resourceGroupName, accountName);
 2126            _pipeline.Send(message, cancellationToken);
 2127            switch (message.Response.Status)
 128            {
 129                case 200:
 130                    {
 2131                        PrivateLinkResourceListResult value = default;
 2132                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2133                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 134                        {
 0135                            value = null;
 136                        }
 137                        else
 138                        {
 2139                            value = PrivateLinkResourceListResult.DeserializePrivateLinkResourceListResult(document.Root
 140                        }
 2141                        return Response.FromValue(value, message.Response);
 142                    }
 143                default:
 0144                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 145            }
 2146        }
 147    }
 148}