Beispiel #1
0
        public static Task FreezePlanAsync(this ISearchIndexManager manager, string indexName, Action <FreezePlanSearchIndexOptions> configureOptions)
        {
            var options = new FreezePlanSearchIndexOptions();

            configureOptions(options);

            return(manager.FreezePlanAsync(indexName, options));
        }
        public async Task FreezePlanAsync(string indexName, FreezePlanSearchIndexOptions options)
        {
            var baseUri = GetFreezeControlUri(indexName, true);

            Logger.LogInformation($"Trying to freeze 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 freeze index with name {indexName} - {baseUri}");
                throw;
            }
        }