| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Storage.Models; |
| | 16 | |
|
| | 17 | | namespace 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 |
| 240 | 34 | | public PrivateLinkResourcesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub |
| | 35 | | { |
| 240 | 36 | | if (subscriptionId == null) |
| | 37 | | { |
| 0 | 38 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 39 | | } |
| 240 | 40 | | endpoint ??= new Uri("https://management.azure.com"); |
| 240 | 41 | | if (apiVersion == null) |
| | 42 | | { |
| 0 | 43 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 44 | | } |
| | 45 | |
|
| 240 | 46 | | this.subscriptionId = subscriptionId; |
| 240 | 47 | | this.endpoint = endpoint; |
| 240 | 48 | | this.apiVersion = apiVersion; |
| 240 | 49 | | _clientDiagnostics = clientDiagnostics; |
| 240 | 50 | | _pipeline = pipeline; |
| 240 | 51 | | } |
| | 52 | |
|
| | 53 | | internal HttpMessage CreateListByStorageAccountRequest(string resourceGroupName, string accountName) |
| | 54 | | { |
| 4 | 55 | | var message = _pipeline.CreateMessage(); |
| 4 | 56 | | var request = message.Request; |
| 4 | 57 | | request.Method = RequestMethod.Get; |
| 4 | 58 | | var uri = new RawRequestUriBuilder(); |
| 4 | 59 | | uri.Reset(endpoint); |
| 4 | 60 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 61 | | uri.AppendPath(subscriptionId, true); |
| 4 | 62 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 63 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 64 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 4 | 65 | | uri.AppendPath(accountName, true); |
| 4 | 66 | | uri.AppendPath("/privateLinkResources", false); |
| 4 | 67 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 68 | | request.Uri = uri; |
| 4 | 69 | | 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'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 | | { |
| 2 | 78 | | if (resourceGroupName == null) |
| | 79 | | { |
| 0 | 80 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 81 | | } |
| 2 | 82 | | if (accountName == null) |
| | 83 | | { |
| 0 | 84 | | throw new ArgumentNullException(nameof(accountName)); |
| | 85 | | } |
| | 86 | |
|
| 2 | 87 | | using var message = CreateListByStorageAccountRequest(resourceGroupName, accountName); |
| 2 | 88 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 89 | | switch (message.Response.Status) |
| | 90 | | { |
| | 91 | | case 200: |
| | 92 | | { |
| 2 | 93 | | PrivateLinkResourceListResult value = default; |
| 2 | 94 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 95 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 96 | | { |
| 0 | 97 | | value = null; |
| | 98 | | } |
| | 99 | | else |
| | 100 | | { |
| 2 | 101 | | value = PrivateLinkResourceListResult.DeserializePrivateLinkResourceListResult(document.Root |
| | 102 | | } |
| 2 | 103 | | return Response.FromValue(value, message.Response); |
| | 104 | | } |
| | 105 | | default: |
| 0 | 106 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 107 | | } |
| 2 | 108 | | } |
| | 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'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 | | { |
| 2 | 116 | | if (resourceGroupName == null) |
| | 117 | | { |
| 0 | 118 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 119 | | } |
| 2 | 120 | | if (accountName == null) |
| | 121 | | { |
| 0 | 122 | | throw new ArgumentNullException(nameof(accountName)); |
| | 123 | | } |
| | 124 | |
|
| 2 | 125 | | using var message = CreateListByStorageAccountRequest(resourceGroupName, accountName); |
| 2 | 126 | | _pipeline.Send(message, cancellationToken); |
| 2 | 127 | | switch (message.Response.Status) |
| | 128 | | { |
| | 129 | | case 200: |
| | 130 | | { |
| 2 | 131 | | PrivateLinkResourceListResult value = default; |
| 2 | 132 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 133 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 134 | | { |
| 0 | 135 | | value = null; |
| | 136 | | } |
| | 137 | | else |
| | 138 | | { |
| 2 | 139 | | value = PrivateLinkResourceListResult.DeserializePrivateLinkResourceListResult(document.Root |
| | 140 | | } |
| 2 | 141 | | return Response.FromValue(value, message.Response); |
| | 142 | | } |
| | 143 | | default: |
| 0 | 144 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 145 | | } |
| 2 | 146 | | } |
| | 147 | | } |
| | 148 | | } |