diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/AzureAppConfigurationClient.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/AzureAppConfigurationClient.cs
new file mode 100644
index 000000000000..291d777cde96
--- /dev/null
+++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/AzureAppConfigurationClient.cs
@@ -0,0 +1,4303 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.AppConfiguration
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Serialization;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ public partial class AzureAppConfigurationClient : ServiceClient, IAzureAppConfigurationClient, IAzureClient
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ internal string BaseUri {get; set;}
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ public JsonSerializerSettings SerializationSettings { get; private set; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ public JsonSerializerSettings DeserializationSettings { get; private set; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ public ServiceClientCredentials Credentials { get; private set; }
+
+ ///
+ /// Used to guarantee real-time consistency between requests.
+ ///
+ public string SyncToken { get; set; }
+
+ ///
+ /// The API version to be used with the HTTP request.
+ ///
+ public string ApiVersion { get; private set; }
+
+ ///
+ /// The endpoint of the App Configuration instance to send requests to.
+ ///
+ public string Endpoint { get; set; }
+
+ ///
+ /// The preferred language for the response.
+ ///
+ public string AcceptLanguage { get; set; }
+
+ ///
+ /// The retry timeout in seconds for Long Running Operations. Default value is
+ /// 30.
+ ///
+ public int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// Whether a unique x-ms-client-request-id should be generated. When set to
+ /// true a unique x-ms-client-request-id value is generated and included in
+ /// each request. Default is true.
+ ///
+ public bool? GenerateClientRequestId { get; set; }
+
+ ///
+ /// Initializes a new instance of the AzureAppConfigurationClient class.
+ ///
+ ///
+ /// HttpClient to be used
+ ///
+ ///
+ /// True: will dispose the provided httpClient on calling AzureAppConfigurationClient.Dispose(). False: will not dispose provided httpClient
+ protected AzureAppConfigurationClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the AzureAppConfigurationClient class.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected AzureAppConfigurationClient(params DelegatingHandler[] handlers) : base(handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the AzureAppConfigurationClient class.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected AzureAppConfigurationClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the AzureAppConfigurationClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public AzureAppConfigurationClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the AzureAppConfigurationClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// HttpClient to be used
+ ///
+ ///
+ /// True: will dispose the provided httpClient on calling AzureAppConfigurationClient.Dispose(). False: will not dispose provided httpClient
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public AzureAppConfigurationClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the AzureAppConfigurationClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public AzureAppConfigurationClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// An optional partial-method to perform custom initialization.
+ ///
+ partial void CustomInitialize();
+ ///
+ /// Initializes client properties.
+ ///
+ private void Initialize()
+ {
+ BaseUri = "{endpoint}";
+ ApiVersion = "1.0";
+ AcceptLanguage = "en-US";
+ LongRunningOperationRetryTimeout = 30;
+ GenerateClientRequestId = true;
+ SerializationSettings = new JsonSerializerSettings
+ {
+ Formatting = Newtonsoft.Json.Formatting.Indented,
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ DeserializationSettings = new JsonSerializerSettings
+ {
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ CustomInitialize();
+ DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
+ }
+ ///
+ /// Gets a list of keys.
+ ///
+ ///
+ /// A filter for the name of the returned keys.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task,GetKeysHeaders>> GetKeysWithHttpMessagesAsync(string name = default(string), string after = default(string), string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("after", after);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetKeys", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "keys";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ List _queryParameters = new List();
+ if (name != null)
+ {
+ _queryParameters.Add(string.Format("name={0}", System.Uri.EscapeDataString(name)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (after != null)
+ {
+ _queryParameters.Add(string.Format("After={0}", System.Uri.EscapeDataString(after)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse,GetKeysHeaders>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// A filter for the name of the returned keys.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CheckKeysWithHttpMessagesAsync(string name = default(string), string after = default(string), string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("after", after);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CheckKeys", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "keys";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ List _queryParameters = new List();
+ if (name != null)
+ {
+ _queryParameters.Add(string.Format("name={0}", System.Uri.EscapeDataString(name)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (after != null)
+ {
+ _queryParameters.Add(string.Format("After={0}", System.Uri.EscapeDataString(after)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Gets a list of key-values.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task,GetKeyValuesHeaders>> GetKeyValuesWithHttpMessagesAsync(string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("after", after);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetKeyValues", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "kv";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ List _queryParameters = new List();
+ if (key != null)
+ {
+ _queryParameters.Add(string.Format("key={0}", System.Uri.EscapeDataString(key)));
+ }
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (after != null)
+ {
+ _queryParameters.Add(string.Format("After={0}", System.Uri.EscapeDataString(after)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$Select={0}", System.Uri.EscapeDataString(string.Join(",", select))));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse,GetKeyValuesHeaders>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CheckKeyValuesWithHttpMessagesAsync(string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("after", after);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CheckKeyValues", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "kv";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ List _queryParameters = new List();
+ if (key != null)
+ {
+ _queryParameters.Add(string.Format("key={0}", System.Uri.EscapeDataString(key)));
+ }
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (after != null)
+ {
+ _queryParameters.Add(string.Format("After={0}", System.Uri.EscapeDataString(after)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$Select={0}", System.Uri.EscapeDataString(string.Join(",", select))));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Gets a single key-value.
+ ///
+ ///
+ /// The key of the key-value to retrieve.
+ ///
+ ///
+ /// The label of the key-value to retrieve.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetKeyValueWithHttpMessagesAsync(string key, string label = default(string), string acceptDatetime = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (key == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "key");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("ifMatch", ifMatch);
+ tracingParameters.Add("ifNoneMatch", ifNoneMatch);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetKeyValue", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "kv/{key}";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ _url = _url.Replace("{key}", System.Uri.EscapeDataString(key));
+ List _queryParameters = new List();
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$Select={0}", System.Uri.EscapeDataString(string.Join(",", select))));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (ifMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-Match"))
+ {
+ _httpRequest.Headers.Remove("If-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
+ }
+ if (ifNoneMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-None-Match"))
+ {
+ _httpRequest.Headers.Remove("If-None-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Creates a key-value.
+ ///
+ ///
+ /// The key of the key-value to create.
+ ///
+ ///
+ /// The label of the key-value to create.
+ ///
+ ///
+ /// The key-value to create.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> PutKeyValueWithHttpMessagesAsync(string key, string label = default(string), KeyValue entity = default(KeyValue), string ifMatch = default(string), string ifNoneMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (key == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "key");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("entity", entity);
+ tracingParameters.Add("ifMatch", ifMatch);
+ tracingParameters.Add("ifNoneMatch", ifNoneMatch);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "PutKeyValue", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "kv/{key}";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ _url = _url.Replace("{key}", System.Uri.EscapeDataString(key));
+ List _queryParameters = new List();
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PUT");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (ifMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-Match"))
+ {
+ _httpRequest.Headers.Remove("If-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
+ }
+ if (ifNoneMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-None-Match"))
+ {
+ _httpRequest.Headers.Remove("If-None-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(entity != null)
+ {
+ _requestContent = SafeJsonConvert.SerializeObject(entity, SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Deletes a key-value.
+ ///
+ ///
+ /// The key of the key-value to delete.
+ ///
+ ///
+ /// The label of the key-value to delete.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> DeleteKeyValueWithHttpMessagesAsync(string key, string label = default(string), string ifMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (key == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "key");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("ifMatch", ifMatch);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "DeleteKeyValue", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "kv/{key}";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ _url = _url.Replace("{key}", System.Uri.EscapeDataString(key));
+ List _queryParameters = new List();
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (ifMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-Match"))
+ {
+ _httpRequest.Headers.Remove("If-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 204)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// The key of the key-value to retrieve.
+ ///
+ ///
+ /// The label of the key-value to retrieve.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CheckKeyValueWithHttpMessagesAsync(string key, string label = default(string), string acceptDatetime = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (key == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "key");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("ifMatch", ifMatch);
+ tracingParameters.Add("ifNoneMatch", ifNoneMatch);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CheckKeyValue", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "kv/{key}";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ _url = _url.Replace("{key}", System.Uri.EscapeDataString(key));
+ List _queryParameters = new List();
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$Select={0}", System.Uri.EscapeDataString(string.Join(",", select))));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (ifMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-Match"))
+ {
+ _httpRequest.Headers.Remove("If-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
+ }
+ if (ifNoneMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-None-Match"))
+ {
+ _httpRequest.Headers.Remove("If-None-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Gets a list of labels.
+ ///
+ ///
+ /// A filter for the name of the returned labels.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task,GetLabelsHeaders>> GetLabelsWithHttpMessagesAsync(string name = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("after", after);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetLabels", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "labels";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ List _queryParameters = new List();
+ if (name != null)
+ {
+ _queryParameters.Add(string.Format("name={0}", System.Uri.EscapeDataString(name)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (after != null)
+ {
+ _queryParameters.Add(string.Format("After={0}", System.Uri.EscapeDataString(after)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$Select={0}", System.Uri.EscapeDataString(string.Join(",", select))));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse,GetLabelsHeaders>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// A filter for the name of the returned labels.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CheckLabelsWithHttpMessagesAsync(string name = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("name", name);
+ tracingParameters.Add("after", after);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CheckLabels", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "labels";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ List _queryParameters = new List();
+ if (name != null)
+ {
+ _queryParameters.Add(string.Format("name={0}", System.Uri.EscapeDataString(name)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (after != null)
+ {
+ _queryParameters.Add(string.Format("After={0}", System.Uri.EscapeDataString(after)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$Select={0}", System.Uri.EscapeDataString(string.Join(",", select))));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Locks a key-value.
+ ///
+ ///
+ /// The key of the key-value to lock.
+ ///
+ ///
+ /// The label, if any, of the key-value to lock.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> PutLockWithHttpMessagesAsync(string key, string label = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (key == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "key");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("ifMatch", ifMatch);
+ tracingParameters.Add("ifNoneMatch", ifNoneMatch);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "PutLock", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "locks/{key}";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ _url = _url.Replace("{key}", System.Uri.EscapeDataString(key));
+ List _queryParameters = new List();
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PUT");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (ifMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-Match"))
+ {
+ _httpRequest.Headers.Remove("If-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
+ }
+ if (ifNoneMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-None-Match"))
+ {
+ _httpRequest.Headers.Remove("If-None-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Unlocks a key-value.
+ ///
+ ///
+ /// The key of the key-value to unlock.
+ ///
+ ///
+ /// The label, if any, of the key-value to unlock.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> DeleteLockWithHttpMessagesAsync(string key, string label = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (key == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "key");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("ifMatch", ifMatch);
+ tracingParameters.Add("ifNoneMatch", ifNoneMatch);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "DeleteLock", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "locks/{key}";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ _url = _url.Replace("{key}", System.Uri.EscapeDataString(key));
+ List _queryParameters = new List();
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (ifMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-Match"))
+ {
+ _httpRequest.Headers.Remove("If-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
+ }
+ if (ifNoneMatch != null)
+ {
+ if (_httpRequest.Headers.Contains("If-None-Match"))
+ {
+ _httpRequest.Headers.Remove("If-None-Match");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Gets a list of key-value revisions.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task,GetRevisionsHeaders>> GetRevisionsWithHttpMessagesAsync(string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("after", after);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetRevisions", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "revisions";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ List _queryParameters = new List();
+ if (key != null)
+ {
+ _queryParameters.Add(string.Format("key={0}", System.Uri.EscapeDataString(key)));
+ }
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (after != null)
+ {
+ _queryParameters.Add(string.Format("After={0}", System.Uri.EscapeDataString(after)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$Select={0}", System.Uri.EscapeDataString(string.Join(",", select))));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse,GetRevisionsHeaders>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CheckRevisionsWithHttpMessagesAsync(string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
+ }
+ if (ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("key", key);
+ tracingParameters.Add("label", label);
+ tracingParameters.Add("after", after);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("select", select);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CheckRevisions", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "revisions";
+ _url = _url.Replace("{endpoint}", Endpoint);
+ List _queryParameters = new List();
+ if (key != null)
+ {
+ _queryParameters.Add(string.Format("key={0}", System.Uri.EscapeDataString(key)));
+ }
+ if (label != null)
+ {
+ _queryParameters.Add(string.Format("label={0}", System.Uri.EscapeDataString(label)));
+ }
+ if (ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion)));
+ }
+ if (after != null)
+ {
+ _queryParameters.Add(string.Format("After={0}", System.Uri.EscapeDataString(after)));
+ }
+ if (select != null)
+ {
+ _queryParameters.Add(string.Format("$Select={0}", System.Uri.EscapeDataString(string.Join(",", select))));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex = new CloudException(_errorBody.Message);
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Gets a list of keys.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task,GetKeysHeaders>> GetKeysNextWithHttpMessagesAsync(string nextPageLink, string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (nextPageLink == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetKeysNext", tracingParameters);
+ }
+ // Construct URL
+ string _url = "{nextLink}";
+ _url = _url.Replace("{nextLink}", nextPageLink);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse,GetKeysHeaders>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Gets a list of key-values.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task,GetKeyValuesHeaders>> GetKeyValuesNextWithHttpMessagesAsync(string nextPageLink, string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (nextPageLink == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetKeyValuesNext", tracingParameters);
+ }
+ // Construct URL
+ string _url = "{nextLink}";
+ _url = _url.Replace("{nextLink}", nextPageLink);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse,GetKeyValuesHeaders>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Gets a list of labels.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task,GetLabelsHeaders>> GetLabelsNextWithHttpMessagesAsync(string nextPageLink, string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (nextPageLink == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetLabelsNext", tracingParameters);
+ }
+ // Construct URL
+ string _url = "{nextLink}";
+ _url = _url.Replace("{nextLink}", nextPageLink);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse,GetLabelsHeaders>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Gets a list of key-value revisions.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task,GetRevisionsHeaders>> GetRevisionsNextWithHttpMessagesAsync(string nextPageLink, string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (nextPageLink == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("acceptDatetime", acceptDatetime);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetRevisionsNext", tracingParameters);
+ }
+ // Construct URL
+ string _url = "{nextLink}";
+ _url = _url.Replace("{nextLink}", nextPageLink);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (GenerateClientRequestId != null && GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (SyncToken != null)
+ {
+ if (_httpRequest.Headers.Contains("Sync-Token"))
+ {
+ _httpRequest.Headers.Remove("Sync-Token");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Sync-Token", SyncToken);
+ }
+ if (acceptDatetime != null)
+ {
+ if (_httpRequest.Headers.Contains("Accept-Datetime"))
+ {
+ _httpRequest.Headers.Remove("Accept-Datetime");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Accept-Datetime", acceptDatetime);
+ }
+ if (AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ Error _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse,GetRevisionsHeaders>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/AzureAppConfigurationClientExtensions.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/AzureAppConfigurationClientExtensions.cs
new file mode 100644
index 000000000000..cc1b16170e12
--- /dev/null
+++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/AzureAppConfigurationClientExtensions.cs
@@ -0,0 +1,576 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.AppConfiguration
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for AzureAppConfigurationClient.
+ ///
+ public static partial class AzureAppConfigurationClientExtensions
+ {
+ ///
+ /// Gets a list of keys.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A filter for the name of the returned keys.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> GetKeysAsync(this IAzureAppConfigurationClient operations, string name = default(string), string after = default(string), string acceptDatetime = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetKeysWithHttpMessagesAsync(name, after, acceptDatetime, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A filter for the name of the returned keys.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CheckKeysAsync(this IAzureAppConfigurationClient operations, string name = default(string), string after = default(string), string acceptDatetime = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CheckKeysWithHttpMessagesAsync(name, after, acceptDatetime, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Gets a list of key-values.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> GetKeyValuesAsync(this IAzureAppConfigurationClient operations, string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetKeyValuesWithHttpMessagesAsync(key, label, after, acceptDatetime, select, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CheckKeyValuesAsync(this IAzureAppConfigurationClient operations, string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CheckKeyValuesWithHttpMessagesAsync(key, label, after, acceptDatetime, select, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Gets a single key-value.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The key of the key-value to retrieve.
+ ///
+ ///
+ /// The label of the key-value to retrieve.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetKeyValueAsync(this IAzureAppConfigurationClient operations, string key, string label = default(string), string acceptDatetime = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), IList select = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetKeyValueWithHttpMessagesAsync(key, label, acceptDatetime, ifMatch, ifNoneMatch, select, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Creates a key-value.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The key of the key-value to create.
+ ///
+ ///
+ /// The label of the key-value to create.
+ ///
+ ///
+ /// The key-value to create.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task PutKeyValueAsync(this IAzureAppConfigurationClient operations, string key, string label = default(string), KeyValue entity = default(KeyValue), string ifMatch = default(string), string ifNoneMatch = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.PutKeyValueWithHttpMessagesAsync(key, label, entity, ifMatch, ifNoneMatch, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Deletes a key-value.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The key of the key-value to delete.
+ ///
+ ///
+ /// The label of the key-value to delete.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteKeyValueAsync(this IAzureAppConfigurationClient operations, string key, string label = default(string), string ifMatch = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.DeleteKeyValueWithHttpMessagesAsync(key, label, ifMatch, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The key of the key-value to retrieve.
+ ///
+ ///
+ /// The label of the key-value to retrieve.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CheckKeyValueAsync(this IAzureAppConfigurationClient operations, string key, string label = default(string), string acceptDatetime = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), IList select = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CheckKeyValueWithHttpMessagesAsync(key, label, acceptDatetime, ifMatch, ifNoneMatch, select, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Gets a list of labels.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A filter for the name of the returned labels.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> GetLabelsAsync(this IAzureAppConfigurationClient operations, string name = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetLabelsWithHttpMessagesAsync(name, after, acceptDatetime, select, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A filter for the name of the returned labels.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CheckLabelsAsync(this IAzureAppConfigurationClient operations, string name = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CheckLabelsWithHttpMessagesAsync(name, after, acceptDatetime, select, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Locks a key-value.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The key of the key-value to lock.
+ ///
+ ///
+ /// The label, if any, of the key-value to lock.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task PutLockAsync(this IAzureAppConfigurationClient operations, string key, string label = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.PutLockWithHttpMessagesAsync(key, label, ifMatch, ifNoneMatch, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Unlocks a key-value.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The key of the key-value to unlock.
+ ///
+ ///
+ /// The label, if any, of the key-value to unlock.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag matches
+ /// the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag does not
+ /// match the value provided.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteLockAsync(this IAzureAppConfigurationClient operations, string key, string label = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.DeleteLockWithHttpMessagesAsync(key, label, ifMatch, ifNoneMatch, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets a list of key-value revisions.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> GetRevisionsAsync(this IAzureAppConfigurationClient operations, string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetRevisionsWithHttpMessagesAsync(key, label, after, acceptDatetime, select, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the element
+ /// referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CheckRevisionsAsync(this IAzureAppConfigurationClient operations, string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CheckRevisionsWithHttpMessagesAsync(key, label, after, acceptDatetime, select, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Gets a list of keys.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> GetKeysNextAsync(this IAzureAppConfigurationClient operations, string nextPageLink, string acceptDatetime = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetKeysNextWithHttpMessagesAsync(nextPageLink, acceptDatetime, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets a list of key-values.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> GetKeyValuesNextAsync(this IAzureAppConfigurationClient operations, string nextPageLink, string acceptDatetime = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetKeyValuesNextWithHttpMessagesAsync(nextPageLink, acceptDatetime, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets a list of labels.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> GetLabelsNextAsync(this IAzureAppConfigurationClient operations, string nextPageLink, string acceptDatetime = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetLabelsNextWithHttpMessagesAsync(nextPageLink, acceptDatetime, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets a list of key-value revisions.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at the
+ /// specified time.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> GetRevisionsNextAsync(this IAzureAppConfigurationClient operations, string nextPageLink, string acceptDatetime = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetRevisionsNextWithHttpMessagesAsync(nextPageLink, acceptDatetime, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/IAzureAppConfigurationClient.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/IAzureAppConfigurationClient.cs
new file mode 100644
index 000000000000..6719d1e35ff9
--- /dev/null
+++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/IAzureAppConfigurationClient.cs
@@ -0,0 +1,521 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.AppConfiguration
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ ///
+ public partial interface IAzureAppConfigurationClient : System.IDisposable
+ {
+ ///
+ /// The base URI of the service.
+ ///
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ JsonSerializerSettings SerializationSettings { get; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ JsonSerializerSettings DeserializationSettings { get; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ ServiceClientCredentials Credentials { get; }
+
+ ///
+ /// Used to guarantee real-time consistency between requests.
+ ///
+ string SyncToken { get; set; }
+
+ ///
+ /// The API version to be used with the HTTP request.
+ ///
+ string ApiVersion { get; }
+
+ ///
+ /// The endpoint of the App Configuration instance to send requests to.
+ ///
+ string Endpoint { get; set; }
+
+ ///
+ /// The preferred language for the response.
+ ///
+ string AcceptLanguage { get; set; }
+
+ ///
+ /// The retry timeout in seconds for Long Running Operations. Default
+ /// value is 30.
+ ///
+ int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// Whether a unique x-ms-client-request-id should be generated. When
+ /// set to true a unique x-ms-client-request-id value is generated and
+ /// included in each request. Default is true.
+ ///
+ bool? GenerateClientRequestId { get; set; }
+
+
+ ///
+ /// Gets a list of keys.
+ ///
+ ///
+ /// A filter for the name of the returned keys.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the
+ /// element referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at
+ /// the specified time.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task,GetKeysHeaders>> GetKeysWithHttpMessagesAsync(string name = default(string), string after = default(string), string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// A filter for the name of the returned keys.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the
+ /// element referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at
+ /// the specified time.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task> CheckKeysWithHttpMessagesAsync(string name = default(string), string after = default(string), string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Gets a list of key-values.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the
+ /// element referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at
+ /// the specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task,GetKeyValuesHeaders>> GetKeyValuesWithHttpMessagesAsync(string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// A filter used to match keys.
+ ///
+ ///
+ /// A filter used to match labels
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the
+ /// element referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at
+ /// the specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task> CheckKeyValuesWithHttpMessagesAsync(string key = default(string), string label = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Gets a single key-value.
+ ///
+ ///
+ /// The key of the key-value to retrieve.
+ ///
+ ///
+ /// The label of the key-value to retrieve.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at
+ /// the specified time.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag
+ /// matches the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag
+ /// does not match the value provided.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task> GetKeyValueWithHttpMessagesAsync(string key, string label = default(string), string acceptDatetime = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Creates a key-value.
+ ///
+ ///
+ /// The key of the key-value to create.
+ ///
+ ///
+ /// The label of the key-value to create.
+ ///
+ ///
+ /// The key-value to create.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag
+ /// matches the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag
+ /// does not match the value provided.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task> PutKeyValueWithHttpMessagesAsync(string key, string label = default(string), KeyValue entity = default(KeyValue), string ifMatch = default(string), string ifNoneMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Deletes a key-value.
+ ///
+ ///
+ /// The key of the key-value to delete.
+ ///
+ ///
+ /// The label of the key-value to delete.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag
+ /// matches the value provided.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task> DeleteKeyValueWithHttpMessagesAsync(string key, string label = default(string), string ifMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Requests the headers and status of the given resource.
+ ///
+ ///
+ /// The key of the key-value to retrieve.
+ ///
+ ///
+ /// The label of the key-value to retrieve.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at
+ /// the specified time.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag
+ /// matches the value provided.
+ ///
+ ///
+ /// Used to perform an operation only if the targeted resource's etag
+ /// does not match the value provided.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task> CheckKeyValueWithHttpMessagesAsync(string key, string label = default(string), string acceptDatetime = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), IList select = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Gets a list of labels.
+ ///
+ ///
+ /// A filter for the name of the returned labels.
+ ///
+ ///
+ /// Instructs the server to return elements that appear after the
+ /// element referred to by the specified token.
+ ///
+ ///
+ /// Requests the server to respond with the state of the resource at
+ /// the specified time.
+ ///
+ ///
+ /// Used to select what fields are present in the returned resource(s).
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task,GetLabelsHeaders>> GetLabelsWithHttpMessagesAsync(string name = default(string), string after = default(string), string acceptDatetime = default(string), IList select = default(IList