< Summary

Class:Microsoft.Azure.Attestation.PolicyCertificatesOperations
Assembly:Microsoft.Azure.Attestation
File(s):C:\Git\azure-sdk-for-net\sdk\attestation\Microsoft.Azure.Attestation\src\Generated\PolicyCertificatesOperations.cs
Covered lines:156
Uncovered lines:170
Coverable lines:326
Total lines:733
Line coverage:47.8% (156 of 326)
Covered branches:94
Total branches:196
Branch coverage:47.9% (94 of 196)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
GetWithHttpMessagesAsync()-46.08%46.77%
AddWithHttpMessagesAsync()-47.71%48.48%
RemoveWithHttpMessagesAsync()-47.71%48.48%

File(s)

C:\Git\azure-sdk-for-net\sdk\attestation\Microsoft.Azure.Attestation\src\Generated\PolicyCertificatesOperations.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.Attestation
 12{
 13    using Microsoft.Rest;
 14    using Microsoft.Rest.Azure;
 15    using Models;
 16    using Newtonsoft.Json;
 17    using System.Collections;
 18    using System.Collections.Generic;
 19    using System.Linq;
 20    using System.Net;
 21    using System.Net.Http;
 22    using System.Threading;
 23    using System.Threading.Tasks;
 24
 25    /// <summary>
 26    /// PolicyCertificatesOperations operations.
 27    /// </summary>
 28    internal partial class PolicyCertificatesOperations : IServiceOperations<AttestationClient>, IPolicyCertificatesOper
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the PolicyCertificatesOperations class.
 32        /// </summary>
 33        /// <param name='client'>
 34        /// Reference to the service client.
 35        /// </param>
 36        /// <exception cref="System.ArgumentNullException">
 37        /// Thrown when a required parameter is null
 38        /// </exception>
 839        internal PolicyCertificatesOperations(AttestationClient client)
 40        {
 841            if (client == null)
 42            {
 043                throw new System.ArgumentNullException("client");
 44            }
 845            Client = client;
 846        }
 47
 48        /// <summary>
 49        /// Gets a reference to the AttestationClient
 50        /// </summary>
 10051        public AttestationClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Retrieves the set of certificates used to express policy for the current
 55        /// tenant.
 56        /// </summary>
 57        /// <param name='tenantBaseUrl'>
 58        /// The tenant name, for example https://mytenant.attest.azure.net.
 59        /// </param>
 60        /// <param name='customHeaders'>
 61        /// Headers that will be added to request.
 62        /// </param>
 63        /// <param name='cancellationToken'>
 64        /// The cancellation token.
 65        /// </param>
 66        /// <exception cref="CloudException">
 67        /// Thrown when the operation returned an invalid status code
 68        /// </exception>
 69        /// <exception cref="SerializationException">
 70        /// Thrown when unable to deserialize the response
 71        /// </exception>
 72        /// <exception cref="ValidationException">
 73        /// Thrown when a required parameter is null
 74        /// </exception>
 75        /// <exception cref="System.ArgumentNullException">
 76        /// Thrown when a required parameter is null
 77        /// </exception>
 78        /// <return>
 79        /// A response object containing the response body and response headers.
 80        /// </return>
 81        public async Task<AzureOperationResponse<object>> GetWithHttpMessagesAsync(string tenantBaseUrl, Dictionary<stri
 82        {
 483            if (tenantBaseUrl == null)
 84            {
 085                throw new ValidationException(ValidationRules.CannotBeNull, "tenantBaseUrl");
 86            }
 87            // Tracing
 488            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 489            string _invocationId = null;
 490            if (_shouldTrace)
 91            {
 092                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 093                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 094                tracingParameters.Add("tenantBaseUrl", tenantBaseUrl);
 095                tracingParameters.Add("cancellationToken", cancellationToken);
 096                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 97            }
 98            // Construct URL
 499            var _baseUrl = Client.BaseUri;
 4100            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "operations/policy/certificates";
 4101            _url = _url.Replace("{tenantBaseUrl}", tenantBaseUrl);
 4102            List<string> _queryParameters = new List<string>();
 4103            if (Client.ApiVersion != null)
 104            {
 4105                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 106            }
 4107            if (_queryParameters.Count > 0)
 108            {
 4109                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 110            }
 111            // Create HTTP transport objects
 4112            var _httpRequest = new HttpRequestMessage();
 4113            HttpResponseMessage _httpResponse = null;
 4114            _httpRequest.Method = new HttpMethod("GET");
 4115            _httpRequest.RequestUri = new System.Uri(_url);
 116            // Set Headers
 4117            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 118            {
 4119                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 120            }
 4121            if (Client.AcceptLanguage != null)
 122            {
 4123                if (_httpRequest.Headers.Contains("accept-language"))
 124                {
 0125                    _httpRequest.Headers.Remove("accept-language");
 126                }
 4127                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 128            }
 129
 130
 4131            if (customHeaders != null)
 132            {
 0133                foreach(var _header in customHeaders)
 134                {
 0135                    if (_httpRequest.Headers.Contains(_header.Key))
 136                    {
 0137                        _httpRequest.Headers.Remove(_header.Key);
 138                    }
 0139                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 140                }
 141            }
 142
 143            // Serialize Request
 4144            string _requestContent = null;
 145            // Set Credentials
 4146            if (Client.Credentials != null)
 147            {
 4148                cancellationToken.ThrowIfCancellationRequested();
 4149                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 150            }
 151            // Send Request
 4152            if (_shouldTrace)
 153            {
 0154                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 155            }
 4156            cancellationToken.ThrowIfCancellationRequested();
 4157            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 4158            if (_shouldTrace)
 159            {
 0160                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 161            }
 4162            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 4163            cancellationToken.ThrowIfCancellationRequested();
 4164            string _responseContent = null;
 4165            if ((int)_statusCode != 200 && (int)_statusCode != 400 && (int)_statusCode != 401)
 166            {
 0167                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 168                try
 169                {
 0170                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0171                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0172                    if (_errorBody != null)
 173                    {
 0174                        ex = new CloudException(_errorBody.Message);
 0175                        ex.Body = _errorBody;
 176                    }
 0177                }
 0178                catch (JsonException)
 179                {
 180                    // Ignore the exception
 0181                }
 0182                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0183                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0184                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 185                {
 0186                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 187                }
 0188                if (_shouldTrace)
 189                {
 0190                    ServiceClientTracing.Error(_invocationId, ex);
 191                }
 0192                _httpRequest.Dispose();
 0193                if (_httpResponse != null)
 194                {
 0195                    _httpResponse.Dispose();
 196                }
 0197                throw ex;
 198            }
 199            // Create Result
 4200            var _result = new AzureOperationResponse<object>();
 4201            _result.Request = _httpRequest;
 4202            _result.Response = _httpResponse;
 4203            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 204            {
 0205                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 206            }
 207            // Deserialize Response
 4208            if ((int)_statusCode == 200)
 209            {
 4210                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 211                try
 212                {
 4213                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 4214                }
 0215                catch (JsonException ex)
 216                {
 0217                    _httpRequest.Dispose();
 0218                    if (_httpResponse != null)
 219                    {
 0220                        _httpResponse.Dispose();
 221                    }
 0222                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 223                }
 224            }
 225            // Deserialize Response
 4226            if ((int)_statusCode == 400)
 227            {
 0228                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 229                try
 230                {
 0231                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseContent, Cl
 0232                }
 0233                catch (JsonException ex)
 234                {
 0235                    _httpRequest.Dispose();
 0236                    if (_httpResponse != null)
 237                    {
 0238                        _httpResponse.Dispose();
 239                    }
 0240                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 241                }
 242            }
 243            // Deserialize Response
 4244            if ((int)_statusCode == 401)
 245            {
 0246                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 247                try
 248                {
 0249                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 0250                }
 0251                catch (JsonException ex)
 252                {
 0253                    _httpRequest.Dispose();
 0254                    if (_httpResponse != null)
 255                    {
 0256                        _httpResponse.Dispose();
 257                    }
 0258                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 259                }
 260            }
 4261            if (_shouldTrace)
 262            {
 0263                ServiceClientTracing.Exit(_invocationId, _result);
 264            }
 4265            return _result;
 4266        }
 267
 268        /// <summary>
 269        /// Adds a new attestation policy certificate to the set of policy management
 270        /// certificates.
 271        /// </summary>
 272        /// <param name='tenantBaseUrl'>
 273        /// The tenant name, for example https://mytenant.attest.azure.net.
 274        /// </param>
 275        /// <param name='policyCertificateToAdd'>
 276        /// An RFC7519 JSON Web Token containing a claim named "aas-policyCertificate"
 277        /// whose value is an RFC7517 JSON Web Key which specifies a new key to add.
 278        /// The RFC7519 JWT must be signed with one of the existing signing
 279        /// certificates
 280        /// </param>
 281        /// <param name='customHeaders'>
 282        /// Headers that will be added to request.
 283        /// </param>
 284        /// <param name='cancellationToken'>
 285        /// The cancellation token.
 286        /// </param>
 287        /// <exception cref="CloudException">
 288        /// Thrown when the operation returned an invalid status code
 289        /// </exception>
 290        /// <exception cref="SerializationException">
 291        /// Thrown when unable to deserialize the response
 292        /// </exception>
 293        /// <exception cref="ValidationException">
 294        /// Thrown when a required parameter is null
 295        /// </exception>
 296        /// <exception cref="System.ArgumentNullException">
 297        /// Thrown when a required parameter is null
 298        /// </exception>
 299        /// <return>
 300        /// A response object containing the response body and response headers.
 301        /// </return>
 302        public async Task<AzureOperationResponse<object>> AddWithHttpMessagesAsync(string tenantBaseUrl, string policyCe
 303        {
 2304            if (tenantBaseUrl == null)
 305            {
 0306                throw new ValidationException(ValidationRules.CannotBeNull, "tenantBaseUrl");
 307            }
 2308            if (policyCertificateToAdd == null)
 309            {
 0310                throw new ValidationException(ValidationRules.CannotBeNull, "policyCertificateToAdd");
 311            }
 312            // Tracing
 2313            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2314            string _invocationId = null;
 2315            if (_shouldTrace)
 316            {
 0317                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0318                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0319                tracingParameters.Add("tenantBaseUrl", tenantBaseUrl);
 0320                tracingParameters.Add("policyCertificateToAdd", policyCertificateToAdd);
 0321                tracingParameters.Add("cancellationToken", cancellationToken);
 0322                ServiceClientTracing.Enter(_invocationId, this, "Add", tracingParameters);
 323            }
 324            // Construct URL
 2325            var _baseUrl = Client.BaseUri;
 2326            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "operations/policy/certificates";
 2327            _url = _url.Replace("{tenantBaseUrl}", tenantBaseUrl);
 2328            List<string> _queryParameters = new List<string>();
 2329            if (Client.ApiVersion != null)
 330            {
 2331                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 332            }
 2333            if (_queryParameters.Count > 0)
 334            {
 2335                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 336            }
 337            // Create HTTP transport objects
 2338            var _httpRequest = new HttpRequestMessage();
 2339            HttpResponseMessage _httpResponse = null;
 2340            _httpRequest.Method = new HttpMethod("PUT");
 2341            _httpRequest.RequestUri = new System.Uri(_url);
 342            // Set Headers
 2343            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 344            {
 2345                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 346            }
 2347            if (Client.AcceptLanguage != null)
 348            {
 2349                if (_httpRequest.Headers.Contains("accept-language"))
 350                {
 0351                    _httpRequest.Headers.Remove("accept-language");
 352                }
 2353                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 354            }
 355
 356
 2357            if (customHeaders != null)
 358            {
 0359                foreach(var _header in customHeaders)
 360                {
 0361                    if (_httpRequest.Headers.Contains(_header.Key))
 362                    {
 0363                        _httpRequest.Headers.Remove(_header.Key);
 364                    }
 0365                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 366                }
 367            }
 368
 369            // Serialize Request
 2370            string _requestContent = null;
 2371            if(policyCertificateToAdd != null)
 372            {
 2373                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(policyCertificateToAdd, Client.Seri
 2374                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 2375                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 376            }
 377            // Set Credentials
 2378            if (Client.Credentials != null)
 379            {
 2380                cancellationToken.ThrowIfCancellationRequested();
 2381                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 382            }
 383            // Send Request
 2384            if (_shouldTrace)
 385            {
 0386                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 387            }
 2388            cancellationToken.ThrowIfCancellationRequested();
 2389            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2390            if (_shouldTrace)
 391            {
 0392                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 393            }
 2394            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2395            cancellationToken.ThrowIfCancellationRequested();
 2396            string _responseContent = null;
 2397            if ((int)_statusCode != 200 && (int)_statusCode != 400 && (int)_statusCode != 401)
 398            {
 0399                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 400                try
 401                {
 0402                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0403                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0404                    if (_errorBody != null)
 405                    {
 0406                        ex = new CloudException(_errorBody.Message);
 0407                        ex.Body = _errorBody;
 408                    }
 0409                }
 0410                catch (JsonException)
 411                {
 412                    // Ignore the exception
 0413                }
 0414                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0415                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0416                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 417                {
 0418                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 419                }
 0420                if (_shouldTrace)
 421                {
 0422                    ServiceClientTracing.Error(_invocationId, ex);
 423                }
 0424                _httpRequest.Dispose();
 0425                if (_httpResponse != null)
 426                {
 0427                    _httpResponse.Dispose();
 428                }
 0429                throw ex;
 430            }
 431            // Create Result
 2432            var _result = new AzureOperationResponse<object>();
 2433            _result.Request = _httpRequest;
 2434            _result.Response = _httpResponse;
 2435            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 436            {
 0437                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 438            }
 439            // Deserialize Response
 2440            if ((int)_statusCode == 200)
 441            {
 2442                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 443                try
 444                {
 2445                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 2446                }
 0447                catch (JsonException ex)
 448                {
 0449                    _httpRequest.Dispose();
 0450                    if (_httpResponse != null)
 451                    {
 0452                        _httpResponse.Dispose();
 453                    }
 0454                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 455                }
 456            }
 457            // Deserialize Response
 2458            if ((int)_statusCode == 400)
 459            {
 0460                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 461                try
 462                {
 0463                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseContent, Cl
 0464                }
 0465                catch (JsonException ex)
 466                {
 0467                    _httpRequest.Dispose();
 0468                    if (_httpResponse != null)
 469                    {
 0470                        _httpResponse.Dispose();
 471                    }
 0472                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 473                }
 474            }
 475            // Deserialize Response
 2476            if ((int)_statusCode == 401)
 477            {
 0478                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 479                try
 480                {
 0481                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 0482                }
 0483                catch (JsonException ex)
 484                {
 0485                    _httpRequest.Dispose();
 0486                    if (_httpResponse != null)
 487                    {
 0488                        _httpResponse.Dispose();
 489                    }
 0490                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 491                }
 492            }
 2493            if (_shouldTrace)
 494            {
 0495                ServiceClientTracing.Exit(_invocationId, _result);
 496            }
 2497            return _result;
 2498        }
 499
 500        /// <summary>
 501        /// Removes the specified policy management certificate. Note that the final
 502        /// policy management certificate cannot be removed.
 503        /// </summary>
 504        /// <param name='tenantBaseUrl'>
 505        /// The tenant name, for example https://mytenant.attest.azure.net.
 506        /// </param>
 507        /// <param name='policyCertificateToRemove'>
 508        /// An RFC7519 JSON Web Token containing a claim named "aas-policyCertificate"
 509        /// whose value is an RFC7517 JSON Web Key which specifies a new key to update.
 510        /// The RFC7519 JWT must be signed with one of the existing signing
 511        /// certificates
 512        /// </param>
 513        /// <param name='customHeaders'>
 514        /// Headers that will be added to request.
 515        /// </param>
 516        /// <param name='cancellationToken'>
 517        /// The cancellation token.
 518        /// </param>
 519        /// <exception cref="CloudException">
 520        /// Thrown when the operation returned an invalid status code
 521        /// </exception>
 522        /// <exception cref="SerializationException">
 523        /// Thrown when unable to deserialize the response
 524        /// </exception>
 525        /// <exception cref="ValidationException">
 526        /// Thrown when a required parameter is null
 527        /// </exception>
 528        /// <exception cref="System.ArgumentNullException">
 529        /// Thrown when a required parameter is null
 530        /// </exception>
 531        /// <return>
 532        /// A response object containing the response body and response headers.
 533        /// </return>
 534        public async Task<AzureOperationResponse<object>> RemoveWithHttpMessagesAsync(string tenantBaseUrl, string polic
 535        {
 2536            if (tenantBaseUrl == null)
 537            {
 0538                throw new ValidationException(ValidationRules.CannotBeNull, "tenantBaseUrl");
 539            }
 2540            if (policyCertificateToRemove == null)
 541            {
 0542                throw new ValidationException(ValidationRules.CannotBeNull, "policyCertificateToRemove");
 543            }
 544            // Tracing
 2545            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2546            string _invocationId = null;
 2547            if (_shouldTrace)
 548            {
 0549                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0550                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0551                tracingParameters.Add("tenantBaseUrl", tenantBaseUrl);
 0552                tracingParameters.Add("policyCertificateToRemove", policyCertificateToRemove);
 0553                tracingParameters.Add("cancellationToken", cancellationToken);
 0554                ServiceClientTracing.Enter(_invocationId, this, "Remove", tracingParameters);
 555            }
 556            // Construct URL
 2557            var _baseUrl = Client.BaseUri;
 2558            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "operations/policy/certificates";
 2559            _url = _url.Replace("{tenantBaseUrl}", tenantBaseUrl);
 2560            List<string> _queryParameters = new List<string>();
 2561            if (Client.ApiVersion != null)
 562            {
 2563                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 564            }
 2565            if (_queryParameters.Count > 0)
 566            {
 2567                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 568            }
 569            // Create HTTP transport objects
 2570            var _httpRequest = new HttpRequestMessage();
 2571            HttpResponseMessage _httpResponse = null;
 2572            _httpRequest.Method = new HttpMethod("POST");
 2573            _httpRequest.RequestUri = new System.Uri(_url);
 574            // Set Headers
 2575            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 576            {
 2577                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 578            }
 2579            if (Client.AcceptLanguage != null)
 580            {
 2581                if (_httpRequest.Headers.Contains("accept-language"))
 582                {
 0583                    _httpRequest.Headers.Remove("accept-language");
 584                }
 2585                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 586            }
 587
 588
 2589            if (customHeaders != null)
 590            {
 0591                foreach(var _header in customHeaders)
 592                {
 0593                    if (_httpRequest.Headers.Contains(_header.Key))
 594                    {
 0595                        _httpRequest.Headers.Remove(_header.Key);
 596                    }
 0597                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 598                }
 599            }
 600
 601            // Serialize Request
 2602            string _requestContent = null;
 2603            if(policyCertificateToRemove != null)
 604            {
 2605                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(policyCertificateToRemove, Client.S
 2606                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 2607                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 608            }
 609            // Set Credentials
 2610            if (Client.Credentials != null)
 611            {
 2612                cancellationToken.ThrowIfCancellationRequested();
 2613                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 614            }
 615            // Send Request
 2616            if (_shouldTrace)
 617            {
 0618                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 619            }
 2620            cancellationToken.ThrowIfCancellationRequested();
 2621            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2622            if (_shouldTrace)
 623            {
 0624                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 625            }
 2626            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2627            cancellationToken.ThrowIfCancellationRequested();
 2628            string _responseContent = null;
 2629            if ((int)_statusCode != 200 && (int)_statusCode != 400 && (int)_statusCode != 401)
 630            {
 0631                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 632                try
 633                {
 0634                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0635                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0636                    if (_errorBody != null)
 637                    {
 0638                        ex = new CloudException(_errorBody.Message);
 0639                        ex.Body = _errorBody;
 640                    }
 0641                }
 0642                catch (JsonException)
 643                {
 644                    // Ignore the exception
 0645                }
 0646                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0647                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0648                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 649                {
 0650                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 651                }
 0652                if (_shouldTrace)
 653                {
 0654                    ServiceClientTracing.Error(_invocationId, ex);
 655                }
 0656                _httpRequest.Dispose();
 0657                if (_httpResponse != null)
 658                {
 0659                    _httpResponse.Dispose();
 660                }
 0661                throw ex;
 662            }
 663            // Create Result
 2664            var _result = new AzureOperationResponse<object>();
 2665            _result.Request = _httpRequest;
 2666            _result.Response = _httpResponse;
 2667            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 668            {
 0669                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 670            }
 671            // Deserialize Response
 2672            if ((int)_statusCode == 200)
 673            {
 2674                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 675                try
 676                {
 2677                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 2678                }
 0679                catch (JsonException ex)
 680                {
 0681                    _httpRequest.Dispose();
 0682                    if (_httpResponse != null)
 683                    {
 0684                        _httpResponse.Dispose();
 685                    }
 0686                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 687                }
 688            }
 689            // Deserialize Response
 2690            if ((int)_statusCode == 400)
 691            {
 0692                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 693                try
 694                {
 0695                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseContent, Cl
 0696                }
 0697                catch (JsonException ex)
 698                {
 0699                    _httpRequest.Dispose();
 0700                    if (_httpResponse != null)
 701                    {
 0702                        _httpResponse.Dispose();
 703                    }
 0704                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 705                }
 706            }
 707            // Deserialize Response
 2708            if ((int)_statusCode == 401)
 709            {
 0710                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 711                try
 712                {
 0713                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<string>(_responseContent, Client
 0714                }
 0715                catch (JsonException ex)
 716                {
 0717                    _httpRequest.Dispose();
 0718                    if (_httpResponse != null)
 719                    {
 0720                        _httpResponse.Dispose();
 721                    }
 0722                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 723                }
 724            }
 2725            if (_shouldTrace)
 726            {
 0727                ServiceClientTracing.Exit(_invocationId, _result);
 728            }
 2729            return _result;
 2730        }
 731
 732    }
 733}