| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | |
| | | 6 | | namespace Azure.Security.KeyVault.Administration |
| | | 7 | | { |
| | | 8 | | internal static class OperationHeadersExtensions |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Extracts the operation JobId from the <see cref="ServiceFullBackupHeaders" /> AzureAsyncOperation. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <returns>The operation JobId.</returns> |
| | | 14 | | public static string JobId(this ServiceFullBackupHeaders header) |
| | | 15 | | { |
| | 4 | 16 | | return GetJobIdFromAzureAsyncOperation(header.AzureAsyncOperation); |
| | | 17 | | } |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Extracts the operation JobId from the <see cref="ServiceFullRestoreOperationHeaders" /> AzureAsyncOperation. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <returns>The operation JobId.</returns> |
| | | 23 | | public static string JobId(this ServiceFullRestoreOperationHeaders header) |
| | | 24 | | { |
| | 4 | 25 | | return GetJobIdFromAzureAsyncOperation(header.AzureAsyncOperation); |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Extracts the operation JobId from the <see cref="ServiceSelectiveKeyRestoreOperationHeaders" /> AzureAsyncOp |
| | | 30 | | /// </summary> |
| | | 31 | | /// <returns>The operation JobId.</returns> |
| | | 32 | | public static string JobId(this ServiceSelectiveKeyRestoreOperationHeaders header) |
| | | 33 | | { |
| | 0 | 34 | | return GetJobIdFromAzureAsyncOperation(header.AzureAsyncOperation); |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Extracts the operation JobId from the AzureAsyncOperation. |
| | | 39 | | /// </summary> |
| | | 40 | | /// <param name="azureAsyncOperation">The AzureAsyncOperation string, which is a URI.</param> |
| | | 41 | | /// <returns>The operation JobId.</returns> |
| | | 42 | | private static string GetJobIdFromAzureAsyncOperation(string azureAsyncOperation) |
| | | 43 | | { |
| | 8 | 44 | | var uri = new Uri(azureAsyncOperation); |
| | | 45 | | |
| | | 46 | | // return segment 2 (<jobId>) from the azureAsyncOperation which takes the form: |
| | | 47 | | // "https://myvault.vault.azure.net/<operationName>/<jobId>/pending" |
| | | 48 | | |
| | 8 | 49 | | return uri.Segments[2].TrimEnd('/'); |
| | | 50 | | } |
| | | 51 | | } |
| | | 52 | | } |