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), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// 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). + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + 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)); + + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> PutLockWithHttpMessagesAsync(string key, string label = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> DeleteLockWithHttpMessagesAsync(string key, string label = default(string), string ifMatch = default(string), string ifNoneMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// 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). + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + 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)); + + /// + /// 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> 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)); + + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task,GetKeysHeaders>> GetKeysNextWithHttpMessagesAsync(string nextPageLink, string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task,GetKeyValuesHeaders>> GetKeyValuesNextWithHttpMessagesAsync(string nextPageLink, string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task,GetLabelsHeaders>> GetLabelsNextWithHttpMessagesAsync(string nextPageLink, string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task,GetRevisionsHeaders>> GetRevisionsNextWithHttpMessagesAsync(string nextPageLink, string acceptDatetime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckKeyValueHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckKeyValueHeaders.cs new file mode 100644 index 000000000000..f5d38f290687 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckKeyValueHeaders.cs @@ -0,0 +1,75 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CheckKeyValue operation. + /// + public partial class CheckKeyValueHeaders + { + /// + /// Initializes a new instance of the CheckKeyValueHeaders class. + /// + public CheckKeyValueHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckKeyValueHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + /// An identifier representing the returned state of + /// the resource. + /// A UTC datetime that specifies the last + /// time the resource was modified. + public CheckKeyValueHeaders(string syncToken = default(string), string eTag = default(string), string lastModified = default(string)) + { + SyncToken = syncToken; + ETag = eTag; + LastModified = lastModified; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + /// + /// Gets or sets an identifier representing the returned state of the + /// resource. + /// + [JsonProperty(PropertyName = "ETag")] + public string ETag { get; set; } + + /// + /// Gets or sets a UTC datetime that specifies the last time the + /// resource was modified. + /// + [JsonProperty(PropertyName = "Last-Modified")] + public string LastModified { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckKeyValuesHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckKeyValuesHeaders.cs new file mode 100644 index 000000000000..b27f744a4658 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckKeyValuesHeaders.cs @@ -0,0 +1,55 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CheckKeyValues operation. + /// + public partial class CheckKeyValuesHeaders + { + /// + /// Initializes a new instance of the CheckKeyValuesHeaders class. + /// + public CheckKeyValuesHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckKeyValuesHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + public CheckKeyValuesHeaders(string syncToken = default(string)) + { + SyncToken = syncToken; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckKeysHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckKeysHeaders.cs new file mode 100644 index 000000000000..16f47f8e24eb --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckKeysHeaders.cs @@ -0,0 +1,55 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CheckKeys operation. + /// + public partial class CheckKeysHeaders + { + /// + /// Initializes a new instance of the CheckKeysHeaders class. + /// + public CheckKeysHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckKeysHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + public CheckKeysHeaders(string syncToken = default(string)) + { + SyncToken = syncToken; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckLabelsHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckLabelsHeaders.cs new file mode 100644 index 000000000000..55fd59dbb3f7 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckLabelsHeaders.cs @@ -0,0 +1,55 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CheckLabels operation. + /// + public partial class CheckLabelsHeaders + { + /// + /// Initializes a new instance of the CheckLabelsHeaders class. + /// + public CheckLabelsHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckLabelsHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + public CheckLabelsHeaders(string syncToken = default(string)) + { + SyncToken = syncToken; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckRevisionsHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckRevisionsHeaders.cs new file mode 100644 index 000000000000..0005f67142bf --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/CheckRevisionsHeaders.cs @@ -0,0 +1,55 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CheckRevisions operation. + /// + public partial class CheckRevisionsHeaders + { + /// + /// Initializes a new instance of the CheckRevisionsHeaders class. + /// + public CheckRevisionsHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckRevisionsHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + public CheckRevisionsHeaders(string syncToken = default(string)) + { + SyncToken = syncToken; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/DeleteKeyValueHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/DeleteKeyValueHeaders.cs new file mode 100644 index 000000000000..156c0edf09af --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/DeleteKeyValueHeaders.cs @@ -0,0 +1,65 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for DeleteKeyValue operation. + /// + public partial class DeleteKeyValueHeaders + { + /// + /// Initializes a new instance of the DeleteKeyValueHeaders class. + /// + public DeleteKeyValueHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeleteKeyValueHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + /// An identifier representing the returned state of + /// the resource. + public DeleteKeyValueHeaders(string syncToken = default(string), string eTag = default(string)) + { + SyncToken = syncToken; + ETag = eTag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + /// + /// Gets or sets an identifier representing the returned state of the + /// resource. + /// + [JsonProperty(PropertyName = "ETag")] + public string ETag { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/DeleteLockHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/DeleteLockHeaders.cs new file mode 100644 index 000000000000..6972c1c01651 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/DeleteLockHeaders.cs @@ -0,0 +1,65 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for DeleteLock operation. + /// + public partial class DeleteLockHeaders + { + /// + /// Initializes a new instance of the DeleteLockHeaders class. + /// + public DeleteLockHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeleteLockHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + /// An identifier representing the returned state of + /// the resource. + public DeleteLockHeaders(string syncToken = default(string), string eTag = default(string)) + { + SyncToken = syncToken; + ETag = eTag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + /// + /// Gets or sets an identifier representing the returned state of the + /// resource. + /// + [JsonProperty(PropertyName = "ETag")] + public string ETag { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Error.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Error.cs new file mode 100644 index 000000000000..2f94cfadfe9e --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Error.cs @@ -0,0 +1,85 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Azure App Configuration error object. + /// + public partial class Error + { + /// + /// Initializes a new instance of the Error class. + /// + public Error() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Error class. + /// + /// The type of the error. + /// A brief summary of the error. + /// The name of the parameter that resulted in the + /// error. + /// A detailed description of the error. + /// The HTTP status code that the error maps + /// to. + public Error(string type = default(string), string title = default(string), string name = default(string), string detail = default(string), int? status = default(int?)) + { + Type = type; + Title = title; + Name = name; + Detail = detail; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the error. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets a brief summary of the error. + /// + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Gets or sets the name of the parameter that resulted in the error. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets a detailed description of the error. + /// + [JsonProperty(PropertyName = "detail")] + public string Detail { get; set; } + + /// + /// Gets or sets the HTTP status code that the error maps to. + /// + [JsonProperty(PropertyName = "status")] + public int? Status { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/ErrorException.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/ErrorException.cs new file mode 100644 index 000000000000..218c9cbaabd9 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/ErrorException.cs @@ -0,0 +1,61 @@ +// +// 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.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with Error information. + /// + public partial class ErrorException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public Error Body { get; set; } + + /// + /// Initializes a new instance of the ErrorException class. + /// + public ErrorException() + { + } + + /// + /// Initializes a new instance of the ErrorException class. + /// + /// The exception message. + public ErrorException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorException class. + /// + /// The exception message. + /// Inner exception. + public ErrorException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetKeyValueHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetKeyValueHeaders.cs new file mode 100644 index 000000000000..10cca100f60c --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetKeyValueHeaders.cs @@ -0,0 +1,75 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for GetKeyValue operation. + /// + public partial class GetKeyValueHeaders + { + /// + /// Initializes a new instance of the GetKeyValueHeaders class. + /// + public GetKeyValueHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GetKeyValueHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + /// An identifier representing the returned state of + /// the resource. + /// A UTC datetime that specifies the last + /// time the resource was modified. + public GetKeyValueHeaders(string syncToken = default(string), string eTag = default(string), string lastModified = default(string)) + { + SyncToken = syncToken; + ETag = eTag; + LastModified = lastModified; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + /// + /// Gets or sets an identifier representing the returned state of the + /// resource. + /// + [JsonProperty(PropertyName = "ETag")] + public string ETag { get; set; } + + /// + /// Gets or sets a UTC datetime that specifies the last time the + /// resource was modified. + /// + [JsonProperty(PropertyName = "Last-Modified")] + public string LastModified { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetKeyValuesHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetKeyValuesHeaders.cs new file mode 100644 index 000000000000..94edb89ef45e --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetKeyValuesHeaders.cs @@ -0,0 +1,55 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for GetKeyValues operation. + /// + public partial class GetKeyValuesHeaders + { + /// + /// Initializes a new instance of the GetKeyValuesHeaders class. + /// + public GetKeyValuesHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GetKeyValuesHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + public GetKeyValuesHeaders(string syncToken = default(string)) + { + SyncToken = syncToken; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetKeysHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetKeysHeaders.cs new file mode 100644 index 000000000000..abe308cab4ee --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetKeysHeaders.cs @@ -0,0 +1,55 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for GetKeys operation. + /// + public partial class GetKeysHeaders + { + /// + /// Initializes a new instance of the GetKeysHeaders class. + /// + public GetKeysHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GetKeysHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + public GetKeysHeaders(string syncToken = default(string)) + { + SyncToken = syncToken; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetLabelsHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetLabelsHeaders.cs new file mode 100644 index 000000000000..d658cdee1e6c --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetLabelsHeaders.cs @@ -0,0 +1,55 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for GetLabels operation. + /// + public partial class GetLabelsHeaders + { + /// + /// Initializes a new instance of the GetLabelsHeaders class. + /// + public GetLabelsHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GetLabelsHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + public GetLabelsHeaders(string syncToken = default(string)) + { + SyncToken = syncToken; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetRevisionsHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetRevisionsHeaders.cs new file mode 100644 index 000000000000..6cb1607ffa48 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/GetRevisionsHeaders.cs @@ -0,0 +1,55 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for GetRevisions operation. + /// + public partial class GetRevisionsHeaders + { + /// + /// Initializes a new instance of the GetRevisionsHeaders class. + /// + public GetRevisionsHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GetRevisionsHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + public GetRevisionsHeaders(string syncToken = default(string)) + { + SyncToken = syncToken; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Key.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Key.cs new file mode 100644 index 000000000000..bf65e49833b8 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Key.cs @@ -0,0 +1,46 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class Key + { + /// + /// Initializes a new instance of the Key class. + /// + public Key() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Key class. + /// + public Key(string name = default(string)) + { + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/KeyValue.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/KeyValue.cs new file mode 100644 index 000000000000..ed371b62c949 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/KeyValue.cs @@ -0,0 +1,90 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class KeyValue + { + /// + /// Initializes a new instance of the KeyValue class. + /// + public KeyValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the KeyValue class. + /// + public KeyValue(string key = default(string), string label = default(string), string contentType = default(string), string value = default(string), System.DateTime? lastModified = default(System.DateTime?), IDictionary tags = default(IDictionary), bool? locked = default(bool?), string etag = default(string)) + { + Key = key; + Label = label; + ContentType = contentType; + Value = value; + LastModified = lastModified; + Tags = tags; + Locked = locked; + Etag = etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "key")] + public string Key { get; set; } + + /// + /// + [JsonProperty(PropertyName = "label")] + public string Label { get; set; } + + /// + /// + [JsonProperty(PropertyName = "content_type")] + public string ContentType { get; set; } + + /// + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// + [JsonProperty(PropertyName = "last_modified")] + public System.DateTime? LastModified { get; set; } + + /// + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// + [JsonProperty(PropertyName = "locked")] + public bool? Locked { get; set; } + + /// + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Label.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Label.cs new file mode 100644 index 000000000000..818854a5d741 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Label.cs @@ -0,0 +1,46 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class Label + { + /// + /// Initializes a new instance of the Label class. + /// + public Label() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Label class. + /// + public Label(string name = default(string)) + { + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Page.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Page.cs new file mode 100644 index 000000000000..ebe4f9e4e1f2 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/Page.cs @@ -0,0 +1,53 @@ +// +// 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.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("@nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("items")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/PutKeyValueHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/PutKeyValueHeaders.cs new file mode 100644 index 000000000000..756c49ae41a4 --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/PutKeyValueHeaders.cs @@ -0,0 +1,65 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for PutKeyValue operation. + /// + public partial class PutKeyValueHeaders + { + /// + /// Initializes a new instance of the PutKeyValueHeaders class. + /// + public PutKeyValueHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PutKeyValueHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + /// An identifier representing the returned state of + /// the resource. + public PutKeyValueHeaders(string syncToken = default(string), string eTag = default(string)) + { + SyncToken = syncToken; + ETag = eTag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + /// + /// Gets or sets an identifier representing the returned state of the + /// resource. + /// + [JsonProperty(PropertyName = "ETag")] + public string ETag { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/PutLockHeaders.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/PutLockHeaders.cs new file mode 100644 index 000000000000..0b1bc406108a --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/Models/PutLockHeaders.cs @@ -0,0 +1,65 @@ +// +// 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.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for PutLock operation. + /// + public partial class PutLockHeaders + { + /// + /// Initializes a new instance of the PutLockHeaders class. + /// + public PutLockHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PutLockHeaders class. + /// + /// Enables real-time consistency between + /// requests by providing the returned value in the next request made + /// to the server. + /// An identifier representing the returned state of + /// the resource. + public PutLockHeaders(string syncToken = default(string), string eTag = default(string)) + { + SyncToken = syncToken; + ETag = eTag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets enables real-time consistency between requests by + /// providing the returned value in the next request made to the + /// server. + /// + [JsonProperty(PropertyName = "Sync-Token")] + public string SyncToken { get; set; } + + /// + /// Gets or sets an identifier representing the returned state of the + /// resource. + /// + [JsonProperty(PropertyName = "ETag")] + public string ETag { get; set; } + + } +} diff --git a/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/SdkInfo_AzureAppConfiguration.cs b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/SdkInfo_AzureAppConfiguration.cs new file mode 100644 index 000000000000..0bb8a0a22a5c --- /dev/null +++ b/sdk/AppConfiguration/preview/Microsoft.Azure.AppConfiguration/src/Generated/SdkInfo_AzureAppConfiguration.cs @@ -0,0 +1,40 @@ + +// +// 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 System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_AzureAppConfiguration + { + get + { + return new Tuple[] + { + new Tuple("AzureAppConfiguration", "CheckKeyValue", "1.0"), + new Tuple("AzureAppConfiguration", "CheckKeyValues", "1.0"), + new Tuple("AzureAppConfiguration", "CheckKeys", "1.0"), + new Tuple("AzureAppConfiguration", "CheckLabels", "1.0"), + new Tuple("AzureAppConfiguration", "CheckRevisions", "1.0"), + new Tuple("AzureAppConfiguration", "DeleteKeyValue", "1.0"), + new Tuple("AzureAppConfiguration", "DeleteLock", "1.0"), + new Tuple("AzureAppConfiguration", "GetKeyValue", "1.0"), + new Tuple("AzureAppConfiguration", "GetKeyValues", "1.0"), + new Tuple("AzureAppConfiguration", "GetKeys", "1.0"), + new Tuple("AzureAppConfiguration", "GetLabels", "1.0"), + new Tuple("AzureAppConfiguration", "GetRevisions", "1.0"), + new Tuple("AzureAppConfiguration", "PutKeyValue", "1.0"), + new Tuple("AzureAppConfiguration", "PutLock", "1.0"), + }.AsEnumerable(); + } + } + } +}