/// <summary> /// Creates a new Azure Search indexer or updates an indexer if it already /// exists. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Create-Indexer" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='indexer'> /// The definition of the indexer to create or update. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation. /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation. /// </param> /// <returns> /// The indexer that was created or updated. /// </returns> public static Indexer CreateOrUpdate(this IIndexersOperations operations, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition)) { return(operations.CreateOrUpdateAsync(indexer, searchRequestOptions, accessCondition).GetAwaiter().GetResult()); }
/// <summary> /// Deletes an Azure Search datasource. /// <see href="https://msdn.microsoft.com/library/azure/dn946881.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='dataSourceName'> /// The name of the datasource to delete. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task DeleteAsync(this IDataSourcesOperations operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition), CancellationToken cancellationToken = default(CancellationToken)) { await operations.DeleteWithHttpMessagesAsync(dataSourceName, searchRequestOptions, accessCondition, null, cancellationToken).ConfigureAwait(false); }
/// <summary> /// Creates a new Azure Search datasource. /// <see href="https://msdn.microsoft.com/library/azure/dn946876.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='dataSource'> /// The definition of the datasource to create. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DataSource> CreateAsync(this IDataSourcesOperations operations, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateWithHttpMessagesAsync(dataSource, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Lists all datasources available for a search service. /// <see href="https://docs.microsoft.com/rest/api/searchservice/List-Data-Sources" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> public static DataSourceListResult List(this IDataSourcesOperations operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) { return(operations.ListAsync(searchRequestOptions).GetAwaiter().GetResult()); }
/// <summary> /// Creates a new datasource or updates a datasource if it already exists. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Update-Data-Source" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='dataSourceName'> /// The name of the datasource to create or update. /// </param> /// <param name='dataSource'> /// The definition of the datasource to create or update. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation /// </param> public static DataSource CreateOrUpdate(this IDataSourcesOperations operations, string dataSourceName, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition)) { return(operations.CreateOrUpdateAsync(dataSourceName, dataSource, searchRequestOptions, accessCondition).GetAwaiter().GetResult()); }
/// <summary> /// Lists the names of all indexes available for a search /// service. Use this instead of List() when you only need index /// names. It will save bandwidth and resource utilization, especially /// if your Search Service has many indexes. /// <see href="https://docs.microsoft.com/rest/api/searchservice/List-Indexes"/> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation. /// </param> /// <returns> /// The list of all index names for the search service. /// </returns> public static IList <string> ListNames( this IIndexesOperations operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) { return(GetIndexNames(operations.List(select: "name", searchRequestOptions: searchRequestOptions))); }
/// <summary> /// Creates a new search index or updates an index if it already exists. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Update-Index" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='index'> /// The definition of the index to create or update. /// </param> /// <param name='allowIndexDowntime'> /// Allows new analyzers, tokenizers, token filters, or char filters /// to be added to an index by taking the index offline for at least /// a few seconds. This temporarily causes indexing and query /// requests to fail. Performance and write availability of the index /// can be impaired for several minutes after the index is updated, /// or longer for very large indexes. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation. /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <returns> /// The index that was created or updated. /// </returns> public static async Task <Index> CreateOrUpdateAsync(this IIndexesOperations operations, Index index, bool?allowIndexDowntime = default(bool?), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(index, allowIndexDowntime, searchRequestOptions, accessCondition, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates a new indexer or updates an indexer if it already /// exists. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Create-Indexer" /> /// </summary> /// <param name='indexer'> /// The definition of the indexer to create or update. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation. /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation. /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="CloudException"> /// Thrown when the operation returned an invalid status code. /// </exception> /// <exception cref="Microsoft.Rest.SerializationException"> /// Thrown when unable to deserialize the response. /// </exception> /// <exception cref="Microsoft.Rest.ValidationException"> /// Thrown when a required parameter is null. /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null. /// </exception> /// <returns> /// A response object containing the response body and response headers. /// </returns> public Task <AzureOperationResponse <Indexer> > CreateOrUpdateWithHttpMessagesAsync(Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { return(CreateOrUpdateWithHttpMessagesAsync(indexer?.Name, indexer, searchRequestOptions, accessCondition, customHeaders, cancellationToken)); }
/// <summary> /// Queries the number of documents in the Azure Search index. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Count-Documents" /> /// </summary> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="CloudException"> /// Thrown when the operation returned an invalid status code /// </exception> /// <exception cref="SerializationException"> /// Thrown when unable to deserialize the response /// </exception> /// <exception cref="ValidationException"> /// Thrown when a required parameter is null /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <AzureOperationResponse <long?> > CountWithHttpMessagesAsync(SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SearchServiceName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); } if (Client.SearchDnsSuffix == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); } if (Client.IndexName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } System.Guid?clientRequestId = default(System.Guid?); if (searchRequestOptions != null) { clientRequestId = searchRequestOptions.ClientRequestId; } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("clientRequestId", clientRequestId); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Count", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri; var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs/$count"; _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); _url = _url.Replace("{indexName}", Client.IndexName); List <string> _queryParameters = new List <string>(); if (Client.ApiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) { _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); } if (Client.AcceptLanguage != null) { if (_httpRequest.Headers.Contains("accept-language")) { _httpRequest.Headers.Remove("accept-language"); } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } if (clientRequestId != null) { if (_httpRequest.Headers.Contains("client-request-id")) { _httpRequest.Headers.Remove("client-request-id"); } _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); } if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; // Set Credentials if (Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); } // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 200) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject <CloudError>(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex = new CloudException(_errorBody.Message); ex.Body = _errorBody; } } catch (JsonException) { // Ignore the exception } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_httpResponse.Headers.Contains("request-id")) { ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); } if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new AzureOperationResponse <long?>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); } // Deserialize Response if ((int)_statusCode == 200) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <long?>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
/// <summary> /// Creates a new skillset or updates a skillset if it /// already exists. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='skillset'> /// The definition of the skillset to create or update. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation /// </param> public static Skillset CreateOrUpdate(this ISkillsetsOperations operations, Skillset skillset, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition)) { return(operations.CreateOrUpdateAsync(skillset, searchRequestOptions, accessCondition).GetAwaiter().GetResult()); }
/// <summary> /// Creates a new skillset or updates a skillset if it /// already exists. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='skillset'> /// The definition of the skillset to create or update. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <Skillset> CreateOrUpdateAsync(this ISkillsetsOperations operations, Skillset skillset, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(skillset, searchRequestOptions, accessCondition, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Returns statistics for the given index, including a document count and /// storage usage. /// <see href="https://msdn.microsoft.com/library/azure/dn798942.aspx" /> /// </summary> /// <param name='indexName'> /// The name of the index for which to retrieve statistics. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="HttpOperationException"> /// Thrown when the operation returned an invalid status code /// </exception> /// <exception cref="SerializationException"> /// Thrown when unable to deserialize the response /// </exception> /// <exception cref="ValidationException"> /// Thrown when a required parameter is null /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <HttpOperationResponse <IndexGetStatisticsResult> > GetStatisticsWithHttpMessagesAsync(string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (indexName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "indexName"); } string apiVersion = "2015-02-28"; System.Guid?clientRequestId = default(System.Guid?); if (searchRequestOptions != null) { clientRequestId = searchRequestOptions.ClientRequestId; } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("indexName", indexName); tracingParameters.Add("apiVersion", apiVersion); tracingParameters.Add("clientRequestId", clientRequestId); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "GetStatistics", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "indexes('{indexName}')/search.stats").ToString(); _url = _url.Replace("{indexName}", System.Uri.EscapeDataString(indexName)); List <string> _queryParameters = new List <string>(); if (apiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); } if (_queryParameters.Count > 0) { _url += "?" + string.Join("&", _queryParameters); } // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (clientRequestId != null) { if (_httpRequest.Headers.Contains("client-request-id")) { _httpRequest.Headers.Remove("client-request-id"); } _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(clientRequestId, Client.SerializationSettings).Trim('"')); } if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 200) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); if (_httpResponse.Content != null) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); } else { _responseContent = string.Empty; } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new HttpOperationResponse <IndexGetStatisticsResult>(); _result.Request = _httpRequest; _result.Response = _httpResponse; // Deserialize Response if ((int)_statusCode == 200) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject <IndexGetStatisticsResult>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
/// <summary> /// Deletes an Azure Search datasource. /// <see href="https://msdn.microsoft.com/library/azure/dn946881.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='dataSourceName'> /// The name of the datasource to delete. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task DeleteAsync(this IDataSources operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) { (await operations.DeleteWithHttpMessagesAsync(dataSourceName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <summary> /// Lists all datasources available for an Azure Search service. /// <see href="https://msdn.microsoft.com/library/azure/dn946878.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DataSourceListResult> ListAsync(this IDataSources operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListWithHttpMessagesAsync(searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
private Index CreateOrUpdateIndex(Index index, SearchRequestOptions options, AccessCondition condition) => Data.GetSearchServiceClient().Indexes.CreateOrUpdate(index, null, options, condition);
/// <summary> /// Lists all indexers available for an Azure Search service. /// <see href="https://msdn.microsoft.com/library/azure/dn946883.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> public static IndexerListResult List(this IIndexers operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) { return(operations.ListAsync(searchRequestOptions).GetAwaiter().GetResult()); }
/// <summary> /// Creates a new search index or updates an index if it already exists. /// <see href="https://docs.microsoft.com/rest/api/searchservice/update-index">Update Index</see> /// </summary> /// <param name='index'> /// The definition of the index to create or update. /// </param> /// <param name='allowIndexDowntime'> /// Allows new analyzers, tokenizers, token filters, or char filters to be /// added to an index by taking the index offline for at least a few seconds. /// This temporarily causes indexing and query requests to fail. Performance /// and write availability of the index can be impaired for several minutes /// after the index is updated, or longer for very large indexes. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation. /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation. /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="CloudException"> /// Thrown when the operation returned an invalid status code. /// </exception> /// <exception cref="Microsoft.Rest.SerializationException"> /// Thrown when unable to deserialize the response. /// </exception> /// <exception cref="Microsoft.Rest.ValidationException"> /// Thrown when a required parameter is null. /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <returns> /// A response object containing the response body and response headers. /// </returns> public Task <AzureOperationResponse <Index> > CreateOrUpdateWithHttpMessagesAsync(Index index, bool?allowIndexDowntime = default(bool?), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { return(CreateOrUpdateWithHttpMessagesAsync(index != null ? index.Name : null, index, allowIndexDowntime, searchRequestOptions, accessCondition, customHeaders, cancellationToken)); }
/// <summary> /// Creates a new Azure Search indexer. /// <see href="https://msdn.microsoft.com/library/azure/dn946899.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='indexer'> /// The definition of the indexer to create. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> public static Indexer Create(this IIndexers operations, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) { return(operations.CreateAsync(indexer, searchRequestOptions).GetAwaiter().GetResult()); }
/// <summary> /// Creates a new search index or updates an index if it already exists. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Update-Index" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='index'> /// The definition of the index to create or update. /// </param> /// <param name='allowIndexDowntime'> /// Allows new analyzers, tokenizers, token filters, or char filters /// to be added to an index by taking the index offline for at least /// a few seconds. This temporarily causes indexing and query /// requests to fail. Performance and write availability of the index /// can be impaired for several minutes after the index is updated, /// or longer for very large indexes. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation. /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation. /// </param> /// <returns> /// The index that was created or updated. /// </returns> public static Index CreateOrUpdate(this IIndexesOperations operations, Index index, bool?allowIndexDowntime = default(bool?), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition)) { return(operations.CreateOrUpdateAsync(index, allowIndexDowntime, searchRequestOptions, accessCondition).GetAwaiter().GetResult()); }
/// <summary> /// Creates a new Azure Search indexer. /// <see href="https://msdn.microsoft.com/library/azure/dn946899.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='indexer'> /// The definition of the indexer to create. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <Indexer> CreateAsync(this IIndexers operations, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateWithHttpMessagesAsync(indexer, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Retrieves a datasource definition. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Get-Data-Source" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='dataSourceName'> /// The name of the datasource to retrieve. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> public static DataSource Get(this IDataSourcesOperations operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) { return(operations.GetAsync(dataSourceName, searchRequestOptions).GetAwaiter().GetResult()); }
/// <summary> /// Returns the current status and execution history of an indexer. /// <see href="https://msdn.microsoft.com/library/azure/dn946884.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='indexerName'> /// The name of the indexer for which to retrieve status. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> public static IndexerExecutionInfo GetStatus(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) { return(operations.GetStatusAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult()); }
/// <summary> /// Creates a new datasource. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Create-Data-Source" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='dataSource'> /// The definition of the datasource to create. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> public static DataSource Create(this IDataSourcesOperations operations, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) { return(operations.CreateAsync(dataSource, searchRequestOptions).GetAwaiter().GetResult()); }
/// <summary> /// Returns the current status and execution history of an indexer. /// <see href="https://msdn.microsoft.com/library/azure/dn946884.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='indexerName'> /// The name of the indexer for which to retrieve status. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IndexerExecutionInfo> GetStatusAsync(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetStatusWithHttpMessagesAsync(indexerName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Deletes a datasource. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Delete-Data-Source" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='dataSourceName'> /// The name of the datasource to delete. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation /// </param> public static void Delete(this IDataSourcesOperations operations, string dataSourceName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition)) { operations.DeleteAsync(dataSourceName, searchRequestOptions, accessCondition).GetAwaiter().GetResult(); }
/// <summary> /// Runs an Azure Search indexer on-demand. /// <see href="https://msdn.microsoft.com/library/azure/dn946885.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='indexerName'> /// The name of the indexer to run. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> public static void Run(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) { operations.RunAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult(); }
/// <summary> /// Lists all datasources available for an Azure Search service. /// <see href="https://msdn.microsoft.com/library/azure/dn946878.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> public static DataSourceListResult List(this IDataSourcesOperations operations, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions)) { return(Task.Factory.StartNew(s => ((IDataSourcesOperations)s).ListAsync(searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Runs an Azure Search indexer on-demand. /// <see href="https://msdn.microsoft.com/library/azure/dn946885.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='indexerName'> /// The name of the indexer to run. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task RunAsync(this IIndexers operations, string indexerName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken)) { (await operations.RunWithHttpMessagesAsync(indexerName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <summary> /// Creates a new Azure Search datasource or updates a datasource if it /// already exists. /// <see href="https://msdn.microsoft.com/library/azure/dn946900.aspx" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='dataSourceName'> /// The name of the datasource to create or update. /// </param> /// <param name='dataSource'> /// The definition of the datasource to create or update. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation /// </param> public static DataSource CreateOrUpdate(this IDataSourcesOperations operations, string dataSourceName, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition)) { return(Task.Factory.StartNew(s => ((IDataSourcesOperations)s).CreateOrUpdateAsync(dataSourceName, dataSource, searchRequestOptions, accessCondition), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Creates a new Azure Search synonym map or updates a synonym map if it /// already exists. /// <see href="https://docs.microsoft.com/rest/api/searchservice/Update-Synonym-Map" /> /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='synonymMap'> /// The definition of the synonymmap to create or update. /// </param> /// <param name='searchRequestOptions'> /// Additional parameters for the operation. /// </param> /// <param name='accessCondition'> /// Additional parameters for the operation. /// </param> /// <returns>The synonym map that was created or updated.</returns> public static SynonymMap CreateOrUpdate(this ISynonymMapsOperations operations, SynonymMap synonymMap, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition)) { return(operations.CreateOrUpdateAsync(synonymMap, searchRequestOptions, accessCondition).GetAwaiter().GetResult()); }