< Summary

Class:Azure.ResourceManager.KeyVault.PrivateLinkResourcesRestOperations
Assembly:Azure.ResourceManager.KeyVault
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.ResourceManager.KeyVault\src\Generated\PrivateLinkResourcesRestOperations.cs
Covered lines:0
Uncovered lines:51
Coverable lines:51
Total lines:136
Line coverage:0% (0 of 51)
Covered branches:0
Total branches:18
Branch coverage:0% (0 of 18)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateListByVaultRequest(...)-0%100%
ListByVaultAsync()-0%0%
ListByVault(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.ResourceManager.KeyVault\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.KeyVault.Models;
 16
 17namespace Azure.ResourceManager.KeyVault
 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"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 31        /// <param name="endpoint"> server parameter. </param>
 32        /// <param name="apiVersion"> Api Version. </param>
 33        /// <exception cref="ArgumentNullException"> <paramref name="subscriptionId"/> or <paramref name="apiVersion"/> 
 034        public PrivateLinkResourcesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub
 35        {
 036            if (subscriptionId == null)
 37            {
 038                throw new ArgumentNullException(nameof(subscriptionId));
 39            }
 040            endpoint ??= new Uri("https://management.azure.com");
 041            if (apiVersion == null)
 42            {
 043                throw new ArgumentNullException(nameof(apiVersion));
 44            }
 45
 046            this.subscriptionId = subscriptionId;
 047            this.endpoint = endpoint;
 048            this.apiVersion = apiVersion;
 049            _clientDiagnostics = clientDiagnostics;
 050            _pipeline = pipeline;
 051        }
 52
 53        internal HttpMessage CreateListByVaultRequest(string resourceGroupName, string vaultName)
 54        {
 055            var message = _pipeline.CreateMessage();
 056            var request = message.Request;
 057            request.Method = RequestMethod.Get;
 058            var uri = new RawRequestUriBuilder();
 059            uri.Reset(endpoint);
 060            uri.AppendPath("/subscriptions/", false);
 061            uri.AppendPath(subscriptionId, true);
 062            uri.AppendPath("/resourceGroups/", false);
 063            uri.AppendPath(resourceGroupName, true);
 064            uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false);
 065            uri.AppendPath(vaultName, true);
 066            uri.AppendPath("/privateLinkResources", false);
 067            uri.AppendQuery("api-version", apiVersion, true);
 068            request.Uri = uri;
 069            return message;
 70        }
 71
 72        /// <summary> Gets the private link resources supported for the key vault. </summary>
 73        /// <param name="resourceGroupName"> Name of the resource group that contains the key vault. </param>
 74        /// <param name="vaultName"> The name of the key vault. </param>
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="vaultName"/
 77        public async Task<Response<PrivateLinkResourceListResult>> ListByVaultAsync(string resourceGroupName, string vau
 78        {
 079            if (resourceGroupName == null)
 80            {
 081                throw new ArgumentNullException(nameof(resourceGroupName));
 82            }
 083            if (vaultName == null)
 84            {
 085                throw new ArgumentNullException(nameof(vaultName));
 86            }
 87
 088            using var message = CreateListByVaultRequest(resourceGroupName, vaultName);
 089            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 090            switch (message.Response.Status)
 91            {
 92                case 200:
 93                    {
 94                        PrivateLinkResourceListResult value = default;
 095                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 096                        value = PrivateLinkResourceListResult.DeserializePrivateLinkResourceListResult(document.RootElem
 097                        return Response.FromValue(value, message.Response);
 98                    }
 99                default:
 0100                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 101            }
 0102        }
 103
 104        /// <summary> Gets the private link resources supported for the key vault. </summary>
 105        /// <param name="resourceGroupName"> Name of the resource group that contains the key vault. </param>
 106        /// <param name="vaultName"> The name of the key vault. </param>
 107        /// <param name="cancellationToken"> The cancellation token to use. </param>
 108        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="vaultName"/
 109        public Response<PrivateLinkResourceListResult> ListByVault(string resourceGroupName, string vaultName, Cancellat
 110        {
 0111            if (resourceGroupName == null)
 112            {
 0113                throw new ArgumentNullException(nameof(resourceGroupName));
 114            }
 0115            if (vaultName == null)
 116            {
 0117                throw new ArgumentNullException(nameof(vaultName));
 118            }
 119
 0120            using var message = CreateListByVaultRequest(resourceGroupName, vaultName);
 0121            _pipeline.Send(message, cancellationToken);
 0122            switch (message.Response.Status)
 123            {
 124                case 200:
 125                    {
 126                        PrivateLinkResourceListResult value = default;
 0127                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0128                        value = PrivateLinkResourceListResult.DeserializePrivateLinkResourceListResult(document.RootElem
 0129                        return Response.FromValue(value, message.Response);
 130                    }
 131                default:
 0132                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 133            }
 0134        }
 135    }
 136}