| | 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.KeyVault.Models; |
| | 16 | |
|
| | 17 | | namespace 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"/> |
| 0 | 34 | | public PrivateLinkResourcesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub |
| | 35 | | { |
| 0 | 36 | | if (subscriptionId == null) |
| | 37 | | { |
| 0 | 38 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 39 | | } |
| 0 | 40 | | endpoint ??= new Uri("https://management.azure.com"); |
| 0 | 41 | | if (apiVersion == null) |
| | 42 | | { |
| 0 | 43 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 44 | | } |
| | 45 | |
|
| 0 | 46 | | this.subscriptionId = subscriptionId; |
| 0 | 47 | | this.endpoint = endpoint; |
| 0 | 48 | | this.apiVersion = apiVersion; |
| 0 | 49 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 50 | | _pipeline = pipeline; |
| 0 | 51 | | } |
| | 52 | |
|
| | 53 | | internal HttpMessage CreateListByVaultRequest(string resourceGroupName, string vaultName) |
| | 54 | | { |
| 0 | 55 | | var message = _pipeline.CreateMessage(); |
| 0 | 56 | | var request = message.Request; |
| 0 | 57 | | request.Method = RequestMethod.Get; |
| 0 | 58 | | var uri = new RawRequestUriBuilder(); |
| 0 | 59 | | uri.Reset(endpoint); |
| 0 | 60 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 61 | | uri.AppendPath(subscriptionId, true); |
| 0 | 62 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 63 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 64 | | uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); |
| 0 | 65 | | uri.AppendPath(vaultName, true); |
| 0 | 66 | | uri.AppendPath("/privateLinkResources", false); |
| 0 | 67 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 68 | | request.Uri = uri; |
| 0 | 69 | | 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 | | { |
| 0 | 79 | | if (resourceGroupName == null) |
| | 80 | | { |
| 0 | 81 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 82 | | } |
| 0 | 83 | | if (vaultName == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(vaultName)); |
| | 86 | | } |
| | 87 | |
|
| 0 | 88 | | using var message = CreateListByVaultRequest(resourceGroupName, vaultName); |
| 0 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | { |
| | 94 | | PrivateLinkResourceListResult value = default; |
| 0 | 95 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 96 | | value = PrivateLinkResourceListResult.DeserializePrivateLinkResourceListResult(document.RootElem |
| 0 | 97 | | return Response.FromValue(value, message.Response); |
| | 98 | | } |
| | 99 | | default: |
| 0 | 100 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 101 | | } |
| 0 | 102 | | } |
| | 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 | | { |
| 0 | 111 | | if (resourceGroupName == null) |
| | 112 | | { |
| 0 | 113 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 114 | | } |
| 0 | 115 | | if (vaultName == null) |
| | 116 | | { |
| 0 | 117 | | throw new ArgumentNullException(nameof(vaultName)); |
| | 118 | | } |
| | 119 | |
|
| 0 | 120 | | using var message = CreateListByVaultRequest(resourceGroupName, vaultName); |
| 0 | 121 | | _pipeline.Send(message, cancellationToken); |
| 0 | 122 | | switch (message.Response.Status) |
| | 123 | | { |
| | 124 | | case 200: |
| | 125 | | { |
| | 126 | | PrivateLinkResourceListResult value = default; |
| 0 | 127 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 128 | | value = PrivateLinkResourceListResult.DeserializePrivateLinkResourceListResult(document.RootElem |
| 0 | 129 | | return Response.FromValue(value, message.Response); |
| | 130 | | } |
| | 131 | | default: |
| 0 | 132 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 133 | | } |
| 0 | 134 | | } |
| | 135 | | } |
| | 136 | | } |