| | 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.Security.KeyVault.Administration.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.Security.KeyVault.Administration |
| | 18 | | { |
| | 19 | | internal partial class BackupRestoreRestClient |
| | 20 | | { |
| | 21 | | private string apiVersion; |
| | 22 | | private ClientDiagnostics _clientDiagnostics; |
| | 23 | | private HttpPipeline _pipeline; |
| | 24 | |
|
| | 25 | | /// <summary> Initializes a new instance of BackupRestoreRestClient. </summary> |
| | 26 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 27 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 28 | | /// <param name="apiVersion"> Api Version. </param> |
| | 29 | | /// <exception cref="ArgumentNullException"> <paramref name="apiVersion"/> is null. </exception> |
| 8 | 30 | | public BackupRestoreRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string apiVersion = " |
| | 31 | | { |
| 8 | 32 | | if (apiVersion == null) |
| | 33 | | { |
| 0 | 34 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 35 | | } |
| | 36 | |
|
| 8 | 37 | | this.apiVersion = apiVersion; |
| 8 | 38 | | _clientDiagnostics = clientDiagnostics; |
| 8 | 39 | | _pipeline = pipeline; |
| 8 | 40 | | } |
| | 41 | |
|
| | 42 | | internal HttpMessage CreateFullBackupRequest(string vaultBaseUrl, SASTokenParameter azureStorageBlobContainerUri |
| | 43 | | { |
| 4 | 44 | | var message = _pipeline.CreateMessage(); |
| 4 | 45 | | var request = message.Request; |
| 4 | 46 | | request.Method = RequestMethod.Post; |
| 4 | 47 | | var uri = new RawRequestUriBuilder(); |
| 4 | 48 | | uri.AppendRaw(vaultBaseUrl, false); |
| 4 | 49 | | uri.AppendPath("/backup", false); |
| 4 | 50 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 51 | | request.Uri = uri; |
| 4 | 52 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 53 | | if (azureStorageBlobContainerUri != null) |
| | 54 | | { |
| 4 | 55 | | var content = new Utf8JsonRequestContent(); |
| 4 | 56 | | content.JsonWriter.WriteObjectValue(azureStorageBlobContainerUri); |
| 4 | 57 | | request.Content = content; |
| | 58 | | } |
| 4 | 59 | | return message; |
| | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> Creates a full backup using a user-provided SAS token to an Azure blob storage container. </summar |
| | 63 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 64 | | /// <param name="azureStorageBlobContainerUri"> Azure blob shared access signature token pointing to a valid Azu |
| | 65 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 66 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> is null. </exception> |
| | 67 | | public async Task<ResponseWithHeaders<ServiceFullBackupHeaders>> FullBackupAsync(string vaultBaseUrl, SASTokenPa |
| | 68 | | { |
| 2 | 69 | | if (vaultBaseUrl == null) |
| | 70 | | { |
| 0 | 71 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 72 | | } |
| | 73 | |
|
| 2 | 74 | | using var message = CreateFullBackupRequest(vaultBaseUrl, azureStorageBlobContainerUri); |
| 2 | 75 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 76 | | var headers = new ServiceFullBackupHeaders(message.Response); |
| 2 | 77 | | switch (message.Response.Status) |
| | 78 | | { |
| | 79 | | case 202: |
| 2 | 80 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 81 | | default: |
| 0 | 82 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 83 | | } |
| 2 | 84 | | } |
| | 85 | |
|
| | 86 | | /// <summary> Creates a full backup using a user-provided SAS token to an Azure blob storage container. </summar |
| | 87 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 88 | | /// <param name="azureStorageBlobContainerUri"> Azure blob shared access signature token pointing to a valid Azu |
| | 89 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 90 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> is null. </exception> |
| | 91 | | public ResponseWithHeaders<ServiceFullBackupHeaders> FullBackup(string vaultBaseUrl, SASTokenParameter azureStor |
| | 92 | | { |
| 2 | 93 | | if (vaultBaseUrl == null) |
| | 94 | | { |
| 0 | 95 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 96 | | } |
| | 97 | |
|
| 2 | 98 | | using var message = CreateFullBackupRequest(vaultBaseUrl, azureStorageBlobContainerUri); |
| 2 | 99 | | _pipeline.Send(message, cancellationToken); |
| 2 | 100 | | var headers = new ServiceFullBackupHeaders(message.Response); |
| 2 | 101 | | switch (message.Response.Status) |
| | 102 | | { |
| | 103 | | case 202: |
| 2 | 104 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 105 | | default: |
| 0 | 106 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 107 | | } |
| 2 | 108 | | } |
| | 109 | |
|
| | 110 | | internal HttpMessage CreateFullBackupStatusRequest(string vaultBaseUrl, string jobId) |
| | 111 | | { |
| 10 | 112 | | var message = _pipeline.CreateMessage(); |
| 10 | 113 | | var request = message.Request; |
| 10 | 114 | | request.Method = RequestMethod.Get; |
| 10 | 115 | | var uri = new RawRequestUriBuilder(); |
| 10 | 116 | | uri.AppendRaw(vaultBaseUrl, false); |
| 10 | 117 | | uri.AppendPath("/backup/", false); |
| 10 | 118 | | uri.AppendPath(jobId, true); |
| 10 | 119 | | uri.AppendPath("/pending", false); |
| 10 | 120 | | uri.AppendQuery("api-version", apiVersion, true); |
| 10 | 121 | | request.Uri = uri; |
| 10 | 122 | | return message; |
| | 123 | | } |
| | 124 | |
|
| | 125 | | /// <summary> Returns the status of full backup operation. </summary> |
| | 126 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 127 | | /// <param name="jobId"> The id returned as part of the backup request. </param> |
| | 128 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 129 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> or <paramref name="jobId"/> is null |
| | 130 | | public async Task<Response<FullBackupDetailsInternal>> FullBackupStatusAsync(string vaultBaseUrl, string jobId, |
| | 131 | | { |
| 10 | 132 | | if (vaultBaseUrl == null) |
| | 133 | | { |
| 0 | 134 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 135 | | } |
| 10 | 136 | | if (jobId == null) |
| | 137 | | { |
| 0 | 138 | | throw new ArgumentNullException(nameof(jobId)); |
| | 139 | | } |
| | 140 | |
|
| 10 | 141 | | using var message = CreateFullBackupStatusRequest(vaultBaseUrl, jobId); |
| 10 | 142 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 10 | 143 | | switch (message.Response.Status) |
| | 144 | | { |
| | 145 | | case 200: |
| | 146 | | { |
| | 147 | | FullBackupDetailsInternal value = default; |
| 10 | 148 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 10 | 149 | | value = FullBackupDetailsInternal.DeserializeFullBackupDetailsInternal(document.RootElement); |
| 10 | 150 | | return Response.FromValue(value, message.Response); |
| | 151 | | } |
| | 152 | | default: |
| 0 | 153 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 154 | | } |
| 10 | 155 | | } |
| | 156 | |
|
| | 157 | | /// <summary> Returns the status of full backup operation. </summary> |
| | 158 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 159 | | /// <param name="jobId"> The id returned as part of the backup request. </param> |
| | 160 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 161 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> or <paramref name="jobId"/> is null |
| | 162 | | public Response<FullBackupDetailsInternal> FullBackupStatus(string vaultBaseUrl, string jobId, CancellationToken |
| | 163 | | { |
| 0 | 164 | | if (vaultBaseUrl == null) |
| | 165 | | { |
| 0 | 166 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 167 | | } |
| 0 | 168 | | if (jobId == null) |
| | 169 | | { |
| 0 | 170 | | throw new ArgumentNullException(nameof(jobId)); |
| | 171 | | } |
| | 172 | |
|
| 0 | 173 | | using var message = CreateFullBackupStatusRequest(vaultBaseUrl, jobId); |
| 0 | 174 | | _pipeline.Send(message, cancellationToken); |
| 0 | 175 | | switch (message.Response.Status) |
| | 176 | | { |
| | 177 | | case 200: |
| | 178 | | { |
| | 179 | | FullBackupDetailsInternal value = default; |
| 0 | 180 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 181 | | value = FullBackupDetailsInternal.DeserializeFullBackupDetailsInternal(document.RootElement); |
| 0 | 182 | | return Response.FromValue(value, message.Response); |
| | 183 | | } |
| | 184 | | default: |
| 0 | 185 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 186 | | } |
| 0 | 187 | | } |
| | 188 | |
|
| | 189 | | internal HttpMessage CreateFullRestoreOperationRequest(string vaultBaseUrl, RestoreOperationParameters restoreBl |
| | 190 | | { |
| 4 | 191 | | var message = _pipeline.CreateMessage(); |
| 4 | 192 | | var request = message.Request; |
| 4 | 193 | | request.Method = RequestMethod.Put; |
| 4 | 194 | | var uri = new RawRequestUriBuilder(); |
| 4 | 195 | | uri.AppendRaw(vaultBaseUrl, false); |
| 4 | 196 | | uri.AppendPath("/restore", false); |
| 4 | 197 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 198 | | request.Uri = uri; |
| 4 | 199 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 200 | | if (restoreBlobDetails != null) |
| | 201 | | { |
| 4 | 202 | | var content = new Utf8JsonRequestContent(); |
| 4 | 203 | | content.JsonWriter.WriteObjectValue(restoreBlobDetails); |
| 4 | 204 | | request.Content = content; |
| | 205 | | } |
| 4 | 206 | | return message; |
| | 207 | | } |
| | 208 | |
|
| | 209 | | /// <summary> Restores all key materials using the SAS token pointing to a previously stored Azure Blob storage |
| | 210 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 211 | | /// <param name="restoreBlobDetails"> The Azure blob SAS token pointing to a folder where the previous successfu |
| | 212 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 213 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> is null. </exception> |
| | 214 | | public async Task<ResponseWithHeaders<ServiceFullRestoreOperationHeaders>> FullRestoreOperationAsync(string vaul |
| | 215 | | { |
| 2 | 216 | | if (vaultBaseUrl == null) |
| | 217 | | { |
| 0 | 218 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 219 | | } |
| | 220 | |
|
| 2 | 221 | | using var message = CreateFullRestoreOperationRequest(vaultBaseUrl, restoreBlobDetails); |
| 2 | 222 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 223 | | var headers = new ServiceFullRestoreOperationHeaders(message.Response); |
| 2 | 224 | | switch (message.Response.Status) |
| | 225 | | { |
| | 226 | | case 202: |
| 2 | 227 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 228 | | default: |
| 0 | 229 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 230 | | } |
| 2 | 231 | | } |
| | 232 | |
|
| | 233 | | /// <summary> Restores all key materials using the SAS token pointing to a previously stored Azure Blob storage |
| | 234 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 235 | | /// <param name="restoreBlobDetails"> The Azure blob SAS token pointing to a folder where the previous successfu |
| | 236 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 237 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> is null. </exception> |
| | 238 | | public ResponseWithHeaders<ServiceFullRestoreOperationHeaders> FullRestoreOperation(string vaultBaseUrl, Restore |
| | 239 | | { |
| 2 | 240 | | if (vaultBaseUrl == null) |
| | 241 | | { |
| 0 | 242 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 243 | | } |
| | 244 | |
|
| 2 | 245 | | using var message = CreateFullRestoreOperationRequest(vaultBaseUrl, restoreBlobDetails); |
| 2 | 246 | | _pipeline.Send(message, cancellationToken); |
| 2 | 247 | | var headers = new ServiceFullRestoreOperationHeaders(message.Response); |
| 2 | 248 | | switch (message.Response.Status) |
| | 249 | | { |
| | 250 | | case 202: |
| 2 | 251 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 252 | | default: |
| 0 | 253 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 254 | | } |
| 2 | 255 | | } |
| | 256 | |
|
| | 257 | | internal HttpMessage CreateRestoreStatusRequest(string vaultBaseUrl, string jobId) |
| | 258 | | { |
| 12 | 259 | | var message = _pipeline.CreateMessage(); |
| 12 | 260 | | var request = message.Request; |
| 12 | 261 | | request.Method = RequestMethod.Get; |
| 12 | 262 | | var uri = new RawRequestUriBuilder(); |
| 12 | 263 | | uri.AppendRaw(vaultBaseUrl, false); |
| 12 | 264 | | uri.AppendPath("/restore/", false); |
| 12 | 265 | | uri.AppendPath(jobId, true); |
| 12 | 266 | | uri.AppendPath("/pending", false); |
| 12 | 267 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 268 | | request.Uri = uri; |
| 12 | 269 | | return message; |
| | 270 | | } |
| | 271 | |
|
| | 272 | | /// <summary> Returns the status of restore operation. </summary> |
| | 273 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 274 | | /// <param name="jobId"> The Job Id returned part of the restore operation. </param> |
| | 275 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 276 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> or <paramref name="jobId"/> is null |
| | 277 | | public async Task<Response<RestoreDetailsInternal>> RestoreStatusAsync(string vaultBaseUrl, string jobId, Cancel |
| | 278 | | { |
| 12 | 279 | | if (vaultBaseUrl == null) |
| | 280 | | { |
| 0 | 281 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 282 | | } |
| 12 | 283 | | if (jobId == null) |
| | 284 | | { |
| 0 | 285 | | throw new ArgumentNullException(nameof(jobId)); |
| | 286 | | } |
| | 287 | |
|
| 12 | 288 | | using var message = CreateRestoreStatusRequest(vaultBaseUrl, jobId); |
| 12 | 289 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 12 | 290 | | switch (message.Response.Status) |
| | 291 | | { |
| | 292 | | case 200: |
| | 293 | | { |
| | 294 | | RestoreDetailsInternal value = default; |
| 12 | 295 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 12 | 296 | | value = RestoreDetailsInternal.DeserializeRestoreDetailsInternal(document.RootElement); |
| 12 | 297 | | return Response.FromValue(value, message.Response); |
| | 298 | | } |
| | 299 | | default: |
| 0 | 300 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 301 | | } |
| 12 | 302 | | } |
| | 303 | |
|
| | 304 | | /// <summary> Returns the status of restore operation. </summary> |
| | 305 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 306 | | /// <param name="jobId"> The Job Id returned part of the restore operation. </param> |
| | 307 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 308 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> or <paramref name="jobId"/> is null |
| | 309 | | public Response<RestoreDetailsInternal> RestoreStatus(string vaultBaseUrl, string jobId, CancellationToken cance |
| | 310 | | { |
| 0 | 311 | | if (vaultBaseUrl == null) |
| | 312 | | { |
| 0 | 313 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 314 | | } |
| 0 | 315 | | if (jobId == null) |
| | 316 | | { |
| 0 | 317 | | throw new ArgumentNullException(nameof(jobId)); |
| | 318 | | } |
| | 319 | |
|
| 0 | 320 | | using var message = CreateRestoreStatusRequest(vaultBaseUrl, jobId); |
| 0 | 321 | | _pipeline.Send(message, cancellationToken); |
| 0 | 322 | | switch (message.Response.Status) |
| | 323 | | { |
| | 324 | | case 200: |
| | 325 | | { |
| | 326 | | RestoreDetailsInternal value = default; |
| 0 | 327 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 328 | | value = RestoreDetailsInternal.DeserializeRestoreDetailsInternal(document.RootElement); |
| 0 | 329 | | return Response.FromValue(value, message.Response); |
| | 330 | | } |
| | 331 | | default: |
| 0 | 332 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 333 | | } |
| 0 | 334 | | } |
| | 335 | |
|
| | 336 | | internal HttpMessage CreateSelectiveKeyRestoreOperationRequest(string vaultBaseUrl, string keyName, SelectiveKey |
| | 337 | | { |
| 0 | 338 | | var message = _pipeline.CreateMessage(); |
| 0 | 339 | | var request = message.Request; |
| 0 | 340 | | request.Method = RequestMethod.Put; |
| 0 | 341 | | var uri = new RawRequestUriBuilder(); |
| 0 | 342 | | uri.AppendRaw(vaultBaseUrl, false); |
| 0 | 343 | | uri.AppendPath("/keys/", false); |
| 0 | 344 | | uri.AppendPath(keyName, true); |
| 0 | 345 | | uri.AppendPath("/restore", false); |
| 0 | 346 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 347 | | request.Uri = uri; |
| 0 | 348 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 349 | | if (restoreBlobDetails != null) |
| | 350 | | { |
| 0 | 351 | | var content = new Utf8JsonRequestContent(); |
| 0 | 352 | | content.JsonWriter.WriteObjectValue(restoreBlobDetails); |
| 0 | 353 | | request.Content = content; |
| | 354 | | } |
| 0 | 355 | | return message; |
| | 356 | | } |
| | 357 | |
|
| | 358 | | /// <summary> Restores all key versions of a given key using user supplied SAS token pointing to a previously st |
| | 359 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 360 | | /// <param name="keyName"> The name of the key to be restored from the user supplied backup. </param> |
| | 361 | | /// <param name="restoreBlobDetails"> The Azure blob SAS token pointing to a folder where the previous successfu |
| | 362 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 363 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> or <paramref name="keyName"/> is nu |
| | 364 | | public async Task<ResponseWithHeaders<ServiceSelectiveKeyRestoreOperationHeaders>> SelectiveKeyRestoreOperationA |
| | 365 | | { |
| 0 | 366 | | if (vaultBaseUrl == null) |
| | 367 | | { |
| 0 | 368 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 369 | | } |
| 0 | 370 | | if (keyName == null) |
| | 371 | | { |
| 0 | 372 | | throw new ArgumentNullException(nameof(keyName)); |
| | 373 | | } |
| | 374 | |
|
| 0 | 375 | | using var message = CreateSelectiveKeyRestoreOperationRequest(vaultBaseUrl, keyName, restoreBlobDetails); |
| 0 | 376 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 377 | | var headers = new ServiceSelectiveKeyRestoreOperationHeaders(message.Response); |
| 0 | 378 | | switch (message.Response.Status) |
| | 379 | | { |
| | 380 | | case 202: |
| 0 | 381 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 382 | | default: |
| 0 | 383 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 384 | | } |
| 0 | 385 | | } |
| | 386 | |
|
| | 387 | | /// <summary> Restores all key versions of a given key using user supplied SAS token pointing to a previously st |
| | 388 | | /// <param name="vaultBaseUrl"> The vault name, for example https://myvault.vault.azure.net. </param> |
| | 389 | | /// <param name="keyName"> The name of the key to be restored from the user supplied backup. </param> |
| | 390 | | /// <param name="restoreBlobDetails"> The Azure blob SAS token pointing to a folder where the previous successfu |
| | 391 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 392 | | /// <exception cref="ArgumentNullException"> <paramref name="vaultBaseUrl"/> or <paramref name="keyName"/> is nu |
| | 393 | | public ResponseWithHeaders<ServiceSelectiveKeyRestoreOperationHeaders> SelectiveKeyRestoreOperation(string vault |
| | 394 | | { |
| 0 | 395 | | if (vaultBaseUrl == null) |
| | 396 | | { |
| 0 | 397 | | throw new ArgumentNullException(nameof(vaultBaseUrl)); |
| | 398 | | } |
| 0 | 399 | | if (keyName == null) |
| | 400 | | { |
| 0 | 401 | | throw new ArgumentNullException(nameof(keyName)); |
| | 402 | | } |
| | 403 | |
|
| 0 | 404 | | using var message = CreateSelectiveKeyRestoreOperationRequest(vaultBaseUrl, keyName, restoreBlobDetails); |
| 0 | 405 | | _pipeline.Send(message, cancellationToken); |
| 0 | 406 | | var headers = new ServiceSelectiveKeyRestoreOperationHeaders(message.Response); |
| 0 | 407 | | switch (message.Response.Status) |
| | 408 | | { |
| | 409 | | case 202: |
| 0 | 410 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 411 | | default: |
| 0 | 412 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 413 | | } |
| 0 | 414 | | } |
| | 415 | | } |
| | 416 | | } |