| | 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 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"/> |
| 0 | 34 | | public PrivateEndpointConnectionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, stri |
| | 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 CreateGetRequest(string resourceGroupName, string vaultName, string privateEndpointConnecti |
| | 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("/privateEndpointConnections/", false); |
| 0 | 67 | | uri.AppendPath(privateEndpointConnectionName, true); |
| 0 | 68 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 69 | | request.Uri = uri; |
| 0 | 70 | | 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 | | { |
| 0 | 81 | | if (resourceGroupName == null) |
| | 82 | | { |
| 0 | 83 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 84 | | } |
| 0 | 85 | | if (vaultName == null) |
| | 86 | | { |
| 0 | 87 | | throw new ArgumentNullException(nameof(vaultName)); |
| | 88 | | } |
| 0 | 89 | | if (privateEndpointConnectionName == null) |
| | 90 | | { |
| 0 | 91 | | throw new ArgumentNullException(nameof(privateEndpointConnectionName)); |
| | 92 | | } |
| | 93 | |
|
| 0 | 94 | | using var message = CreateGetRequest(resourceGroupName, vaultName, privateEndpointConnectionName); |
| 0 | 95 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 96 | | switch (message.Response.Status) |
| | 97 | | { |
| | 98 | | case 200: |
| | 99 | | { |
| | 100 | | PrivateEndpointConnection value = default; |
| 0 | 101 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 102 | | value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement); |
| 0 | 103 | | return Response.FromValue(value, message.Response); |
| | 104 | | } |
| | 105 | | default: |
| 0 | 106 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 107 | | } |
| 0 | 108 | | } |
| | 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 | | { |
| 0 | 118 | | if (resourceGroupName == null) |
| | 119 | | { |
| 0 | 120 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 121 | | } |
| 0 | 122 | | if (vaultName == null) |
| | 123 | | { |
| 0 | 124 | | throw new ArgumentNullException(nameof(vaultName)); |
| | 125 | | } |
| 0 | 126 | | if (privateEndpointConnectionName == null) |
| | 127 | | { |
| 0 | 128 | | throw new ArgumentNullException(nameof(privateEndpointConnectionName)); |
| | 129 | | } |
| | 130 | |
|
| 0 | 131 | | using var message = CreateGetRequest(resourceGroupName, vaultName, privateEndpointConnectionName); |
| 0 | 132 | | _pipeline.Send(message, cancellationToken); |
| 0 | 133 | | switch (message.Response.Status) |
| | 134 | | { |
| | 135 | | case 200: |
| | 136 | | { |
| | 137 | | PrivateEndpointConnection value = default; |
| 0 | 138 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 139 | | value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement); |
| 0 | 140 | | return Response.FromValue(value, message.Response); |
| | 141 | | } |
| | 142 | | default: |
| 0 | 143 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 144 | | } |
| 0 | 145 | | } |
| | 146 | |
|
| | 147 | | internal HttpMessage CreatePutRequest(string resourceGroupName, string vaultName, string privateEndpointConnecti |
| | 148 | | { |
| 0 | 149 | | var message = _pipeline.CreateMessage(); |
| 0 | 150 | | var request = message.Request; |
| 0 | 151 | | request.Method = RequestMethod.Put; |
| 0 | 152 | | var uri = new RawRequestUriBuilder(); |
| 0 | 153 | | uri.Reset(endpoint); |
| 0 | 154 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 155 | | uri.AppendPath(subscriptionId, true); |
| 0 | 156 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 157 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 158 | | uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); |
| 0 | 159 | | uri.AppendPath(vaultName, true); |
| 0 | 160 | | uri.AppendPath("/privateEndpointConnections/", false); |
| 0 | 161 | | uri.AppendPath(privateEndpointConnectionName, true); |
| 0 | 162 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 163 | | request.Uri = uri; |
| 0 | 164 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 165 | | var content = new Utf8JsonRequestContent(); |
| 0 | 166 | | content.JsonWriter.WriteObjectValue(properties); |
| 0 | 167 | | request.Content = content; |
| 0 | 168 | | 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 | | { |
| 0 | 180 | | if (resourceGroupName == null) |
| | 181 | | { |
| 0 | 182 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 183 | | } |
| 0 | 184 | | if (vaultName == null) |
| | 185 | | { |
| 0 | 186 | | throw new ArgumentNullException(nameof(vaultName)); |
| | 187 | | } |
| 0 | 188 | | if (privateEndpointConnectionName == null) |
| | 189 | | { |
| 0 | 190 | | throw new ArgumentNullException(nameof(privateEndpointConnectionName)); |
| | 191 | | } |
| 0 | 192 | | if (properties == null) |
| | 193 | | { |
| 0 | 194 | | throw new ArgumentNullException(nameof(properties)); |
| | 195 | | } |
| | 196 | |
|
| 0 | 197 | | using var message = CreatePutRequest(resourceGroupName, vaultName, privateEndpointConnectionName, properties |
| 0 | 198 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 199 | | var headers = new PrivateEndpointConnectionsPutHeaders(message.Response); |
| 0 | 200 | | switch (message.Response.Status) |
| | 201 | | { |
| | 202 | | case 200: |
| | 203 | | { |
| | 204 | | PrivateEndpointConnection value = default; |
| 0 | 205 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 206 | | value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement); |
| 0 | 207 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 208 | | } |
| | 209 | | default: |
| 0 | 210 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 211 | | } |
| 0 | 212 | | } |
| | 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 | | { |
| 0 | 223 | | if (resourceGroupName == null) |
| | 224 | | { |
| 0 | 225 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 226 | | } |
| 0 | 227 | | if (vaultName == null) |
| | 228 | | { |
| 0 | 229 | | throw new ArgumentNullException(nameof(vaultName)); |
| | 230 | | } |
| 0 | 231 | | if (privateEndpointConnectionName == null) |
| | 232 | | { |
| 0 | 233 | | throw new ArgumentNullException(nameof(privateEndpointConnectionName)); |
| | 234 | | } |
| 0 | 235 | | if (properties == null) |
| | 236 | | { |
| 0 | 237 | | throw new ArgumentNullException(nameof(properties)); |
| | 238 | | } |
| | 239 | |
|
| 0 | 240 | | using var message = CreatePutRequest(resourceGroupName, vaultName, privateEndpointConnectionName, properties |
| 0 | 241 | | _pipeline.Send(message, cancellationToken); |
| 0 | 242 | | var headers = new PrivateEndpointConnectionsPutHeaders(message.Response); |
| 0 | 243 | | switch (message.Response.Status) |
| | 244 | | { |
| | 245 | | case 200: |
| | 246 | | { |
| | 247 | | PrivateEndpointConnection value = default; |
| 0 | 248 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 249 | | value = PrivateEndpointConnection.DeserializePrivateEndpointConnection(document.RootElement); |
| 0 | 250 | | return ResponseWithHeaders.FromValue(value, headers, message.Response); |
| | 251 | | } |
| | 252 | | default: |
| 0 | 253 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 254 | | } |
| 0 | 255 | | } |
| | 256 | |
|
| | 257 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string vaultName, string privateEndpointConne |
| | 258 | | { |
| 0 | 259 | | var message = _pipeline.CreateMessage(); |
| 0 | 260 | | var request = message.Request; |
| 0 | 261 | | request.Method = RequestMethod.Delete; |
| 0 | 262 | | var uri = new RawRequestUriBuilder(); |
| 0 | 263 | | uri.Reset(endpoint); |
| 0 | 264 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 265 | | uri.AppendPath(subscriptionId, true); |
| 0 | 266 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 267 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 268 | | uri.AppendPath("/providers/Microsoft.KeyVault/vaults/", false); |
| 0 | 269 | | uri.AppendPath(vaultName, true); |
| 0 | 270 | | uri.AppendPath("/privateEndpointConnections/", false); |
| 0 | 271 | | uri.AppendPath(privateEndpointConnectionName, true); |
| 0 | 272 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 273 | | request.Uri = uri; |
| 0 | 274 | | 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 | | { |
| 0 | 285 | | if (resourceGroupName == null) |
| | 286 | | { |
| 0 | 287 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 288 | | } |
| 0 | 289 | | if (vaultName == null) |
| | 290 | | { |
| 0 | 291 | | throw new ArgumentNullException(nameof(vaultName)); |
| | 292 | | } |
| 0 | 293 | | if (privateEndpointConnectionName == null) |
| | 294 | | { |
| 0 | 295 | | throw new ArgumentNullException(nameof(privateEndpointConnectionName)); |
| | 296 | | } |
| | 297 | |
|
| 0 | 298 | | using var message = CreateDeleteRequest(resourceGroupName, vaultName, privateEndpointConnectionName); |
| 0 | 299 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 300 | | var headers = new PrivateEndpointConnectionsDeleteHeaders(message.Response); |
| 0 | 301 | | switch (message.Response.Status) |
| | 302 | | { |
| | 303 | | case 200: |
| | 304 | | case 202: |
| | 305 | | case 204: |
| 0 | 306 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 307 | | default: |
| 0 | 308 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 309 | | } |
| 0 | 310 | | } |
| | 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 | | { |
| 0 | 320 | | if (resourceGroupName == null) |
| | 321 | | { |
| 0 | 322 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 323 | | } |
| 0 | 324 | | if (vaultName == null) |
| | 325 | | { |
| 0 | 326 | | throw new ArgumentNullException(nameof(vaultName)); |
| | 327 | | } |
| 0 | 328 | | if (privateEndpointConnectionName == null) |
| | 329 | | { |
| 0 | 330 | | throw new ArgumentNullException(nameof(privateEndpointConnectionName)); |
| | 331 | | } |
| | 332 | |
|
| 0 | 333 | | using var message = CreateDeleteRequest(resourceGroupName, vaultName, privateEndpointConnectionName); |
| 0 | 334 | | _pipeline.Send(message, cancellationToken); |
| 0 | 335 | | var headers = new PrivateEndpointConnectionsDeleteHeaders(message.Response); |
| 0 | 336 | | switch (message.Response.Status) |
| | 337 | | { |
| | 338 | | case 200: |
| | 339 | | case 202: |
| | 340 | | case 204: |
| 0 | 341 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 342 | | default: |
| 0 | 343 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 344 | | } |
| 0 | 345 | | } |
| | 346 | | } |
| | 347 | | } |