< Summary

Class:Azure.Security.KeyVault.Administration.OperationHeadersExtensions
Assembly:Azure.Security.KeyVault.Administration
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Administration\src\OperationHeadersExtensions.cs
Covered lines:4
Uncovered lines:1
Coverable lines:5
Total lines:52
Line coverage:80% (4 of 5)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
JobId(...)-100%100%
JobId(...)-100%100%
JobId(...)-0%100%
GetJobIdFromAzureAsyncOperation(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Administration\src\OperationHeadersExtensions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5
 6namespace 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        {
 416            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        {
 425            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        {
 034            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        {
 844            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
 849            return uri.Segments[2].TrimEnd('/');
 50        }
 51    }
 52}