예제 #1
0
        public static Task PauseIngestAsync(this ISearchIndexManager manager, string indexName, Action <PauseIngestSearchIndexOptions> configureOptions)
        {
            var options = new PauseIngestSearchIndexOptions();

            configureOptions(options);

            return(manager.PauseIngestAsync(indexName, options));
        }
        public async Task PauseIngestAsync(string indexName, PauseIngestSearchIndexOptions options)
        {
            var baseUri = GetIngestControlUri(indexName, true);

            Logger.LogInformation($"Trying to pause ingest for index with name {indexName} - {baseUri}");

            try
            {
                var result = await _client.PostAsync(baseUri, null, options.CancellationToken).ConfigureAwait(false);

                if (result.StatusCode == HttpStatusCode.NotFound)
                {
                    throw new SearchIndexNotFound(indexName);
                }

                result.EnsureSuccessStatusCode();
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to pause ingest for index with name {indexName} - {baseUri}");
                throw;
            }
        }