/// <summary>
        /// Configures a suggester for a domain. A suggester enables you to display possible matches
        /// before users finish typing their queries. When you configure a suggester, you must
        /// specify the name of the text field you want to search for possible matches and a unique
        /// name for the suggester. For more information, see <a href="http://docs.aws.amazon.com/cloudsearch/latest/developerguide/getting-suggestions.html"
        /// target="_blank">Getting Search Suggestions</a> in the <i>Amazon CloudSearch Developer
        /// Guide</i>.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the DefineSuggester service method.</param>
        /// 
        /// <returns>The response from the DefineSuggester service method, as returned by CloudSearch.</returns>
        /// <exception cref="Amazon.CloudSearch.Model.BaseException">
        /// An error occurred while processing the request.
        /// </exception>
        /// <exception cref="Amazon.CloudSearch.Model.InternalException">
        /// An internal error occurred while processing the request. If this problem persists,
        /// report an issue from the <a href="http://status.aws.amazon.com/" target="_blank">Service
        /// Health Dashboard</a>.
        /// </exception>
        /// <exception cref="Amazon.CloudSearch.Model.InvalidTypeException">
        /// The request was rejected because it specified an invalid type definition.
        /// </exception>
        /// <exception cref="Amazon.CloudSearch.Model.LimitExceededException">
        /// The request was rejected because a resource limit has already been met.
        /// </exception>
        /// <exception cref="Amazon.CloudSearch.Model.ResourceNotFoundException">
        /// The request was rejected because it attempted to reference a resource that does not
        /// exist.
        /// </exception>
        public DefineSuggesterResponse DefineSuggester(DefineSuggesterRequest request)
        {
            var marshaller = new DefineSuggesterRequestMarshaller();
            var unmarshaller = DefineSuggesterResponseUnmarshaller.Instance;

            return Invoke<DefineSuggesterRequest,DefineSuggesterResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DefineSuggester operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DefineSuggester operation on AmazonCloudSearchClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDefineSuggester
        ///         operation.</returns>
        public IAsyncResult BeginDefineSuggester(DefineSuggesterRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DefineSuggesterRequestMarshaller();
            var unmarshaller = DefineSuggesterResponseUnmarshaller.Instance;

            return BeginInvoke<DefineSuggesterRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the DefineSuggester operation.
 /// <seealso cref="Amazon.CloudSearch.IAmazonCloudSearch.DefineSuggester"/>
 /// </summary>
 /// 
 /// <param name="defineSuggesterRequest">Container for the necessary parameters to execute the DefineSuggester operation on
 ///          AmazonCloudSearch.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// 
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDefineSuggester
 ///         operation.</returns>
 public IAsyncResult BeginDefineSuggester(DefineSuggesterRequest defineSuggesterRequest, AsyncCallback callback, object state)
 {
     return invokeDefineSuggester(defineSuggesterRequest, callback, state, false);
 }
 IAsyncResult invokeDefineSuggester(DefineSuggesterRequest defineSuggesterRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new DefineSuggesterRequestMarshaller().Marshall(defineSuggesterRequest);
     var unmarshaller = DefineSuggesterResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
        public void CreateIndex(string name, IEnumerable<IFieldDefinition> fieldDefinitions)
        {
            //You must add here your accessKey and SecretAccessKey. See here how to get them: http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html
            using (IAmazonCloudSearch cloudSearchClient = AWSClientFactory.CreateAmazonCloudSearchClient(AmazonSearchService.AwsAccessKey, AmazonSearchService.AwsSecretAccessKey, RegionEndpoint.EUWest1))
            {
                try
                {
                    CreateDomainRequest domainRequest = new CreateDomainRequest();
                    domainRequest.DomainName = name;
                    cloudSearchClient.CreateDomain(domainRequest);

                    if (fieldDefinitions == null)
                        throw new ArgumentNullException("fieldDefinitions");

                    foreach (var fieldDefinition in fieldDefinitions)
                    {
                        DefineIndexFieldRequest request = new DefineIndexFieldRequest();
                        request.DomainName = name;
                        request.IndexField = new IndexField();
                        request.IndexField.IndexFieldName = fieldDefinition.Name.ToUpperInvariant();
                        if (fieldDefinition.Type == null || fieldDefinition.Type == typeof(string))
                            request.IndexField.IndexFieldType = IndexFieldType.Text;
                        if (fieldDefinition.Type == typeof(string[]))
                            request.IndexField.IndexFieldType = IndexFieldType.TextArray;
                        if (fieldDefinition.Type == typeof(int))
                            request.IndexField.IndexFieldType = IndexFieldType.Int;
                        if (fieldDefinition.Type == typeof(DateTime))
                            request.IndexField.IndexFieldType = IndexFieldType.Date;
                        cloudSearchClient.DefineIndexField(request);
                    }

                    SearchResults searchResults = new SearchResults();
                    foreach (var field in searchResults.HighlightedFields)
                    {
                        Suggester suggester = new Suggester();
                        DocumentSuggesterOptions suggesterOptions = new DocumentSuggesterOptions();
                        suggesterOptions.FuzzyMatching = SuggesterFuzzyMatching.None;
                        suggesterOptions.SourceField = field.ToUpperInvariant();
                        suggester.DocumentSuggesterOptions = suggesterOptions;
                        suggester.SuggesterName = field.ToUpperInvariant() + "_suggester";
                        DefineSuggesterRequest defineRequest = new DefineSuggesterRequest();
                        defineRequest.DomainName = name;
                        defineRequest.Suggester = suggester;
                        cloudSearchClient.DefineSuggester(defineRequest);
                    }

                    searchResults.Dispose();

                    IndexDocumentsRequest documentRequest = new IndexDocumentsRequest();
                    documentRequest.DomainName = name;
                    cloudSearchClient.IndexDocuments(documentRequest);
                }
                catch (BaseException ex)
                {
                    Log.Write(ex.InnerException.Message);
                }
                catch (LimitExceededException ex)
                {
                    Log.Write(ex.InnerException.Message);
                }
                catch (InternalException ex)
                {
                    Log.Write(ex.InnerException.Message);
                }
            }
        }
 /// <summary>
 /// <para>Configures a suggester for a domain. A suggester enables you to display possible matches before users finish typing their queries.
 /// When you configure a suggester, you must specify the name of the text field you want to search for possible matches and a unique name for
 /// the suggester. For more information, see <a
 /// href="http://docs.aws.amazon.com/cloudsearch/latest/developerguide/getting-search-suggestions.html" >Getting Search Suggestions</a> in the
 /// <i>Amazon CloudSearch Developer Guide</i> .</para>
 /// </summary>
 /// 
 /// <param name="defineSuggesterRequest">Container for the necessary parameters to execute the DefineSuggester service method on
 ///          AmazonCloudSearch.</param>
 /// 
 /// <returns>The response from the DefineSuggester service method, as returned by AmazonCloudSearch.</returns>
 /// 
 /// <exception cref="InternalException"/>
 /// <exception cref="InvalidTypeException"/>
 /// <exception cref="ResourceNotFoundException"/>
 /// <exception cref="LimitExceededException"/>
 /// <exception cref="BaseException"/>
 public DefineSuggesterResponse DefineSuggester(DefineSuggesterRequest defineSuggesterRequest)
 {
     IAsyncResult asyncResult = invokeDefineSuggester(defineSuggesterRequest, null, null, true);
     return EndDefineSuggester(asyncResult);
 }
        /// <summary>
        /// <para>Configures a suggester for a domain. A suggester enables you to display possible matches before users finish typing their queries.
        /// When you configure a suggester, you must specify the name of the text field you want to search for possible matches and a unique name for
        /// the suggester. For more information, see <a href="http://docs.aws.amazon.com/cloudsearch/latest/developerguide/getting-search-suggestions.html">Getting Search Suggestions</a> in the
        /// <i>Amazon CloudSearch Developer Guide</i> .</para>
        /// </summary>
        /// 
        /// <param name="defineSuggesterRequest">Container for the necessary parameters to execute the DefineSuggester service method on
        /// AmazonCloudSearch.</param>
        /// 
        /// <returns>The response from the DefineSuggester service method, as returned by AmazonCloudSearch.</returns>
        /// 
        /// <exception cref="T:Amazon.CloudSearch.Model.InternalException" />
        /// <exception cref="T:Amazon.CloudSearch.Model.InvalidTypeException" />
        /// <exception cref="T:Amazon.CloudSearch.Model.ResourceNotFoundException" />
        /// <exception cref="T:Amazon.CloudSearch.Model.LimitExceededException" />
        /// <exception cref="T:Amazon.CloudSearch.Model.BaseException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<DefineSuggesterResponse> DefineSuggesterAsync(DefineSuggesterRequest defineSuggesterRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DefineSuggesterRequestMarshaller();
            var unmarshaller = DefineSuggesterResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, DefineSuggesterRequest, DefineSuggesterResponse>(defineSuggesterRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
		internal DefineSuggesterResponse DefineSuggester(DefineSuggesterRequest request)
        {
            var task = DefineSuggesterAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DefineSuggester operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DefineSuggester operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<DefineSuggesterResponse> DefineSuggesterAsync(DefineSuggesterRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DefineSuggesterRequestMarshaller();
            var unmarshaller = DefineSuggesterResponseUnmarshaller.Instance;

            return InvokeAsync<DefineSuggesterRequest,DefineSuggesterResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
 private Amazon.CloudSearch.Model.DefineSuggesterResponse CallAWSServiceOperation(IAmazonCloudSearch client, Amazon.CloudSearch.Model.DefineSuggesterRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudSearch", "DefineSuggester");
     try
     {
         #if DESKTOP
         return(client.DefineSuggester(request));
         #elif CORECLR
         return(client.DefineSuggesterAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.CloudSearch.Model.DefineSuggesterRequest();

            if (cmdletContext.DomainName != null)
            {
                request.DomainName = cmdletContext.DomainName;
            }

            // populate Suggester
            var requestSuggesterIsNull = true;

            request.Suggester = new Amazon.CloudSearch.Model.Suggester();
            System.String requestSuggester_suggester_SuggesterName = null;
            if (cmdletContext.Suggester_SuggesterName != null)
            {
                requestSuggester_suggester_SuggesterName = cmdletContext.Suggester_SuggesterName;
            }
            if (requestSuggester_suggester_SuggesterName != null)
            {
                request.Suggester.SuggesterName = requestSuggester_suggester_SuggesterName;
                requestSuggesterIsNull          = false;
            }
            Amazon.CloudSearch.Model.DocumentSuggesterOptions requestSuggester_suggester_DocumentSuggesterOptions = null;

            // populate DocumentSuggesterOptions
            var requestSuggester_suggester_DocumentSuggesterOptionsIsNull = true;

            requestSuggester_suggester_DocumentSuggesterOptions = new Amazon.CloudSearch.Model.DocumentSuggesterOptions();
            Amazon.CloudSearch.SuggesterFuzzyMatching requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_FuzzyMatching = null;
            if (cmdletContext.DocumentSuggesterOptions_FuzzyMatching != null)
            {
                requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_FuzzyMatching = cmdletContext.DocumentSuggesterOptions_FuzzyMatching;
            }
            if (requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_FuzzyMatching != null)
            {
                requestSuggester_suggester_DocumentSuggesterOptions.FuzzyMatching = requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_FuzzyMatching;
                requestSuggester_suggester_DocumentSuggesterOptionsIsNull         = false;
            }
            System.String requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_SortExpression = null;
            if (cmdletContext.DocumentSuggesterOptions_SortExpression != null)
            {
                requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_SortExpression = cmdletContext.DocumentSuggesterOptions_SortExpression;
            }
            if (requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_SortExpression != null)
            {
                requestSuggester_suggester_DocumentSuggesterOptions.SortExpression = requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_SortExpression;
                requestSuggester_suggester_DocumentSuggesterOptionsIsNull          = false;
            }
            System.String requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_SourceField = null;
            if (cmdletContext.DocumentSuggesterOptions_SourceField != null)
            {
                requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_SourceField = cmdletContext.DocumentSuggesterOptions_SourceField;
            }
            if (requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_SourceField != null)
            {
                requestSuggester_suggester_DocumentSuggesterOptions.SourceField = requestSuggester_suggester_DocumentSuggesterOptions_documentSuggesterOptions_SourceField;
                requestSuggester_suggester_DocumentSuggesterOptionsIsNull       = false;
            }
            // determine if requestSuggester_suggester_DocumentSuggesterOptions should be set to null
            if (requestSuggester_suggester_DocumentSuggesterOptionsIsNull)
            {
                requestSuggester_suggester_DocumentSuggesterOptions = null;
            }
            if (requestSuggester_suggester_DocumentSuggesterOptions != null)
            {
                request.Suggester.DocumentSuggesterOptions = requestSuggester_suggester_DocumentSuggesterOptions;
                requestSuggesterIsNull = false;
            }
            // determine if request.Suggester should be set to null
            if (requestSuggesterIsNull)
            {
                request.Suggester = null;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }