< Summary

Class:Azure.ResourceManager.Storage.PrivateEndpointConnectionsRestOperations
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\PrivateEndpointConnectionsRestOperations.cs
Covered lines:10
Uncovered lines:195
Coverable lines:205
Total lines:458
Line coverage:4.8% (10 of 205)
Covered branches:3
Total branches:86
Branch coverage:3.4% (3 of 86)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
CreateListRequest(...)-0%100%
ListAsync()-0%0%
List(...)-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\storage\Azure.ResourceManager.Storage\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.Storage.Models;
 16
 17namespace Azure.ResourceManager.Storage
 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"> 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 PrivateEndpointConnectionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, stri
 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 CreateListRequest(string resourceGroupName, string accountName)
 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.Storage/storageAccounts/", false);
 065            uri.AppendPath(accountName, true);
 066            uri.AppendPath("/privateEndpointConnections", false);
 067            uri.AppendQuery("api-version", apiVersion, true);
 068            request.Uri = uri;
 069            return message;
 70        }
 71
 72        /// <summary> List all the private endpoint connections associated with the 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<PrivateEndpointConnectionListResult>> ListAsync(string resourceGroupName, string acco
 77        {
 078            if (resourceGroupName == null)
 79            {
 080                throw new ArgumentNullException(nameof(resourceGroupName));
 81            }
 082            if (accountName == null)
 83            {
 084                throw new ArgumentNullException(nameof(accountName));
 85            }
 86
 087            using var message = CreateListRequest(resourceGroupName, accountName);
 088            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 089            switch (message.Response.Status)
 90            {
 91                case 200:
 92                    {
 093                        PrivateEndpointConnectionListResult 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 = PrivateEndpointConnectionListResult.DeserializePrivateEndpointConnectionListResult(d
 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> List all the private endpoint connections associated with the 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<PrivateEndpointConnectionListResult> List(string resourceGroupName, string accountName, Cancella
 115        {
 0116            if (resourceGroupName == null)
 117            {
 0118                throw new ArgumentNullException(nameof(resourceGroupName));
 119            }
 0120            if (accountName == null)
 121            {
 0122                throw new ArgumentNullException(nameof(accountName));
 123            }
 124
 0125            using var message = CreateListRequest(resourceGroupName, accountName);
 0126            _pipeline.Send(message, cancellationToken);
 0127            switch (message.Response.Status)
 128            {
 129                case 200:
 130                    {
 0131                        PrivateEndpointConnectionListResult value = default;
 0132                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0133                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 134                        {
 0135                            value = null;
 136                        }
 137                        else
 138                        {
 0139                            value = PrivateEndpointConnectionListResult.DeserializePrivateEndpointConnectionListResult(d
 140                        }
 0141                        return Response.FromValue(value, message.Response);
 142                    }
 143                default:
 0144                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 145            }
 0146        }
 147
 148        internal HttpMessage CreateGetRequest(string resourceGroupName, string accountName, string privateEndpointConnec
 149        {
 0150            var message = _pipeline.CreateMessage();
 0151            var request = message.Request;
 0152            request.Method = RequestMethod.Get;
 0153            var uri = new RawRequestUriBuilder();
 0154            uri.Reset(endpoint);
 0155            uri.AppendPath("/subscriptions/", false);
 0156            uri.AppendPath(subscriptionId, true);
 0157            uri.AppendPath("/resourceGroups/", false);
 0158            uri.AppendPath(resourceGroupName, true);
 0159            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 0160            uri.AppendPath(accountName, true);
 0161            uri.AppendPath("/privateEndpointConnections/", false);
 0162            uri.AppendPath(privateEndpointConnectionName, true);
 0163            uri.AppendQuery("api-version", apiVersion, true);
 0164            request.Uri = uri;
 0165            return message;
 166        }
 167
 168        /// <summary> Gets the specified private endpoint connection associated with the storage account. </summary>
 169        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 170        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 171        /// <param name="privateEndpointConnectionName"> The name of the private endpoint connection associated with the
 172        /// <param name="cancellationToken"> The cancellation token to use. </param>
 173        public async Task<Response<PrivateEndpointConnection>> GetAsync(string resourceGroupName, string accountName, st
 174        {
 0175            if (resourceGroupName == null)
 176            {
 0177                throw new ArgumentNullException(nameof(resourceGroupName));
 178            }
 0179            if (accountName == null)
 180            {
 0181                throw new ArgumentNullException(nameof(accountName));
 182            }
 0183            if (privateEndpointConnectionName == null)
 184            {
 0185                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 186            }
 187
 0188            using var message = CreateGetRequest(resourceGroupName, accountName, privateEndpointConnectionName);
 0189            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0190            switch (message.Response.Status)
 191            {
 192                case 200:
 193                    {
 0194                        PrivateEndpointConnection value = default;
 0195                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0196                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 197                        {
 0198                            value = null;
 199                        }
 200                        else
 201                        {
 0202                            value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement)
 203                        }
 0204                        return Response.FromValue(value, message.Response);
 205                    }
 206                default:
 0207                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 208            }
 0209        }
 210
 211        /// <summary> Gets the specified private endpoint connection associated with the storage account. </summary>
 212        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 213        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 214        /// <param name="privateEndpointConnectionName"> The name of the private endpoint connection associated with the
 215        /// <param name="cancellationToken"> The cancellation token to use. </param>
 216        public Response<PrivateEndpointConnection> Get(string resourceGroupName, string accountName, string privateEndpo
 217        {
 0218            if (resourceGroupName == null)
 219            {
 0220                throw new ArgumentNullException(nameof(resourceGroupName));
 221            }
 0222            if (accountName == null)
 223            {
 0224                throw new ArgumentNullException(nameof(accountName));
 225            }
 0226            if (privateEndpointConnectionName == null)
 227            {
 0228                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 229            }
 230
 0231            using var message = CreateGetRequest(resourceGroupName, accountName, privateEndpointConnectionName);
 0232            _pipeline.Send(message, cancellationToken);
 0233            switch (message.Response.Status)
 234            {
 235                case 200:
 236                    {
 0237                        PrivateEndpointConnection value = default;
 0238                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0239                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 240                        {
 0241                            value = null;
 242                        }
 243                        else
 244                        {
 0245                            value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement)
 246                        }
 0247                        return Response.FromValue(value, message.Response);
 248                    }
 249                default:
 0250                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 251            }
 0252        }
 253
 254        internal HttpMessage CreatePutRequest(string resourceGroupName, string accountName, string privateEndpointConnec
 255        {
 0256            var message = _pipeline.CreateMessage();
 0257            var request = message.Request;
 0258            request.Method = RequestMethod.Put;
 0259            var uri = new RawRequestUriBuilder();
 0260            uri.Reset(endpoint);
 0261            uri.AppendPath("/subscriptions/", false);
 0262            uri.AppendPath(subscriptionId, true);
 0263            uri.AppendPath("/resourceGroups/", false);
 0264            uri.AppendPath(resourceGroupName, true);
 0265            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 0266            uri.AppendPath(accountName, true);
 0267            uri.AppendPath("/privateEndpointConnections/", false);
 0268            uri.AppendPath(privateEndpointConnectionName, true);
 0269            uri.AppendQuery("api-version", apiVersion, true);
 0270            request.Uri = uri;
 0271            request.Headers.Add("Content-Type", "application/json");
 0272            var content = new Utf8JsonRequestContent();
 0273            content.JsonWriter.WriteObjectValue(properties);
 0274            request.Content = content;
 0275            return message;
 276        }
 277
 278        /// <summary> Update the state of specified private endpoint connection associated with the storage account. </s
 279        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 280        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 281        /// <param name="privateEndpointConnectionName"> The name of the private endpoint connection associated with the
 282        /// <param name="properties"> The private endpoint connection properties. </param>
 283        /// <param name="cancellationToken"> The cancellation token to use. </param>
 284        public async Task<Response<PrivateEndpointConnection>> PutAsync(string resourceGroupName, string accountName, st
 285        {
 0286            if (resourceGroupName == null)
 287            {
 0288                throw new ArgumentNullException(nameof(resourceGroupName));
 289            }
 0290            if (accountName == null)
 291            {
 0292                throw new ArgumentNullException(nameof(accountName));
 293            }
 0294            if (privateEndpointConnectionName == null)
 295            {
 0296                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 297            }
 0298            if (properties == null)
 299            {
 0300                throw new ArgumentNullException(nameof(properties));
 301            }
 302
 0303            using var message = CreatePutRequest(resourceGroupName, accountName, privateEndpointConnectionName, properti
 0304            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0305            switch (message.Response.Status)
 306            {
 307                case 200:
 308                    {
 0309                        PrivateEndpointConnection value = default;
 0310                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0311                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 312                        {
 0313                            value = null;
 314                        }
 315                        else
 316                        {
 0317                            value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement)
 318                        }
 0319                        return Response.FromValue(value, message.Response);
 320                    }
 321                default:
 0322                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 323            }
 0324        }
 325
 326        /// <summary> Update the state of specified private endpoint connection associated with the storage account. </s
 327        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 328        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 329        /// <param name="privateEndpointConnectionName"> The name of the private endpoint connection associated with the
 330        /// <param name="properties"> The private endpoint connection properties. </param>
 331        /// <param name="cancellationToken"> The cancellation token to use. </param>
 332        public Response<PrivateEndpointConnection> Put(string resourceGroupName, string accountName, string privateEndpo
 333        {
 0334            if (resourceGroupName == null)
 335            {
 0336                throw new ArgumentNullException(nameof(resourceGroupName));
 337            }
 0338            if (accountName == null)
 339            {
 0340                throw new ArgumentNullException(nameof(accountName));
 341            }
 0342            if (privateEndpointConnectionName == null)
 343            {
 0344                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 345            }
 0346            if (properties == null)
 347            {
 0348                throw new ArgumentNullException(nameof(properties));
 349            }
 350
 0351            using var message = CreatePutRequest(resourceGroupName, accountName, privateEndpointConnectionName, properti
 0352            _pipeline.Send(message, cancellationToken);
 0353            switch (message.Response.Status)
 354            {
 355                case 200:
 356                    {
 0357                        PrivateEndpointConnection value = default;
 0358                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0359                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 360                        {
 0361                            value = null;
 362                        }
 363                        else
 364                        {
 0365                            value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement)
 366                        }
 0367                        return Response.FromValue(value, message.Response);
 368                    }
 369                default:
 0370                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 371            }
 0372        }
 373
 374        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string accountName, string privateEndpointCon
 375        {
 0376            var message = _pipeline.CreateMessage();
 0377            var request = message.Request;
 0378            request.Method = RequestMethod.Delete;
 0379            var uri = new RawRequestUriBuilder();
 0380            uri.Reset(endpoint);
 0381            uri.AppendPath("/subscriptions/", false);
 0382            uri.AppendPath(subscriptionId, true);
 0383            uri.AppendPath("/resourceGroups/", false);
 0384            uri.AppendPath(resourceGroupName, true);
 0385            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 0386            uri.AppendPath(accountName, true);
 0387            uri.AppendPath("/privateEndpointConnections/", false);
 0388            uri.AppendPath(privateEndpointConnectionName, true);
 0389            uri.AppendQuery("api-version", apiVersion, true);
 0390            request.Uri = uri;
 0391            return message;
 392        }
 393
 394        /// <summary> Deletes the specified private endpoint connection associated with the storage account. </summary>
 395        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 396        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 397        /// <param name="privateEndpointConnectionName"> The name of the private endpoint connection associated with the
 398        /// <param name="cancellationToken"> The cancellation token to use. </param>
 399        public async Task<Response> DeleteAsync(string resourceGroupName, string accountName, string privateEndpointConn
 400        {
 0401            if (resourceGroupName == null)
 402            {
 0403                throw new ArgumentNullException(nameof(resourceGroupName));
 404            }
 0405            if (accountName == null)
 406            {
 0407                throw new ArgumentNullException(nameof(accountName));
 408            }
 0409            if (privateEndpointConnectionName == null)
 410            {
 0411                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 412            }
 413
 0414            using var message = CreateDeleteRequest(resourceGroupName, accountName, privateEndpointConnectionName);
 0415            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0416            switch (message.Response.Status)
 417            {
 418                case 200:
 419                case 204:
 0420                    return message.Response;
 421                default:
 0422                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 423            }
 0424        }
 425
 426        /// <summary> Deletes the specified private endpoint connection associated with the storage account. </summary>
 427        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 428        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 429        /// <param name="privateEndpointConnectionName"> The name of the private endpoint connection associated with the
 430        /// <param name="cancellationToken"> The cancellation token to use. </param>
 431        public Response Delete(string resourceGroupName, string accountName, string privateEndpointConnectionName, Cance
 432        {
 0433            if (resourceGroupName == null)
 434            {
 0435                throw new ArgumentNullException(nameof(resourceGroupName));
 436            }
 0437            if (accountName == null)
 438            {
 0439                throw new ArgumentNullException(nameof(accountName));
 440            }
 0441            if (privateEndpointConnectionName == null)
 442            {
 0443                throw new ArgumentNullException(nameof(privateEndpointConnectionName));
 444            }
 445
 0446            using var message = CreateDeleteRequest(resourceGroupName, accountName, privateEndpointConnectionName);
 0447            _pipeline.Send(message, cancellationToken);
 0448            switch (message.Response.Status)
 449            {
 450                case 200:
 451                case 204:
 0452                    return message.Response;
 453                default:
 0454                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 455            }
 0456        }
 457    }
 458}