< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%
CreatePutRequest(...)-0%100%
PutAsync()-0%0%
Put(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.ResourceManager.KeyVault\src\Generated\PrivateEndpointConnectionsRestOperations.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 PrivateEndpointConnectionsRestOperations
 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 PrivateEndpointConnectionsRestOperations. </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 PrivateEndpointConnectionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, stri
 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 CreateGetRequest(string resourceGroupName, string vaultName, string privateEndpointConnecti
 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("/privateEndpointConnections/", false);
 067            uri.AppendPath(privateEndpointConnectionName, true);
 068            uri.AppendQuery("api-version", apiVersion, true);
 069            request.Uri = uri;
 070            return message;
 71        }
 72
 73        /// <summary> Gets the specified private endpoint connection associated with the key vault. </summary>
 74        /// <param name="resourceGroupName"> Name of the resource group that contains the key vault. </param>
 75        /// <param name="vaultName"> The name of the key vault. </param>
 76        /// <param name="privateEndpointConnectionName"> Name of the private endpoint connection associated with the key
 77        /// <param name="cancellationToken"> The cancellation token to use. </param>
 78        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="vaultName"/>,
 79        public async Task<Response<PrivateEndpointConnection>> GetAsync(string resourceGroupName, string vaultName, stri
 80        {
 081            if (resourceGroupName == null)
 82            {
 083                throw new ArgumentNullException(nameof(resourceGroupName));
 84            }
 085            if (vaultName == null)
 86            {
 087                throw new ArgumentNullException(nameof(vaultName));
 88            }
 089            if (privateEndpointConnectionName == null)
 90            {
 091                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 92            }
 93
 094            using var message = CreateGetRequest(resourceGroupName, vaultName, privateEndpointConnectionName);
 095            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 096            switch (message.Response.Status)
 97            {
 98                case 200:
 99                    {
 100                        PrivateEndpointConnection value = default;
 0101                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0102                        value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement);
 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 the specified private endpoint connection associated with the key vault. </summary>
 111        /// <param name="resourceGroupName"> Name of the resource group that contains the key vault. </param>
 112        /// <param name="vaultName"> The name of the key vault. </param>
 113        /// <param name="privateEndpointConnectionName"> Name of the private endpoint connection associated with the key
 114        /// <param name="cancellationToken"> The cancellation token to use. </param>
 115        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="vaultName"/>,
 116        public Response<PrivateEndpointConnection> Get(string resourceGroupName, string vaultName, string privateEndpoin
 117        {
 0118            if (resourceGroupName == null)
 119            {
 0120                throw new ArgumentNullException(nameof(resourceGroupName));
 121            }
 0122            if (vaultName == null)
 123            {
 0124                throw new ArgumentNullException(nameof(vaultName));
 125            }
 0126            if (privateEndpointConnectionName == null)
 127            {
 0128                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 129            }
 130
 0131            using var message = CreateGetRequest(resourceGroupName, vaultName, privateEndpointConnectionName);
 0132            _pipeline.Send(message, cancellationToken);
 0133            switch (message.Response.Status)
 134            {
 135                case 200:
 136                    {
 137                        PrivateEndpointConnection value = default;
 0138                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0139                        value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement);
 0140                        return Response.FromValue(value, message.Response);
 141                    }
 142                default:
 0143                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 144            }
 0145        }
 146
 147        internal HttpMessage CreatePutRequest(string resourceGroupName, string vaultName, string privateEndpointConnecti
 148        {
 0149            var message = _pipeline.CreateMessage();
 0150            var request = message.Request;
 0151            request.Method = RequestMethod.Put;
 0152            var uri = new RawRequestUriBuilder();
 0153            uri.Reset(endpoint);
 0154            uri.AppendPath("/subscriptions/", false);
 0155            uri.AppendPath(subscriptionId, true);
 0156            uri.AppendPath("/resourceGroups/", false);
 0157            uri.AppendPath(resourceGroupName, true);
 0158            uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false);
 0159            uri.AppendPath(vaultName, true);
 0160            uri.AppendPath("/privateEndpointConnections/", false);
 0161            uri.AppendPath(privateEndpointConnectionName, true);
 0162            uri.AppendQuery("api-version", apiVersion, true);
 0163            request.Uri = uri;
 0164            request.Headers.Add("Content-Type", "application/json");
 0165            var content = new Utf8JsonRequestContent();
 0166            content.JsonWriter.WriteObjectValue(properties);
 0167            request.Content = content;
 0168            return message;
 169        }
 170
 171        /// <summary> Updates the specified private endpoint connection associated with the key vault. </summary>
 172        /// <param name="resourceGroupName"> Name of the resource group that contains the key vault. </param>
 173        /// <param name="vaultName"> The name of the key vault. </param>
 174        /// <param name="privateEndpointConnectionName"> Name of the private endpoint connection associated with the key
 175        /// <param name="properties"> The intended state of private endpoint connection. </param>
 176        /// <param name="cancellationToken"> The cancellation token to use. </param>
 177        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="vaultName"/>,
 178        public async Task<ResponseWithHeaders<PrivateEndpointConnection, PrivateEndpointConnectionsPutHeaders>> PutAsync
 179        {
 0180            if (resourceGroupName == null)
 181            {
 0182                throw new ArgumentNullException(nameof(resourceGroupName));
 183            }
 0184            if (vaultName == null)
 185            {
 0186                throw new ArgumentNullException(nameof(vaultName));
 187            }
 0188            if (privateEndpointConnectionName == null)
 189            {
 0190                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 191            }
 0192            if (properties == null)
 193            {
 0194                throw new ArgumentNullException(nameof(properties));
 195            }
 196
 0197            using var message = CreatePutRequest(resourceGroupName, vaultName, privateEndpointConnectionName, properties
 0198            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0199            var headers = new PrivateEndpointConnectionsPutHeaders(message.Response);
 0200            switch (message.Response.Status)
 201            {
 202                case 200:
 203                    {
 204                        PrivateEndpointConnection value = default;
 0205                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0206                        value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement);
 0207                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 208                    }
 209                default:
 0210                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 211            }
 0212        }
 213
 214        /// <summary> Updates the specified private endpoint connection associated with the key vault. </summary>
 215        /// <param name="resourceGroupName"> Name of the resource group that contains the key vault. </param>
 216        /// <param name="vaultName"> The name of the key vault. </param>
 217        /// <param name="privateEndpointConnectionName"> Name of the private endpoint connection associated with the key
 218        /// <param name="properties"> The intended state of private endpoint connection. </param>
 219        /// <param name="cancellationToken"> The cancellation token to use. </param>
 220        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="vaultName"/>,
 221        public ResponseWithHeaders<PrivateEndpointConnection, PrivateEndpointConnectionsPutHeaders> Put(string resourceG
 222        {
 0223            if (resourceGroupName == null)
 224            {
 0225                throw new ArgumentNullException(nameof(resourceGroupName));
 226            }
 0227            if (vaultName == null)
 228            {
 0229                throw new ArgumentNullException(nameof(vaultName));
 230            }
 0231            if (privateEndpointConnectionName == null)
 232            {
 0233                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 234            }
 0235            if (properties == null)
 236            {
 0237                throw new ArgumentNullException(nameof(properties));
 238            }
 239
 0240            using var message = CreatePutRequest(resourceGroupName, vaultName, privateEndpointConnectionName, properties
 0241            _pipeline.Send(message, cancellationToken);
 0242            var headers = new PrivateEndpointConnectionsPutHeaders(message.Response);
 0243            switch (message.Response.Status)
 244            {
 245                case 200:
 246                    {
 247                        PrivateEndpointConnection value = default;
 0248                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0249                        value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement);
 0250                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
 251                    }
 252                default:
 0253                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 254            }
 0255        }
 256
 257        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string vaultName, string privateEndpointConne
 258        {
 0259            var message = _pipeline.CreateMessage();
 0260            var request = message.Request;
 0261            request.Method = RequestMethod.Delete;
 0262            var uri = new RawRequestUriBuilder();
 0263            uri.Reset(endpoint);
 0264            uri.AppendPath("/subscriptions/", false);
 0265            uri.AppendPath(subscriptionId, true);
 0266            uri.AppendPath("/resourceGroups/", false);
 0267            uri.AppendPath(resourceGroupName, true);
 0268            uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false);
 0269            uri.AppendPath(vaultName, true);
 0270            uri.AppendPath("/privateEndpointConnections/", false);
 0271            uri.AppendPath(privateEndpointConnectionName, true);
 0272            uri.AppendQuery("api-version", apiVersion, true);
 0273            request.Uri = uri;
 0274            return message;
 275        }
 276
 277        /// <summary> Deletes the specified private endpoint connection associated with the key vault. </summary>
 278        /// <param name="resourceGroupName"> Name of the resource group that contains the key vault. </param>
 279        /// <param name="vaultName"> The name of the key vault. </param>
 280        /// <param name="privateEndpointConnectionName"> Name of the private endpoint connection associated with the key
 281        /// <param name="cancellationToken"> The cancellation token to use. </param>
 282        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="vaultName"/>,
 283        public async Task<ResponseWithHeaders<PrivateEndpointConnectionsDeleteHeaders>> DeleteAsync(string resourceGroup
 284        {
 0285            if (resourceGroupName == null)
 286            {
 0287                throw new ArgumentNullException(nameof(resourceGroupName));
 288            }
 0289            if (vaultName == null)
 290            {
 0291                throw new ArgumentNullException(nameof(vaultName));
 292            }
 0293            if (privateEndpointConnectionName == null)
 294            {
 0295                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 296            }
 297
 0298            using var message = CreateDeleteRequest(resourceGroupName, vaultName, privateEndpointConnectionName);
 0299            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0300            var headers = new PrivateEndpointConnectionsDeleteHeaders(message.Response);
 0301            switch (message.Response.Status)
 302            {
 303                case 200:
 304                case 202:
 305                case 204:
 0306                    return ResponseWithHeaders.FromValue(headers, message.Response);
 307                default:
 0308                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 309            }
 0310        }
 311
 312        /// <summary> Deletes the specified private endpoint connection associated with the key vault. </summary>
 313        /// <param name="resourceGroupName"> Name of the resource group that contains the key vault. </param>
 314        /// <param name="vaultName"> The name of the key vault. </param>
 315        /// <param name="privateEndpointConnectionName"> Name of the private endpoint connection associated with the key
 316        /// <param name="cancellationToken"> The cancellation token to use. </param>
 317        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="vaultName"/>,
 318        public ResponseWithHeaders<PrivateEndpointConnectionsDeleteHeaders> Delete(string resourceGroupName, string vaul
 319        {
 0320            if (resourceGroupName == null)
 321            {
 0322                throw new ArgumentNullException(nameof(resourceGroupName));
 323            }
 0324            if (vaultName == null)
 325            {
 0326                throw new ArgumentNullException(nameof(vaultName));
 327            }
 0328            if (privateEndpointConnectionName == null)
 329            {
 0330                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 331            }
 332
 0333            using var message = CreateDeleteRequest(resourceGroupName, vaultName, privateEndpointConnectionName);
 0334            _pipeline.Send(message, cancellationToken);
 0335            var headers = new PrivateEndpointConnectionsDeleteHeaders(message.Response);
 0336            switch (message.Response.Status)
 337            {
 338                case 200:
 339                case 202:
 340                case 204:
 0341                    return ResponseWithHeaders.FromValue(headers, message.Response);
 342                default:
 0343                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 344            }
 0345        }
 346    }
 347}