text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using Hyak.Common;
using Microsoft.Azure;
using Microsoft.Azure.Search;
using Microsoft.Azure.Search.Models;
using Newtonsoft.Json.Linq;

namespace Microsoft.Azure.Search
{
    /// <summary>
    /// Operations for managing indexers.  (see
    /// https://msdn.microsoft.com/library/azure/dn946891.aspx for more
    /// information)
    /// </summary>
    internal partial class IndexerOperations : IServiceOperations<SearchServiceClient>, IIndexerOperations
    {
        /// <summary>
        /// Initializes a new instance of the IndexerOperations class.
        /// </summary>
        /// <param name='client'>
        /// Reference to the service client.
        /// </param>
        internal IndexerOperations(SearchServiceClient client)
        {
            this._client = client;
        }

        private SearchServiceClient _client;

        /// <summary>
        /// Gets a reference to the Microsoft.Azure.Search.SearchServiceClient.
        /// </summary>
        public SearchServiceClient Client
        {
            get { return this._client; }
        }

        /// <summary>
        /// Creates a new Azure Search indexer.  (see
        /// https://msdn.microsoft.com/library/azure/dn946899.aspx for more
        /// information)
        /// </summary>
        /// <param name='indexer'>
        /// Required. The definition of the indexer to create.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// Response from a Create, Update, or Get Indexer request. If
        /// successful, it includes the full definition of the indexer that
        /// was created, updated, or retrieved.
        /// </returns>
        public async Task<IndexerDefinitionResponse> CreateAsync(Indexer indexer, CancellationToken cancellationToken)
        {
            // Validate
            if (indexer == null)
            {
                throw new ArgumentNullException("indexer");
            }
            if (indexer.DataSourceName == null)
            {
                throw new ArgumentNullException("indexer.DataSourceName");
            }
            if (indexer.Name == null)
            {
                throw new ArgumentNullException("indexer.Name");
            }
            if (indexer.TargetIndexName == null)
            {
                throw new ArgumentNullException("indexer.TargetIndexName");
            }

            // Tracing
            bool shouldTrace = TracingAdapter.IsEnabled;
            string invocationId = null;
            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
                tracingParameters.Add("indexer", indexer);
                TracingAdapter.Enter(invocationId, this, "CreateAsync", tracingParameters);
            }

            // Construct URL
            string url = "";
            url = url + "/indexers";
            List<string> queryParameters = new List<string>();
            queryParameters.Add("api-version=2015-02-28");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;
            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;
            try
            {
                httpRequest = new HttpRequestMessage();
                httpRequest.Method = HttpMethod.Post;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json;odata.metadata=none");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Serialize Request
                string requestContent = null;
                JToken requestDoc = null;

                JObject indexerCreateOrUpdateParametersValue = new JObject();
                requestDoc = indexerCreateOrUpdateParametersValue;

                indexerCreateOrUpdateParametersValue["name"] = indexer.Name;

                if (indexer.Description != null)
                {
                    indexerCreateOrUpdateParametersValue["description"] = indexer.Description;
                }

                indexerCreateOrUpdateParametersValue["dataSourceName"] = indexer.DataSourceName;

                indexerCreateOrUpdateParametersValue["targetIndexName"] = indexer.TargetIndexName;

                if (indexer.Schedule != null)
                {
                    JObject scheduleValue = new JObject();
                    indexerCreateOrUpdateParametersValue["schedule"] = scheduleValue;

                    scheduleValue["interval"] = XmlConvert.ToString(indexer.Schedule.Interval);

                    scheduleValue["startTime"] = indexer.Schedule.StartTime;
                }

                if (indexer.Parameters != null)
                {
                    JObject parametersValue = new JObject();
                    indexerCreateOrUpdateParametersValue["parameters"] = parametersValue;

                    parametersValue["maxFailedItems"] = indexer.Parameters.MaxFailedItems;

                    parametersValue["maxFailedItemsPerBatch"] = indexer.Parameters.MaxFailedItemsPerBatch;

                    parametersValue["base64EncodeKeys"] = indexer.Parameters.Base64EncodeKeys;
                }

                requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented);
                httpRequest.Content = new StringContent(requestContent, Encoding.UTF8);
                httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.Created)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    IndexerDefinitionResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.Created)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                        result = new IndexerDefinitionResponse();
                        JToken responseDoc = null;
                        if (string.IsNullOrEmpty(responseContent) == false)
                        {
                            responseDoc = JToken.Parse(responseContent);
                        }

                        if (responseDoc != null && responseDoc.Type != JTokenType.Null)
                        {
                            Indexer indexerInstance = new Indexer();
                            result.Indexer = indexerInstance;

                            JToken nameValue = responseDoc["name"];
                            if (nameValue != null && nameValue.Type != JTokenType.Null)
                            {
                                string nameInstance = ((string)nameValue);
                                indexerInstance.Name = nameInstance;
                            }

                            JToken descriptionValue = responseDoc["description"];
                            if (descriptionValue != null && descriptionValue.Type != JTokenType.Null)
                            {
                                string descriptionInstance = ((string)descriptionValue);
                                indexerInstance.Description = descriptionInstance;
                            }

                            JToken dataSourceNameValue = responseDoc["dataSourceName"];
                            if (dataSourceNameValue != null && dataSourceNameValue.Type != JTokenType.Null)
                            {
                                string dataSourceNameInstance = ((string)dataSourceNameValue);
                                indexerInstance.DataSourceName = dataSourceNameInstance;
                            }

                            JToken targetIndexNameValue = responseDoc["targetIndexName"];
                            if (targetIndexNameValue != null && targetIndexNameValue.Type != JTokenType.Null)
                            {
                                string targetIndexNameInstance = ((string)targetIndexNameValue);
                                indexerInstance.TargetIndexName = targetIndexNameInstance;
                            }

                            JToken scheduleValue2 = responseDoc["schedule"];
                            if (scheduleValue2 != null && scheduleValue2.Type != JTokenType.Null)
                            {
                                IndexingSchedule scheduleInstance = new IndexingSchedule();
                                indexerInstance.Schedule = scheduleInstance;

                                JToken intervalValue = scheduleValue2["interval"];
                                if (intervalValue != null && intervalValue.Type != JTokenType.Null)
                                {
                                    TimeSpan intervalInstance = XmlConvert.ToTimeSpan(((string)intervalValue));
                                    scheduleInstance.Interval = intervalInstance;
                                }

                                JToken startTimeValue = scheduleValue2["startTime"];
                                if (startTimeValue != null && startTimeValue.Type != JTokenType.Null)
                                {
                                    DateTimeOffset startTimeInstance = ((DateTimeOffset)startTimeValue);
                                    scheduleInstance.StartTime = startTimeInstance;
                                }
                            }

                            JToken parametersValue2 = responseDoc["parameters"];
                            if (parametersValue2 != null && parametersValue2.Type != JTokenType.Null)
                            {
                                IndexingParameters parametersInstance = new IndexingParameters();
                                indexerInstance.Parameters = parametersInstance;

                                JToken maxFailedItemsValue = parametersValue2["maxFailedItems"];
                                if (maxFailedItemsValue != null && maxFailedItemsValue.Type != JTokenType.Null)
                                {
                                    int maxFailedItemsInstance = ((int)maxFailedItemsValue);
                                    parametersInstance.MaxFailedItems = maxFailedItemsInstance;
                                }

                                JToken maxFailedItemsPerBatchValue = parametersValue2["maxFailedItemsPerBatch"];
                                if (maxFailedItemsPerBatchValue != null && maxFailedItemsPerBatchValue.Type != JTokenType.Null)
                                {
                                    int maxFailedItemsPerBatchInstance = ((int)maxFailedItemsPerBatchValue);
                                    parametersInstance.MaxFailedItemsPerBatch = maxFailedItemsPerBatchInstance;
                                }

                                JToken base64EncodeKeysValue = parametersValue2["base64EncodeKeys"];
                                if (base64EncodeKeysValue != null && base64EncodeKeysValue.Type != JTokenType.Null)
                                {
                                    bool base64EncodeKeysInstance = ((bool)base64EncodeKeysValue);
                                    parametersInstance.Base64EncodeKeys = base64EncodeKeysInstance;
                                }
                            }
                        }

                    }
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return result;
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }

        /// <summary>
        /// Creates a new Azure Search indexer or updates an indexer if it
        /// already exists.  (see
        /// https://msdn.microsoft.com/library/azure/dn946899.aspx for more
        /// information)
        /// </summary>
        /// <param name='indexer'>
        /// Required. The definition of the indexer to create or update.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// Response from a Create, Update, or Get Indexer request. If
        /// successful, it includes the full definition of the indexer that
        /// was created, updated, or retrieved.
        /// </returns>
        public async Task<IndexerDefinitionResponse> CreateOrUpdateAsync(Indexer indexer, CancellationToken cancellationToken)
        {
            // Validate
            if (indexer == null)
            {
                throw new ArgumentNullException("indexer");
            }
            if (indexer.DataSourceName == null)
            {
                throw new ArgumentNullException("indexer.DataSourceName");
            }
            if (indexer.Name == null)
            {
                throw new ArgumentNullException("indexer.Name");
            }
            if (indexer.TargetIndexName == null)
            {
                throw new ArgumentNullException("indexer.TargetIndexName");
            }

            // Tracing
            bool shouldTrace = TracingAdapter.IsEnabled;
            string invocationId = null;
            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
                tracingParameters.Add("indexer", indexer);
                TracingAdapter.Enter(invocationId, this, "CreateOrUpdateAsync", tracingParameters);
            }

            // Construct URL
            string url = "";
            url = url + "/indexers('";
            url = url + Uri.EscapeDataString(indexer.Name);
            url = url + "')";
            List<string> queryParameters = new List<string>();
            queryParameters.Add("api-version=2015-02-28");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;
            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;
            try
            {
                httpRequest = new HttpRequestMessage();
                httpRequest.Method = HttpMethod.Put;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json;odata.metadata=none");
                httpRequest.Headers.Add("Prefer", "return=representation");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Serialize Request
                string requestContent = null;
                JToken requestDoc = null;

                JObject indexerCreateOrUpdateParametersValue = new JObject();
                requestDoc = indexerCreateOrUpdateParametersValue;

                indexerCreateOrUpdateParametersValue["name"] = indexer.Name;

                if (indexer.Description != null)
                {
                    indexerCreateOrUpdateParametersValue["description"] = indexer.Description;
                }

                indexerCreateOrUpdateParametersValue["dataSourceName"] = indexer.DataSourceName;

                indexerCreateOrUpdateParametersValue["targetIndexName"] = indexer.TargetIndexName;

                if (indexer.Schedule != null)
                {
                    JObject scheduleValue = new JObject();
                    indexerCreateOrUpdateParametersValue["schedule"] = scheduleValue;

                    scheduleValue["interval"] = XmlConvert.ToString(indexer.Schedule.Interval);

                    scheduleValue["startTime"] = indexer.Schedule.StartTime;
                }

                if (indexer.Parameters != null)
                {
                    JObject parametersValue = new JObject();
                    indexerCreateOrUpdateParametersValue["parameters"] = parametersValue;

                    parametersValue["maxFailedItems"] = indexer.Parameters.MaxFailedItems;

                    parametersValue["maxFailedItemsPerBatch"] = indexer.Parameters.MaxFailedItemsPerBatch;

                    parametersValue["base64EncodeKeys"] = indexer.Parameters.Base64EncodeKeys;
                }

                requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented);
                httpRequest.Content = new StringContent(requestContent, Encoding.UTF8);
                httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Created)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    IndexerDefinitionResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                        result = new IndexerDefinitionResponse();
                        JToken responseDoc = null;
                        if (string.IsNullOrEmpty(responseContent) == false)
                        {
                            responseDoc = JToken.Parse(responseContent);
                        }

                        if (responseDoc != null && responseDoc.Type != JTokenType.Null)
                        {
                            Indexer indexerInstance = new Indexer();
                            result.Indexer = indexerInstance;

                            JToken nameValue = responseDoc["name"];
                            if (nameValue != null && nameValue.Type != JTokenType.Null)
                            {
                                string nameInstance = ((string)nameValue);
                                indexerInstance.Name = nameInstance;
                            }

                            JToken descriptionValue = responseDoc["description"];
                            if (descriptionValue != null && descriptionValue.Type != JTokenType.Null)
                            {
                                string descriptionInstance = ((string)descriptionValue);
                                indexerInstance.Description = descriptionInstance;
                            }

                            JToken dataSourceNameValue = responseDoc["dataSourceName"];
                            if (dataSourceNameValue != null && dataSourceNameValue.Type != JTokenType.Null)
                            {
                                string dataSourceNameInstance = ((string)dataSourceNameValue);
                                indexerInstance.DataSourceName = dataSourceNameInstance;
                            }

                            JToken targetIndexNameValue = responseDoc["targetIndexName"];
                            if (targetIndexNameValue != null && targetIndexNameValue.Type != JTokenType.Null)
                            {
                                string targetIndexNameInstance = ((string)targetIndexNameValue);
                                indexerInstance.TargetIndexName = targetIndexNameInstance;
                            }

                            JToken scheduleValue2 = responseDoc["schedule"];
                            if (scheduleValue2 != null && scheduleValue2.Type != JTokenType.Null)
                            {
                                IndexingSchedule scheduleInstance = new IndexingSchedule();
                                indexerInstance.Schedule = scheduleInstance;

                                JToken intervalValue = scheduleValue2["interval"];
                                if (intervalValue != null && intervalValue.Type != JTokenType.Null)
                                {
                                    TimeSpan intervalInstance = XmlConvert.ToTimeSpan(((string)intervalValue));
                                    scheduleInstance.Interval = intervalInstance;
                                }

                                JToken startTimeValue = scheduleValue2["startTime"];
                                if (startTimeValue != null && startTimeValue.Type != JTokenType.Null)
                                {
                                    DateTimeOffset startTimeInstance = ((DateTimeOffset)startTimeValue);
                                    scheduleInstance.StartTime = startTimeInstance;
                                }
                            }

                            JToken parametersValue2 = responseDoc["parameters"];
                            if (parametersValue2 != null && parametersValue2.Type != JTokenType.Null)
                            {
                                IndexingParameters parametersInstance = new IndexingParameters();
                                indexerInstance.Parameters = parametersInstance;

                                JToken maxFailedItemsValue = parametersValue2["maxFailedItems"];
                                if (maxFailedItemsValue != null && maxFailedItemsValue.Type != JTokenType.Null)
                                {
                                    int maxFailedItemsInstance = ((int)maxFailedItemsValue);
                                    parametersInstance.MaxFailedItems = maxFailedItemsInstance;
                                }

                                JToken maxFailedItemsPerBatchValue = parametersValue2["maxFailedItemsPerBatch"];
                                if (maxFailedItemsPerBatchValue != null && maxFailedItemsPerBatchValue.Type != JTokenType.Null)
                                {
                                    int maxFailedItemsPerBatchInstance = ((int)maxFailedItemsPerBatchValue);
                                    parametersInstance.MaxFailedItemsPerBatch = maxFailedItemsPerBatchInstance;
                                }

                                JToken base64EncodeKeysValue = parametersValue2["base64EncodeKeys"];
                                if (base64EncodeKeysValue != null && base64EncodeKeysValue.Type != JTokenType.Null)
                                {
                                    bool base64EncodeKeysInstance = ((bool)base64EncodeKeysValue);
                                    parametersInstance.Base64EncodeKeys = base64EncodeKeysInstance;
                                }
                            }
                        }

                    }
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return result;
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }

        /// <summary>
        /// Deletes an Azure Search indexer.  (see
        /// https://msdn.microsoft.com/library/azure/dn946898.aspx for more
        /// information)
        /// </summary>
        /// <param name='indexerName'>
        /// Required. The name of the indexer to delete.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// A standard service response including an HTTP status code and
        /// request ID.
        /// </returns>
        public async Task<AzureOperationResponse> DeleteAsync(string indexerName, CancellationToken cancellationToken)
        {
            // Validate
            if (indexerName == null)
            {
                throw new ArgumentNullException("indexerName");
            }

            // Tracing
            bool shouldTrace = TracingAdapter.IsEnabled;
            string invocationId = null;
            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
                tracingParameters.Add("indexerName", indexerName);
                TracingAdapter.Enter(invocationId, this, "DeleteAsync", tracingParameters);
            }

            // Construct URL
            string url = "";
            url = url + "/indexers('";
            url = url + Uri.EscapeDataString(indexerName);
            url = url + "')";
            List<string> queryParameters = new List<string>();
            queryParameters.Add("api-version=2015-02-28");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;
            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;
            try
            {
                httpRequest = new HttpRequestMessage();
                httpRequest.Method = HttpMethod.Delete;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json;odata.metadata=none");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.NoContent && statusCode != HttpStatusCode.NotFound)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    AzureOperationResponse result = null;
                    // Deserialize Response
                    result = new AzureOperationResponse();
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return result;
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }

        /// <summary>
        /// Retrieves an indexer definition from Azure Search.  (see
        /// https://msdn.microsoft.com/library/azure/dn946874.aspx for more
        /// information)
        /// </summary>
        /// <param name='indexerName'>
        /// Required. The name of the indexer to retrieve.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// Response from a Create, Update, or Get Indexer request. If
        /// successful, it includes the full definition of the indexer that
        /// was created, updated, or retrieved.
        /// </returns>
        public async Task<IndexerDefinitionResponse> GetAsync(string indexerName, CancellationToken cancellationToken)
        {
            // Validate
            if (indexerName == null)
            {
                throw new ArgumentNullException("indexerName");
            }

            // Tracing
            bool shouldTrace = TracingAdapter.IsEnabled;
            string invocationId = null;
            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
                tracingParameters.Add("indexerName", indexerName);
                TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters);
            }

            // Construct URL
            string url = "";
            url = url + "/indexers('";
            url = url + Uri.EscapeDataString(indexerName);
            url = url + "')";
            List<string> queryParameters = new List<string>();
            queryParameters.Add("api-version=2015-02-28");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;
            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;
            try
            {
                httpRequest = new HttpRequestMessage();
                httpRequest.Method = HttpMethod.Get;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json;odata.metadata=none");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    IndexerDefinitionResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                        result = new IndexerDefinitionResponse();
                        JToken responseDoc = null;
                        if (string.IsNullOrEmpty(responseContent) == false)
                        {
                            responseDoc = JToken.Parse(responseContent);
                        }

                        if (responseDoc != null && responseDoc.Type != JTokenType.Null)
                        {
                            Indexer indexerInstance = new Indexer();
                            result.Indexer = indexerInstance;

                            JToken nameValue = responseDoc["name"];
                            if (nameValue != null && nameValue.Type != JTokenType.Null)
                            {
                                string nameInstance = ((string)nameValue);
                                indexerInstance.Name = nameInstance;
                            }

                            JToken descriptionValue = responseDoc["description"];
                            if (descriptionValue != null && descriptionValue.Type != JTokenType.Null)
                            {
                                string descriptionInstance = ((string)descriptionValue);
                                indexerInstance.Description = descriptionInstance;
                            }

                            JToken dataSourceNameValue = responseDoc["dataSourceName"];
                            if (dataSourceNameValue != null && dataSourceNameValue.Type != JTokenType.Null)
                            {
                                string dataSourceNameInstance = ((string)dataSourceNameValue);
                                indexerInstance.DataSourceName = dataSourceNameInstance;
                            }

                            JToken targetIndexNameValue = responseDoc["targetIndexName"];
                            if (targetIndexNameValue != null && targetIndexNameValue.Type != JTokenType.Null)
                            {
                                string targetIndexNameInstance = ((string)targetIndexNameValue);
                                indexerInstance.TargetIndexName = targetIndexNameInstance;
                            }

                            JToken scheduleValue = responseDoc["schedule"];
                            if (scheduleValue != null && scheduleValue.Type != JTokenType.Null)
                            {
                                IndexingSchedule scheduleInstance = new IndexingSchedule();
                                indexerInstance.Schedule = scheduleInstance;

                                JToken intervalValue = scheduleValue["interval"];
                                if (intervalValue != null && intervalValue.Type != JTokenType.Null)
                                {
                                    TimeSpan intervalInstance = XmlConvert.ToTimeSpan(((string)intervalValue));
                                    scheduleInstance.Interval = intervalInstance;
                                }

                                JToken startTimeValue = scheduleValue["startTime"];
                                if (startTimeValue != null && startTimeValue.Type != JTokenType.Null)
                                {
                                    DateTimeOffset startTimeInstance = ((DateTimeOffset)startTimeValue);
                                    scheduleInstance.StartTime = startTimeInstance;
                                }
                            }

                            JToken parametersValue = responseDoc["parameters"];
                            if (parametersValue != null && parametersValue.Type != JTokenType.Null)
                            {
                                IndexingParameters parametersInstance = new IndexingParameters();
                                indexerInstance.Parameters = parametersInstance;

                                JToken maxFailedItemsValue = parametersValue["maxFailedItems"];
                                if (maxFailedItemsValue != null && maxFailedItemsValue.Type != JTokenType.Null)
                                {
                                    int maxFailedItemsInstance = ((int)maxFailedItemsValue);
                                    parametersInstance.MaxFailedItems = maxFailedItemsInstance;
                                }

                                JToken maxFailedItemsPerBatchValue = parametersValue["maxFailedItemsPerBatch"];
                                if (maxFailedItemsPerBatchValue != null && maxFailedItemsPerBatchValue.Type != JTokenType.Null)
                                {
                                    int maxFailedItemsPerBatchInstance = ((int)maxFailedItemsPerBatchValue);
                                    parametersInstance.MaxFailedItemsPerBatch = maxFailedItemsPerBatchInstance;
                                }

                                JToken base64EncodeKeysValue = parametersValue["base64EncodeKeys"];
                                if (base64EncodeKeysValue != null && base64EncodeKeysValue.Type != JTokenType.Null)
                                {
                                    bool base64EncodeKeysInstance = ((bool)base64EncodeKeysValue);
                                    parametersInstance.Base64EncodeKeys = base64EncodeKeysInstance;
                                }
                            }
                        }

                    }
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return result;
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }

        /// <summary>
        /// Returns the current status and execution history of an indexer.
        /// (see https://msdn.microsoft.com/library/azure/dn946884.aspx for
        /// more information)
        /// </summary>
        /// <param name='indexerName'>
        /// Required. The name of the indexer for which to retrieve status.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// Current status and execution history of an indexer.
        /// </returns>
        public async Task<IndexerGetStatusResponse> GetStatusAsync(string indexerName, CancellationToken cancellationToken)
        {
            // Validate
            if (indexerName == null)
            {
                throw new ArgumentNullException("indexerName");
            }

            // Tracing
            bool shouldTrace = TracingAdapter.IsEnabled;
            string invocationId = null;
            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
                tracingParameters.Add("indexerName", indexerName);
                TracingAdapter.Enter(invocationId, this, "GetStatusAsync", tracingParameters);
            }

            // Construct URL
            string url = "";
            url = url + "/indexers('";
            url = url + Uri.EscapeDataString(indexerName);
            url = url + "')/search.status";
            List<string> queryParameters = new List<string>();
            queryParameters.Add("api-version=2015-02-28");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;
            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;
            try
            {
                httpRequest = new HttpRequestMessage();
                httpRequest.Method = HttpMethod.Get;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json;odata.metadata=none");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    IndexerGetStatusResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                        result = new IndexerGetStatusResponse();
                        JToken responseDoc = null;
                        if (string.IsNullOrEmpty(responseContent) == false)
                        {
                            responseDoc = JToken.Parse(responseContent);
                        }

                        if (responseDoc != null && responseDoc.Type != JTokenType.Null)
                        {
                            IndexerExecutionInfo executionInfoInstance = new IndexerExecutionInfo();
                            result.ExecutionInfo = executionInfoInstance;

                            JToken statusValue = responseDoc["status"];
                            if (statusValue != null && statusValue.Type != JTokenType.Null)
                            {
                                IndexerStatus statusInstance = SearchServiceClient.ParseIndexerStatus(((string)statusValue));
                                executionInfoInstance.Status = statusInstance;
                            }

                            JToken lastResultValue = responseDoc["lastResult"];
                            if (lastResultValue != null && lastResultValue.Type != JTokenType.Null)
                            {
                                IndexerExecutionResult lastResultInstance = new IndexerExecutionResult();
                                executionInfoInstance.LastResult = lastResultInstance;

                                JToken statusValue2 = lastResultValue["status"];
                                if (statusValue2 != null && statusValue2.Type != JTokenType.Null)
                                {
                                    IndexerExecutionStatus statusInstance2 = SearchServiceClient.ParseIndexerExecutionStatus(((string)statusValue2));
                                    lastResultInstance.Status = statusInstance2;
                                }

                                JToken errorMessageValue = lastResultValue["errorMessage"];
                                if (errorMessageValue != null && errorMessageValue.Type != JTokenType.Null)
                                {
                                    string errorMessageInstance = ((string)errorMessageValue);
                                    lastResultInstance.ErrorMessage = errorMessageInstance;
                                }

                                JToken startTimeValue = lastResultValue["startTime"];
                                if (startTimeValue != null && startTimeValue.Type != JTokenType.Null)
                                {
                                    DateTimeOffset startTimeInstance = ((DateTimeOffset)startTimeValue);
                                    lastResultInstance.StartTime = startTimeInstance;
                                }

                                JToken endTimeValue = lastResultValue["endTime"];
                                if (endTimeValue != null && endTimeValue.Type != JTokenType.Null)
                                {
                                    DateTimeOffset endTimeInstance = ((DateTimeOffset)endTimeValue);
                                    lastResultInstance.EndTime = endTimeInstance;
                                }

                                JToken errorsArray = lastResultValue["errors"];
                                if (errorsArray != null && errorsArray.Type != JTokenType.Null)
                                {
                                    foreach (JToken errorsValue in ((JArray)errorsArray))
                                    {
                                        ItemError itemErrorInstance = new ItemError();
                                        lastResultInstance.Errors.Add(itemErrorInstance);

                                        JToken keyValue = errorsValue["key"];
                                        if (keyValue != null && keyValue.Type != JTokenType.Null)
                                        {
                                            string keyInstance = ((string)keyValue);
                                            itemErrorInstance.Key = keyInstance;
                                        }

                                        JToken errorMessageValue2 = errorsValue["errorMessage"];
                                        if (errorMessageValue2 != null && errorMessageValue2.Type != JTokenType.Null)
                                        {
                                            string errorMessageInstance2 = ((string)errorMessageValue2);
                                            itemErrorInstance.ErrorMessage = errorMessageInstance2;
                                        }
                                    }
                                }

                                JToken itemsProcessedValue = lastResultValue["itemsProcessed"];
                                if (itemsProcessedValue != null && itemsProcessedValue.Type != JTokenType.Null)
                                {
                                    int itemsProcessedInstance = ((int)itemsProcessedValue);
                                    lastResultInstance.ItemCount = itemsProcessedInstance;
                                }

                                JToken itemsFailedValue = lastResultValue["itemsFailed"];
                                if (itemsFailedValue != null && itemsFailedValue.Type != JTokenType.Null)
                                {
                                    int itemsFailedInstance = ((int)itemsFailedValue);
                                    lastResultInstance.FailedItemCount = itemsFailedInstance;
                                }

                                JToken initialTrackingStateValue = lastResultValue["initialTrackingState"];
                                if (initialTrackingStateValue != null && initialTrackingStateValue.Type != JTokenType.Null)
                                {
                                    string initialTrackingStateInstance = ((string)initialTrackingStateValue);
                                    lastResultInstance.InitialTrackingState = initialTrackingStateInstance;
                                }

                                JToken finalTrackingStateValue = lastResultValue["finalTrackingState"];
                                if (finalTrackingStateValue != null && finalTrackingStateValue.Type != JTokenType.Null)
                                {
                                    string finalTrackingStateInstance = ((string)finalTrackingStateValue);
                                    lastResultInstance.FinalTrackingState = finalTrackingStateInstance;
                                }
                            }

                            JToken executionHistoryArray = responseDoc["executionHistory"];
                            if (executionHistoryArray != null && executionHistoryArray.Type != JTokenType.Null)
                            {
                                foreach (JToken executionHistoryValue in ((JArray)executionHistoryArray))
                                {
                                    IndexerExecutionResult indexerExecutionResultInstance = new IndexerExecutionResult();
                                    executionInfoInstance.ExecutionHistory.Add(indexerExecutionResultInstance);

                                    JToken statusValue3 = executionHistoryValue["status"];
                                    if (statusValue3 != null && statusValue3.Type != JTokenType.Null)
                                    {
                                        IndexerExecutionStatus statusInstance3 = SearchServiceClient.ParseIndexerExecutionStatus(((string)statusValue3));
                                        indexerExecutionResultInstance.Status = statusInstance3;
                                    }

                                    JToken errorMessageValue3 = executionHistoryValue["errorMessage"];
                                    if (errorMessageValue3 != null && errorMessageValue3.Type != JTokenType.Null)
                                    {
                                        string errorMessageInstance3 = ((string)errorMessageValue3);
                                        indexerExecutionResultInstance.ErrorMessage = errorMessageInstance3;
                                    }

                                    JToken startTimeValue2 = executionHistoryValue["startTime"];
                                    if (startTimeValue2 != null && startTimeValue2.Type != JTokenType.Null)
                                    {
                                        DateTimeOffset startTimeInstance2 = ((DateTimeOffset)startTimeValue2);
                                        indexerExecutionResultInstance.StartTime = startTimeInstance2;
                                    }

                                    JToken endTimeValue2 = executionHistoryValue["endTime"];
                                    if (endTimeValue2 != null && endTimeValue2.Type != JTokenType.Null)
                                    {
                                        DateTimeOffset endTimeInstance2 = ((DateTimeOffset)endTimeValue2);
                                        indexerExecutionResultInstance.EndTime = endTimeInstance2;
                                    }

                                    JToken errorsArray2 = executionHistoryValue["errors"];
                                    if (errorsArray2 != null && errorsArray2.Type != JTokenType.Null)
                                    {
                                        foreach (JToken errorsValue2 in ((JArray)errorsArray2))
                                        {
                                            ItemError itemErrorInstance2 = new ItemError();
                                            indexerExecutionResultInstance.Errors.Add(itemErrorInstance2);

                                            JToken keyValue2 = errorsValue2["key"];
                                            if (keyValue2 != null && keyValue2.Type != JTokenType.Null)
                                            {
                                                string keyInstance2 = ((string)keyValue2);
                                                itemErrorInstance2.Key = keyInstance2;
                                            }

                                            JToken errorMessageValue4 = errorsValue2["errorMessage"];
                                            if (errorMessageValue4 != null && errorMessageValue4.Type != JTokenType.Null)
                                            {
                                                string errorMessageInstance4 = ((string)errorMessageValue4);
                                                itemErrorInstance2.ErrorMessage = errorMessageInstance4;
                                            }
                                        }
                                    }

                                    JToken itemsProcessedValue2 = executionHistoryValue["itemsProcessed"];
                                    if (itemsProcessedValue2 != null && itemsProcessedValue2.Type != JTokenType.Null)
                                    {
                                        int itemsProcessedInstance2 = ((int)itemsProcessedValue2);
                                        indexerExecutionResultInstance.ItemCount = itemsProcessedInstance2;
                                    }

                                    JToken itemsFailedValue2 = executionHistoryValue["itemsFailed"];
                                    if (itemsFailedValue2 != null && itemsFailedValue2.Type != JTokenType.Null)
                                    {
                                        int itemsFailedInstance2 = ((int)itemsFailedValue2);
                                        indexerExecutionResultInstance.FailedItemCount = itemsFailedInstance2;
                                    }

                                    JToken initialTrackingStateValue2 = executionHistoryValue["initialTrackingState"];
                                    if (initialTrackingStateValue2 != null && initialTrackingStateValue2.Type != JTokenType.Null)
                                    {
                                        string initialTrackingStateInstance2 = ((string)initialTrackingStateValue2);
                                        indexerExecutionResultInstance.InitialTrackingState = initialTrackingStateInstance2;
                                    }

                                    JToken finalTrackingStateValue2 = executionHistoryValue["finalTrackingState"];
                                    if (finalTrackingStateValue2 != null && finalTrackingStateValue2.Type != JTokenType.Null)
                                    {
                                        string finalTrackingStateInstance2 = ((string)finalTrackingStateValue2);
                                        indexerExecutionResultInstance.FinalTrackingState = finalTrackingStateInstance2;
                                    }
                                }
                            }
                        }

                    }
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return result;
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }

        /// <summary>
        /// Lists all datasources available for an Azure Search service.  (see
        /// https://msdn.microsoft.com/library/azure/dn946883.aspx for more
        /// information)
        /// </summary>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// Response from a List Indexers request. If successful, it includes
        /// the full definitions of all indexers.
        /// </returns>
        public async Task<IndexerListResponse> ListAsync(CancellationToken cancellationToken)
        {
            // Validate

            // Tracing
            bool shouldTrace = TracingAdapter.IsEnabled;
            string invocationId = null;
            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
                TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters);
            }

            // Construct URL
            string url = "";
            url = url + "/indexers";
            List<string> queryParameters = new List<string>();
            queryParameters.Add("api-version=2015-02-28");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;
            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;
            try
            {
                httpRequest = new HttpRequestMessage();
                httpRequest.Method = HttpMethod.Get;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json;odata.metadata=none");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    IndexerListResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                        result = new IndexerListResponse();
                        JToken responseDoc = null;
                        if (string.IsNullOrEmpty(responseContent) == false)
                        {
                            responseDoc = JToken.Parse(responseContent);
                        }

                        if (responseDoc != null && responseDoc.Type != JTokenType.Null)
                        {
                            JToken valueArray = responseDoc["value"];
                            if (valueArray != null && valueArray.Type != JTokenType.Null)
                            {
                                foreach (JToken valueValue in ((JArray)valueArray))
                                {
                                    Indexer indexerInstance = new Indexer();
                                    result.Indexers.Add(indexerInstance);

                                    JToken nameValue = valueValue["name"];
                                    if (nameValue != null && nameValue.Type != JTokenType.Null)
                                    {
                                        string nameInstance = ((string)nameValue);
                                        indexerInstance.Name = nameInstance;
                                    }

                                    JToken descriptionValue = valueValue["description"];
                                    if (descriptionValue != null && descriptionValue.Type != JTokenType.Null)
                                    {
                                        string descriptionInstance = ((string)descriptionValue);
                                        indexerInstance.Description = descriptionInstance;
                                    }

                                    JToken dataSourceNameValue = valueValue["dataSourceName"];
                                    if (dataSourceNameValue != null && dataSourceNameValue.Type != JTokenType.Null)
                                    {
                                        string dataSourceNameInstance = ((string)dataSourceNameValue);
                                        indexerInstance.DataSourceName = dataSourceNameInstance;
                                    }

                                    JToken targetIndexNameValue = valueValue["targetIndexName"];
                                    if (targetIndexNameValue != null && targetIndexNameValue.Type != JTokenType.Null)
                                    {
                                        string targetIndexNameInstance = ((string)targetIndexNameValue);
                                        indexerInstance.TargetIndexName = targetIndexNameInstance;
                                    }

                                    JToken scheduleValue = valueValue["schedule"];
                                    if (scheduleValue != null && scheduleValue.Type != JTokenType.Null)
                                    {
                                        IndexingSchedule scheduleInstance = new IndexingSchedule();
                                        indexerInstance.Schedule = scheduleInstance;

                                        JToken intervalValue = scheduleValue["interval"];
                                        if (intervalValue != null && intervalValue.Type != JTokenType.Null)
                                        {
                                            TimeSpan intervalInstance = XmlConvert.ToTimeSpan(((string)intervalValue));
                                            scheduleInstance.Interval = intervalInstance;
                                        }

                                        JToken startTimeValue = scheduleValue["startTime"];
                                        if (startTimeValue != null && startTimeValue.Type != JTokenType.Null)
                                        {
                                            DateTimeOffset startTimeInstance = ((DateTimeOffset)startTimeValue);
                                            scheduleInstance.StartTime = startTimeInstance;
                                        }
                                    }

                                    JToken parametersValue = valueValue["parameters"];
                                    if (parametersValue != null && parametersValue.Type != JTokenType.Null)
                                    {
                                        IndexingParameters parametersInstance = new IndexingParameters();
                                        indexerInstance.Parameters = parametersInstance;

                                        JToken maxFailedItemsValue = parametersValue["maxFailedItems"];
                                        if (maxFailedItemsValue != null && maxFailedItemsValue.Type != JTokenType.Null)
                                        {
                                            int maxFailedItemsInstance = ((int)maxFailedItemsValue);
                                            parametersInstance.MaxFailedItems = maxFailedItemsInstance;
                                        }

                                        JToken maxFailedItemsPerBatchValue = parametersValue["maxFailedItemsPerBatch"];
                                        if (maxFailedItemsPerBatchValue != null && maxFailedItemsPerBatchValue.Type != JTokenType.Null)
                                        {
                                            int maxFailedItemsPerBatchInstance = ((int)maxFailedItemsPerBatchValue);
                                            parametersInstance.MaxFailedItemsPerBatch = maxFailedItemsPerBatchInstance;
                                        }

                                        JToken base64EncodeKeysValue = parametersValue["base64EncodeKeys"];
                                        if (base64EncodeKeysValue != null && base64EncodeKeysValue.Type != JTokenType.Null)
                                        {
                                            bool base64EncodeKeysInstance = ((bool)base64EncodeKeysValue);
                                            parametersInstance.Base64EncodeKeys = base64EncodeKeysInstance;
                                        }
                                    }
                                }
                            }
                        }

                    }
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return result;
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }

        /// <summary>
        /// Resets the change tracking state associated with an Azure Search
        /// indexer.  (see
        /// https://msdn.microsoft.com/library/azure/dn946897.aspx for more
        /// information)
        /// </summary>
        /// <param name='indexerName'>
        /// Required. The name of the indexer to reset.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// A standard service response including an HTTP status code and
        /// request ID.
        /// </returns>
        public async Task<AzureOperationResponse> ResetAsync(string indexerName, CancellationToken cancellationToken)
        {
            // Validate
            if (indexerName == null)
            {
                throw new ArgumentNullException("indexerName");
            }

            // Tracing
            bool shouldTrace = TracingAdapter.IsEnabled;
            string invocationId = null;
            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
                tracingParameters.Add("indexerName", indexerName);
                TracingAdapter.Enter(invocationId, this, "ResetAsync", tracingParameters);
            }

            // Construct URL
            string url = "";
            url = url + "/indexers('";
            url = url + Uri.EscapeDataString(indexerName);
            url = url + "')/search.reset";
            List<string> queryParameters = new List<string>();
            queryParameters.Add("api-version=2015-02-28");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;
            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;
            try
            {
                httpRequest = new HttpRequestMessage();
                httpRequest.Method = HttpMethod.Post;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json;odata.metadata=none");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.NoContent)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    AzureOperationResponse result = null;
                    // Deserialize Response
                    result = new AzureOperationResponse();
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return result;
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }

        /// <summary>
        /// Runs an Azure Search indexer on-demand.  (see
        /// https://msdn.microsoft.com/library/azure/dn946885.aspx for more
        /// information)
        /// </summary>
        /// <param name='indexerName'>
        /// Required. The name of the indexer to run.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// A standard service response including an HTTP status code and
        /// request ID.
        /// </returns>
        public async Task<AzureOperationResponse> RunAsync(string indexerName, CancellationToken cancellationToken)
        {
            // Validate
            if (indexerName == null)
            {
                throw new ArgumentNullException("indexerName");
            }

            // Tracing
            bool shouldTrace = TracingAdapter.IsEnabled;
            string invocationId = null;
            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
                tracingParameters.Add("indexerName", indexerName);
                TracingAdapter.Enter(invocationId, this, "RunAsync", tracingParameters);
            }

            // Construct URL
            string url = "";
            url = url + "/indexers('";
            url = url + Uri.EscapeDataString(indexerName);
            url = url + "')/search.run";
            List<string> queryParameters = new List<string>();
            queryParameters.Add("api-version=2015-02-28");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;
            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;
            try
            {
                httpRequest = new HttpRequestMessage();
                httpRequest.Method = HttpMethod.Post;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json;odata.metadata=none");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.Accepted)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    AzureOperationResponse result = null;
                    // Deserialize Response
                    result = new AzureOperationResponse();
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return result;
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }
    }
}


text:
<?php
# Copyright (c) 2000-2002 dev/consulting GmbH
# Copyright (c) 2011 Sven Michael Klose <pixel@copei.de>
#
# Licensed under the MIT, BSD and GPL licenses.

/**
 * Context object
 *
 * @package User interface
 */
class _admin_panel_view {
    /**
     * Context cursor.
     * @var object cursor
     */
    var $cursor;

    /**
     * True: Don't generate a form in next open_source.
     * @var boolean
     */
    var $no_update;

    /**
     * Optional default form function.
     * @var object event
     */
    var $defaultfunc;

    function _admin_panel_view (&$cursor, $no_update, $defaultfunc)
    {
        $this->cursor =& $cursor;
        $this->no_update = $no_update;
        $this->defaultfunc = $defaultfunc;
    }
}
?>

redpajama_set_name: RedPajamaGithub


text:
package de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.classes;

import de.uni_stuttgart.vis.vowl.owl2vowl.constants.Node_Types;
import de.uni_stuttgart.vis.vowl.owl2vowl.export.JsonGeneratorVisitor;

public class OwlComplementOf extends SpecialClass {

	public OwlComplementOf() {
		super();
		setType(Node_Types.TYPE_COMPLEMENT);
	}

	@Override
	public void accept(JsonGeneratorVisitor visitor) {
		super.accept(visitor);
		visitor.visit(this);
	}
}


text:
#if HAVE_CONFIG_H
#include <config.h>
#endif

#include "SocketWrapper.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#include <poll.h>
#include <errno.h>
#include <syslog.h>
#include <sys/file.h>

using namespace nl;

SocketWrapper::~SocketWrapper()
{
}

bool
SocketWrapper::can_read(void)const
{
	return false;
}

bool
SocketWrapper::can_write(void)const
{
	return false;
}

int
SocketWrapper::set_log_level(int log_level)
{
	errno = ENOTSUP;
	return -ENOTSUP;
}

int
SocketWrapper::get_read_fd(void)const
{
	return -1;
}

int
SocketWrapper::get_write_fd(void)const
{
	return -1;
}

cms_t
SocketWrapper::get_ms_to_next_event(void)const
{
	return CMS_DISTANT_FUTURE;
}

void
SocketWrapper::send_break(void)
{
}

off_t
SocketWrapper::lseek(off_t offset, int whence)
{
	errno = ENOTSUP;
	return -ENOTSUP;
}

void
SocketWrapper::reset(void)
{
}

int
SocketWrapper::hibernate(void)
{
	errno = ENOTSUP;
	return -ENOTSUP;
}

bool
SocketWrapper::did_reset(void)
{
	return false;
}

int
SocketWrapper::update_fd_set(fd_set *read_fd_set, fd_set *write_fd_set, fd_set *error_fd_set, int *max_fd, cms_t *timeout)
{
	if (timeout != NULL) {
		*timeout = std::min(*timeout, get_ms_to_next_event());
	}
	return 0;
}


text:
module Aws.Sqs.Commands.Message where

import           Aws.Core
import           Aws.Sqs.Core
import           Control.Applicative
import           Control.Monad.Trans.Resource (MonadThrow)
import           Data.Maybe
import           Text.XML.Cursor       (($/), ($//), (&/), (&|))
import qualified Data.ByteString.Char8 as B
import qualified Data.Text             as T
import qualified Data.Text.Encoding    as TE
import qualified Text.XML.Cursor       as Cu

data SendMessage = SendMessage{
  smMessage :: T.Text,
  smQueueName :: QueueName
}deriving (Show)

data SendMessageResponse = SendMessageResponse{
  smrMD5OfMessageBody :: T.Text,
  smrMessageId :: MessageId
} deriving (Show)

instance ResponseConsumer r SendMessageResponse where
    type ResponseMetadata SendMessageResponse = SqsMetadata
    responseConsumer _ = sqsXmlResponseConsumer parse
      where
        parse el = do
          md5 <- force "Missing MD5 Signature" $ el $// Cu.laxElement "MD5OfMessageBody" &/ Cu.content
          mid <- force "Missing Message Id" $ el $// Cu.laxElement "MessageId" &/ Cu.content
          return SendMessageResponse { smrMD5OfMessageBody = md5, smrMessageId = MessageId mid }

-- | ServiceConfiguration: 'SqsConfiguration'
instance SignQuery SendMessage  where
    type ServiceConfiguration SendMessage  = SqsConfiguration
    signQuery SendMessage {..} = sqsSignQuery SqsQuery {
                                             sqsQueueName = Just smQueueName,
                                             sqsQuery = [("Action", Just "SendMessage"),
                                                        ("MessageBody", Just $ TE.encodeUtf8 smMessage )]}

instance Transaction SendMessage SendMessageResponse

instance AsMemoryResponse SendMessageResponse where
    type MemoryResponse SendMessageResponse = SendMessageResponse
    loadToMemory = return

data DeleteMessage = DeleteMessage{
  dmReceiptHandle :: ReceiptHandle,
  dmQueueName :: QueueName
}deriving (Show)

data DeleteMessageResponse = DeleteMessageResponse{
} deriving (Show)

instance ResponseConsumer r DeleteMessageResponse where
    type ResponseMetadata DeleteMessageResponse = SqsMetadata
    responseConsumer _ = sqsXmlResponseConsumer parse
      where
        parse _ = do return DeleteMessageResponse {}

-- | ServiceConfiguration: 'SqsConfiguration'
instance SignQuery DeleteMessage  where
    type ServiceConfiguration DeleteMessage  = SqsConfiguration
    signQuery DeleteMessage {..} = sqsSignQuery SqsQuery {
                                             sqsQueueName = Just dmQueueName,
                                             sqsQuery = [("Action", Just "DeleteMessage"),
                                                        ("ReceiptHandle", Just $ TE.encodeUtf8 $ printReceiptHandle dmReceiptHandle )]}

instance Transaction DeleteMessage DeleteMessageResponse

instance AsMemoryResponse DeleteMessageResponse where
    type MemoryResponse DeleteMessageResponse = DeleteMessageResponse
    loadToMemory = return

data ReceiveMessage
    = ReceiveMessage {
        rmVisibilityTimeout :: Maybe Int
      , rmAttributes :: [MessageAttribute]
      , rmMaxNumberOfMessages :: Maybe Int
      , rmQueueName :: QueueName
      }
    deriving (Show)

data Message
    = Message {
        mMessageId :: T.Text
      , mReceiptHandle :: ReceiptHandle
      , mMD5OfBody :: T.Text
      , mBody :: T.Text
      , mAttributes :: [(MessageAttribute,T.Text)]
      }
    deriving(Show)

data ReceiveMessageResponse
    = ReceiveMessageResponse {
        rmrMessages :: [Message]
      }
    deriving (Show)

readMessageAttribute :: MonadThrow m => Cu.Cursor -> m (MessageAttribute,T.Text)
readMessageAttribute cursor = do
  name <- force "Missing Name" $ cursor $/ Cu.laxElement "Name" &/ Cu.content
  value <- force "Missing Value" $ cursor $/ Cu.laxElement "Value" &/ Cu.content
  parsedName <- parseMessageAttribute name
  return (parsedName, value)

readMessage :: Cu.Cursor -> [Message]
readMessage cursor = do
  mid :: T.Text <- force "Missing Message Id" $ cursor $// Cu.laxElement "MessageId" &/ Cu.content
  rh <- force "Missing Reciept Handle" $ cursor $// Cu.laxElement "ReceiptHandle" &/ Cu.content
  md5 <- force "Missing MD5 Signature" $ cursor $// Cu.laxElement "MD5OfBody" &/ Cu.content
  body <- force "Missing Body" $ cursor $// Cu.laxElement "Body" &/ Cu.content
  let attributes :: [(MessageAttribute, T.Text)] = concat $ cursor $// Cu.laxElement "Attribute" &| readMessageAttribute

  return Message{ mMessageId = mid, mReceiptHandle = ReceiptHandle rh, mMD5OfBody = md5, mBody = body, mAttributes = attributes}

formatMAttributes :: [MessageAttribute] -> [(B.ByteString, Maybe B.ByteString)]
formatMAttributes attrs =
  case length attrs of
    0 -> []
    1 -> [("AttributeName", Just $ B.pack $ show $ attrs !! 0)]
    _ -> zipWith (\ x y -> ((B.concat ["AttributeName.", B.pack $ show $ y]), Just $ TE.encodeUtf8 $ printMessageAttribute x) ) attrs [1 :: Integer ..]

instance ResponseConsumer r ReceiveMessageResponse where
    type ResponseMetadata ReceiveMessageResponse = SqsMetadata
    responseConsumer _ = sqsXmlResponseConsumer parse
      where
        parse el = do
          let messages = concat $ el $// Cu.laxElement "Message" &| readMessage
          return ReceiveMessageResponse{ rmrMessages = messages }

-- | ServiceConfiguration: 'SqsConfiguration'
instance SignQuery ReceiveMessage  where
    type ServiceConfiguration ReceiveMessage  = SqsConfiguration
    signQuery ReceiveMessage {..} = sqsSignQuery SqsQuery {
                                             sqsQueueName = Just rmQueueName,
                                             sqsQuery = [("Action", Just "ReceiveMessage")] ++
                                                         catMaybes[("VisibilityTimeout",) <$> case rmVisibilityTimeout of
                                                                                Just x -> Just $ Just $ B.pack $ show x
                                                                                Nothing -> Nothing,
                                                                   ("MaxNumberOfMessages",) <$> case rmMaxNumberOfMessages of
                                                                                Just x -> Just $ Just $ B.pack $ show x
                                                                                Nothing -> Nothing] ++ formatMAttributes rmAttributes}

instance Transaction ReceiveMessage ReceiveMessageResponse

instance AsMemoryResponse ReceiveMessageResponse where
    type MemoryResponse ReceiveMessageResponse = ReceiveMessageResponse
    loadToMemory = return

data ChangeMessageVisibility = ChangeMessageVisibility {
  cmvReceiptHandle :: ReceiptHandle,
  cmvVisibilityTimeout :: Int,
  cmvQueueName :: QueueName
}deriving (Show)

data ChangeMessageVisibilityResponse = ChangeMessageVisibilityResponse{
} deriving (Show)

instance ResponseConsumer r ChangeMessageVisibilityResponse where
    type ResponseMetadata ChangeMessageVisibilityResponse = SqsMetadata
    responseConsumer _ = sqsXmlResponseConsumer parse
      where
        parse _ = do return ChangeMessageVisibilityResponse{}

-- | ServiceConfiguration: 'SqsConfiguration'
instance SignQuery ChangeMessageVisibility  where
    type ServiceConfiguration ChangeMessageVisibility  = SqsConfiguration
    signQuery ChangeMessageVisibility {..} = sqsSignQuery SqsQuery {
                                             sqsQueueName = Just cmvQueueName,
                                             sqsQuery = [("Action", Just "ChangeMessageVisibility"),
                                                         ("ReceiptHandle", Just $ TE.encodeUtf8 $ printReceiptHandle cmvReceiptHandle),
                                                         ("VisibilityTimeout", Just $ B.pack $ show cmvVisibilityTimeout)]}

instance Transaction ChangeMessageVisibility ChangeMessageVisibilityResponse

instance AsMemoryResponse ChangeMessageVisibilityResponse where
    type MemoryResponse ChangeMessageVisibilityResponse = ChangeMessageVisibilityResponse
    loadToMemory = return


text:
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE590_Free_Memory_Not_on_Heap__free_int64_t_alloca_64b.c
Label Definition File: CWE590_Free_Memory_Not_on_Heap__free.label.xml
Template File: sources-sink-64b.tmpl.c
*/
/*
 * @description
 * CWE: 590 Free Memory Not on Heap
 * BadSource: alloca Data buffer is allocated on the stack with alloca()
 * GoodSource: Allocate memory on the heap
 * Sinks:
 *    BadSink : Print then free data
 * Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files
 *
 * */

#include "std_testcase.h"

#include <wchar.h>

#ifndef OMITBAD

void CWE590_Free_Memory_Not_on_Heap__free_int64_t_alloca_64b_badSink(void * dataVoidPtr)
{
    /* cast void pointer to a pointer of the appropriate type */
    int64_t * * dataPtr = (int64_t * *)dataVoidPtr;
    /* dereference dataPtr into data */
    int64_t * data = (*dataPtr);
    printLongLongLine(data[0]);
    /* POTENTIAL FLAW: Possibly deallocating memory allocated on the stack */
    free(data);
}

#endif /* OMITBAD */

#ifndef OMITGOOD

/* goodG2B uses the GoodSource with the BadSink */
void CWE590_Free_Memory_Not_on_Heap__free_int64_t_alloca_64b_goodG2BSink(void * dataVoidPtr)
{
    /* cast void pointer to a pointer of the appropriate type */
    int64_t * * dataPtr = (int64_t * *)dataVoidPtr;
    /* dereference dataPtr into data */
    int64_t * data = (*dataPtr);
    printLongLongLine(data[0]);
    /* POTENTIAL FLAW: Possibly deallocating memory allocated on the stack */
    free(data);
}

#endif /* OMITGOOD */


text:
//===-----------------------------------------------------------------------==//
//
// Lockpwn - blazing fast symbolic analysis for concurrent Boogie programs
//
// Copyright (c) 2015 Pantazis Deligiannis (pdeligia@me.com)
//
// This file is distributed under the MIT License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

using System;

namespace Lockpwn
{
  internal enum Outcome
  {
    Done = 0,
    FatalError = 1,
    ParsingError = 2,
    InstrumentationError = 3,
    LocksetAnalysisError = 4
  }
}


text:
if (typeof Cc === "undefined")
  Cc = Components.classes;
if (typeof Ci === "undefined")
  Ci = Components.interfaces;

function destroy_transient_docshell() {
  var docshell = Cc["@mozilla.org/docshell;1"].createInstance(Ci.nsIDocShell);
  docshell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
  do_test_pending();
  do_timeout(0, Components.utils.forceGC);
}

function run_test() {
  var obs = {
    observe: function(aSubject, aTopic, aData) {
      do_check_eq(aTopic, "last-pb-context-exited");
      do_test_finished();
    }
  };
  var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
  os.addObserver(obs, "last-pb-context-exited", false);
  destroy_transient_docshell();
}


text:
package makevalid

import (
	pkg "github.com/go-spatial/geom/cmp"
)

var cmp = pkg.HiCMP


text:
package sxkeji.net.dailydiary.beans;

import java.io.Serializable;

/**
 * 登录引导的实体类
 * Created by zhangshixin on 4/15/2016.
 */
public class LoginGuideBean implements Serializable {
    private int imgId;
    private String title;

    public int getImgId() {
        return imgId;
    }

    public void setImgId(int imgId) {
        this.imgId = imgId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}