diff --git a/.github/workflows/integration-jobs.yml b/.github/workflows/integration-jobs.yml index 05eb1bc647f..80848d2287c 100644 --- a/.github/workflows/integration-jobs.yml +++ b/.github/workflows/integration-jobs.yml @@ -26,7 +26,8 @@ jobs: '8.2.3', '8.3.3', '8.4.3', - '8.5.0-SNAPSHOT', + "8.5.0", + '8.6.0-SNAPSHOT', 'latest-8' ] diff --git a/build/scripts/Testing.fs b/build/scripts/Testing.fs index 70617c49cfb..c30608e7a6e 100644 --- a/build/scripts/Testing.fs +++ b/build/scripts/Testing.fs @@ -46,7 +46,7 @@ module Tests = sprintf "tests/%s.runsettings" prefix Directory.CreateDirectory Paths.BuildOutput |> ignore - let command = ["test"; proj; "--nologo"; "-c"; "Release"; "-s"; runSettings; "--no-build"] + let command = ["test"; proj; "--nologo"; "-c"; "Release"; "-s"; runSettings; "--no-build"; "--blame"] let wantsTrx = let wants = match args.CommandArguments with | Integration a -> a.TrxExport | Test t -> t.TrxExport | _ -> false diff --git a/src/Elastic.Clients.Elasticsearch/Api/IndexManagement/MappingResponse.cs b/src/Elastic.Clients.Elasticsearch/Api/IndexManagement/MappingResponse.cs new file mode 100644 index 00000000000..d181da29625 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/Api/IndexManagement/MappingResponse.cs @@ -0,0 +1,26 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using Elastic.Clients.Elasticsearch.Mapping; + +namespace Elastic.Clients.Elasticsearch.IndexManagement; + +public partial class MappingResponse +{ + public IReadOnlyDictionary Indices => BackingDictionary; +} + +public static class GetMappingResponseExtensions +{ + public static TypeMapping GetMappingFor(this MappingResponse response) => response.GetMappingFor(typeof(T)); + + public static TypeMapping GetMappingFor(this MappingResponse response, IndexName index) + { + if (index.IsNullOrEmpty()) + return null; + + return response.Indices.TryGetValue(index, out var indexMappings) ? indexMappings.Mappings : null; + } +} diff --git a/src/Elastic.Clients.Elasticsearch/Core/Exceptions/ThrowHelper.cs b/src/Elastic.Clients.Elasticsearch/Core/Exceptions/ThrowHelper.cs new file mode 100644 index 00000000000..5fe3afa0cf3 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/Core/Exceptions/ThrowHelper.cs @@ -0,0 +1,22 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.CompilerServices; +using System.Text.Json; + +namespace Elastic.Clients.Elasticsearch; + +internal static class ThrowHelper +{ + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void ThrowJsonException(string? message = null) => throw new JsonException(message); + + [MethodImpl(MethodImplOptions.NoInlining)] + internal static void ThrowUnknownTaggedUnionVariantJsonException(string variantTag, Type interfaceType) => + throw new JsonException($"Encounted an unsupported variant tag '{variantTag}' on '{SimplifiedFullName(interfaceType)}', which could not be deserialised."); + + [MethodImpl(MethodImplOptions.NoInlining)] + private static string SimplifiedFullName(Type type) => type.FullName.Substring(30); +} diff --git a/src/Elastic.Clients.Elasticsearch/Core/Infer/IndexName/IndexName.cs b/src/Elastic.Clients.Elasticsearch/Core/Infer/IndexName/IndexName.cs index b6a25e12ed8..756aea8fd62 100644 --- a/src/Elastic.Clients.Elasticsearch/Core/Infer/IndexName/IndexName.cs +++ b/src/Elastic.Clients.Elasticsearch/Core/Infer/IndexName/IndexName.cs @@ -123,12 +123,13 @@ private bool EqualsMarker(IndexName other) { if (other == null) return false; + if (!Name.IsNullOrEmpty() && !other.Name.IsNullOrEmpty()) return EqualsString(PrefixClusterName(other, other.Name)); if ((!Cluster.IsNullOrEmpty() || !other.Cluster.IsNullOrEmpty()) && Cluster != other.Cluster) return false; - return Type != null && other?.Type != null && Type == other.Type; + return Type is not null && other?.Type is not null && Type == other.Type; } } diff --git a/src/Elastic.Clients.Elasticsearch/Core/IsAReadOnlyDictionary.cs b/src/Elastic.Clients.Elasticsearch/Core/IsAReadOnlyDictionary.cs index 95c1f183a60..3921e5ed085 100644 --- a/src/Elastic.Clients.Elasticsearch/Core/IsAReadOnlyDictionary.cs +++ b/src/Elastic.Clients.Elasticsearch/Core/IsAReadOnlyDictionary.cs @@ -19,9 +19,8 @@ internal IsAReadOnlyDictionary(IReadOnlyDictionary backingDictiona return; var dictionary = new Dictionary(backingDictionary.Count); + foreach (var key in backingDictionary.Keys) - // ReSharper disable once VirtualMemberCallInConstructor - // expect all implementations of Sanitize to be pure dictionary[Sanitize(key)] = backingDictionary[key]; BackingDictionary = dictionary; diff --git a/src/Elastic.Clients.Elasticsearch/Core/Response/DictionaryResponse.cs b/src/Elastic.Clients.Elasticsearch/Core/Response/DictionaryResponse.cs new file mode 100644 index 00000000000..c3cd93235c1 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/Core/Response/DictionaryResponse.cs @@ -0,0 +1,24 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using Elastic.Transport.Products.Elasticsearch; + +namespace Elastic.Clients.Elasticsearch; + +public abstract class DictionaryResponse : ElasticsearchResponseBase +{ + internal DictionaryResponse(IReadOnlyDictionary dictionary) + { + if (dictionary is null) + throw new ArgumentNullException(nameof(dictionary)); + + BackingDictionary = dictionary; + } + + internal DictionaryResponse() => BackingDictionary = EmptyReadOnly.Dictionary; + + protected IReadOnlyDictionary BackingDictionary { get; } +} diff --git a/src/Elastic.Clients.Elasticsearch/Core/Response/ResolvableDictionaryProxy.cs b/src/Elastic.Clients.Elasticsearch/Core/Response/ResolvableDictionaryProxy.cs new file mode 100644 index 00000000000..1edc6924b3f --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/Core/Response/ResolvableDictionaryProxy.cs @@ -0,0 +1,59 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using Elastic.Transport; +using System.Collections; +using System.Collections.Generic; + +namespace Elastic.Clients.Elasticsearch; + +/// +/// A proxy dictionary that is settings-aware to correctly handle IUrlParameter-based keys such as IndexName. +/// +public sealed class ResolvableDictionaryProxy : IIsAReadOnlyDictionary + where TKey : IUrlParameter +{ + private readonly IElasticsearchClientSettings _elasticsearchClientSettings; + + internal ResolvableDictionaryProxy(IElasticsearchClientSettings elasticsearchClientSettings, IReadOnlyDictionary backingDictionary) + { + _elasticsearchClientSettings = elasticsearchClientSettings; + + if (backingDictionary == null) + return; + + Original = backingDictionary; + + var dictionary = new Dictionary(backingDictionary.Count); + + foreach (var key in backingDictionary.Keys) + dictionary[Sanitize(key)] = backingDictionary[key]; + + BackingDictionary = dictionary; + } + + public int Count => BackingDictionary.Count; + + public TValue this[TKey key] => BackingDictionary.TryGetValue(Sanitize(key), out var v) ? v : default; + public TValue this[string key] => BackingDictionary.TryGetValue(key, out var v) ? v : default; + + public IEnumerable Keys => Original.Keys; + public IEnumerable ResolvedKeys => BackingDictionary.Keys; + + public IEnumerable Values => BackingDictionary.Values; + internal IReadOnlyDictionary BackingDictionary { get; } = EmptyReadOnly.Dictionary; + private IReadOnlyDictionary Original { get; } = EmptyReadOnly.Dictionary; + + IEnumerator IEnumerable.GetEnumerator() => Original.GetEnumerator(); + + IEnumerator> IEnumerable>.GetEnumerator() => + Original.GetEnumerator(); + + public bool ContainsKey(TKey key) => BackingDictionary.ContainsKey(Sanitize(key)); + + public bool TryGetValue(TKey key, out TValue value) => + BackingDictionary.TryGetValue(Sanitize(key), out value); + + private string Sanitize(TKey key) => key?.GetString(_elasticsearchClientSettings); +} diff --git a/src/Elastic.Clients.Elasticsearch/Serialization/DefaultRequestResponseSerializer.cs b/src/Elastic.Clients.Elasticsearch/Serialization/DefaultRequestResponseSerializer.cs index ece54bcfb7f..aafb73fc9b8 100644 --- a/src/Elastic.Clients.Elasticsearch/Serialization/DefaultRequestResponseSerializer.cs +++ b/src/Elastic.Clients.Elasticsearch/Serialization/DefaultRequestResponseSerializer.cs @@ -2,7 +2,6 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; @@ -47,10 +46,11 @@ public DefaultRequestResponseSerializer(IElasticsearchClientSettings settings) new SelfTwoWaySerializableConverterFactory(settings), new IndicesJsonConverter(settings), new IdsConverter(settings), - new IsADictionaryConverter(), + new IsADictionaryConverterFactory(), new ResponseItemConverterFactory(), new UnionConverter(), - new ExtraSerializationData(settings) + new ExtraSerializationData(settings), + new DictionaryResponseConverterFactory(settings) }, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; diff --git a/src/Elastic.Clients.Elasticsearch/Serialization/DictionaryResponseConverter.cs b/src/Elastic.Clients.Elasticsearch/Serialization/DictionaryResponseConverter.cs new file mode 100644 index 00000000000..374b0667765 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/Serialization/DictionaryResponseConverter.cs @@ -0,0 +1,87 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; +using Elastic.Transport; + +namespace Elastic.Clients.Elasticsearch.Serialization; + +internal sealed class DictionaryResponseConverterFactory : JsonConverterFactory +{ + private readonly IElasticsearchClientSettings _settings; + + public DictionaryResponseConverterFactory(IElasticsearchClientSettings settings) => _settings = settings; + + public override bool CanConvert(Type typeToConvert) => + typeToConvert.BaseType is not null && + typeToConvert.BaseType.IsGenericType && + typeToConvert.BaseType.GetGenericTypeDefinition() == typeof(DictionaryResponse<,>); + + public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options) + { + var args = typeToConvert.BaseType.GetGenericArguments(); + + var keyType = args[0]; + var valueType = args[1]; + + if (keyType.IsClass) + { + if (keyType == typeof(IndexName)) + { + return (JsonConverter)Activator.CreateInstance( + typeof(ResolvableDictionaryResponseConverterInner<,,>).MakeGenericType(typeToConvert, keyType, valueType), _settings); + } + + return (JsonConverter)Activator.CreateInstance( + typeof(DictionaryResponseConverterInner<,,>).MakeGenericType(typeToConvert, keyType, valueType)); + } + + return null; + } + + private class DictionaryResponseConverterInner : JsonConverter + where TKey : class + where TType : DictionaryResponse, new() + { + public override TType? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + var dictionary = JsonSerializer.Deserialize>(ref reader, options); + + if (dictionary is null) + return null; + + return (TType)Activator.CreateInstance(typeof(TType), new object[] { dictionary }); + } + + public override void Write(Utf8JsonWriter writer, TType value, JsonSerializerOptions options) => + throw new NotImplementedException("Response converters do not support serialization."); + } + + private class ResolvableDictionaryResponseConverterInner : JsonConverter + where TKey : class, IUrlParameter + where TType : DictionaryResponse, new() + { + private readonly IElasticsearchClientSettings _settings; + + public ResolvableDictionaryResponseConverterInner(IElasticsearchClientSettings settings) => _settings = settings; + + public override TType? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + var dictionary = JsonSerializer.Deserialize>(ref reader, options); + + if (dictionary is null) + return null; + + var dictionaryProxy = new ResolvableDictionaryProxy(_settings, dictionary); + + return (TType)Activator.CreateInstance(typeof(TType), new object[] { dictionaryProxy }); + } + + public override void Write(Utf8JsonWriter writer, TType value, JsonSerializerOptions options) => + throw new NotImplementedException("Response converters do not support serialization."); + } +} diff --git a/src/Elastic.Clients.Elasticsearch/Serialization/ThrowHelper.cs b/src/Elastic.Clients.Elasticsearch/Serialization/IUnionVerifiable.cs similarity index 53% rename from src/Elastic.Clients.Elasticsearch/Serialization/ThrowHelper.cs rename to src/Elastic.Clients.Elasticsearch/Serialization/IUnionVerifiable.cs index b8fa30111fb..51fac87e1c9 100644 --- a/src/Elastic.Clients.Elasticsearch/Serialization/ThrowHelper.cs +++ b/src/Elastic.Clients.Elasticsearch/Serialization/IUnionVerifiable.cs @@ -2,13 +2,9 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Runtime.CompilerServices; -using System.Text.Json; - namespace Elastic.Clients.Elasticsearch.Serialization; -internal class ThrowHelper +internal interface IUnionVerifiable { - [MethodImpl(MethodImplOptions.NoInlining)] - public static void ThrowJsonException(string? message = null) => throw new JsonException(message); + bool IsSuccessful { get; } } diff --git a/src/Elastic.Clients.Elasticsearch/Serialization/IsADictionaryConverter.cs b/src/Elastic.Clients.Elasticsearch/Serialization/IsADictionaryConverterFactory.cs similarity index 87% rename from src/Elastic.Clients.Elasticsearch/Serialization/IsADictionaryConverter.cs rename to src/Elastic.Clients.Elasticsearch/Serialization/IsADictionaryConverterFactory.cs index 8dd84dadc13..3d36da2a1ea 100644 --- a/src/Elastic.Clients.Elasticsearch/Serialization/IsADictionaryConverter.cs +++ b/src/Elastic.Clients.Elasticsearch/Serialization/IsADictionaryConverterFactory.cs @@ -6,14 +6,14 @@ using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; +using Elastic.Clients.Elasticsearch.Mapping; namespace Elastic.Clients.Elasticsearch.Serialization; -// TODO : We need to handle these cases https://github.com/elastic/elasticsearch-specification/pull/1589 - -internal sealed class IsADictionaryConverter : JsonConverterFactory +internal sealed class IsADictionaryConverterFactory : JsonConverterFactory { public override bool CanConvert(Type typeToConvert) => + typeToConvert.Name != nameof(Properties) && // Properties has it's own converter assigned typeToConvert.BaseType is not null && typeToConvert.BaseType.IsGenericType && typeToConvert.BaseType.GetGenericTypeDefinition() == typeof(IsADictionary<,>); @@ -52,8 +52,3 @@ public override void Write(Utf8JsonWriter writer, TType value, JsonSerializerOpt JsonSerializer.Serialize>(writer, value.BackingDictionary, options); } } - -internal interface IUnionVerifiable -{ - bool IsSuccessful { get; } -} diff --git a/src/Elastic.Clients.Elasticsearch/Types/Mapping/Properties.cs b/src/Elastic.Clients.Elasticsearch/Types/Mapping/Properties.cs index 1a082ad1659..1f224c043b0 100644 --- a/src/Elastic.Clients.Elasticsearch/Types/Mapping/Properties.cs +++ b/src/Elastic.Clients.Elasticsearch/Types/Mapping/Properties.cs @@ -3,19 +3,24 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using Elastic.Clients.Elasticsearch.Serialization; namespace Elastic.Clients.Elasticsearch.Mapping; +[JsonConverter(typeof(PropertiesConverter))] public partial class Properties { - // TODO - THE ADD METHOD IN THE GENERATED VERSION OF THIS SHOULD TAKE PROPERTYNAME + private readonly IElasticsearchClientSettings _settings; - // TODO - Generate this - public void Add(Expression> propertyName, IProperty property) => BackingDictionary.Add(propertyName, property); + internal Properties(IElasticsearchClientSettings values) => _settings = values; - // TODO - Generate this - public bool TryGetProperty(PropertyName propertyName, out T property) where T : IProperty + public void Add(Expression> propertyName, IProperty property) => BackingDictionary.Add(Sanitize(propertyName), property); + + public bool TryGetProperty(PropertyName propertyName, [NotNullWhen(returnValue: true)] out T? property) where T : class, IProperty { if (BackingDictionary.TryGetValue(propertyName, out var matchedProperty) && matchedProperty is T finalProperty) { @@ -23,13 +28,67 @@ public bool TryGetProperty(PropertyName propertyName, out T property) where T return true; } - property = default; + property = null; return false; } + + protected override PropertyName Sanitize(PropertyName key) => _settings?.Inferrer.PropertyName(key) ?? key; +} + +internal sealed class PropertiesConverter : JsonConverter +{ + public override Properties? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (!options.TryGetClientSettings(out var settings)) + throw new JsonException("Unable to retrive client settings during properties deserialization."); + + if (reader.TokenType != JsonTokenType.StartObject) + throw new JsonException("Expected start object token."); + + var properties = new Properties(settings); + + while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + { + if (reader.TokenType != JsonTokenType.PropertyName) + throw new JsonException("Expected property name token."); + + var propertyName = reader.GetString(); + reader.Read(); + var property = JsonSerializer.Deserialize(ref reader, options); + properties.Add(propertyName, property); + } + + return properties; + } + + public override void Write(Utf8JsonWriter writer, Properties value, JsonSerializerOptions options) + { + if (!options.TryGetClientSettings(out var settings)) + throw new JsonException("Unable to retrive client settings during properties serialization."); + + if (value is null) + { + writer.WriteNullValue(); + return; + } + + // HACK: Deduplicate property mappings with an instance of Properties that has access to ElasticsearchClientSettings to sanitize PropertyName keys. + var properties = new Properties(settings); + + foreach (var kv in value) + { + // TODO - NEST checks for properties of IPropertyWithClrOrigin so that it can then skip ignored properties etc. + // This functionality is missing for GA. + + properties[kv.Key] = kv.Value; + continue; + } + + JsonSerializer.Serialize(writer, properties.BackingDictionary, options); + } } -// TODO - Generate this? -public partial class Properties : Properties +public sealed class Properties : Properties { public void Add(Expression> name, IProperty property) => BackingDictionary.Add(name, property); } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs index 1e20dbc39ea..5e7a1e09be8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs @@ -67,19 +67,16 @@ internal static class ApiUrlsLookups internal static ApiUrls IndexManagementGetMapping = new ApiUrls(new[] { "/_mapping", "/{index}/_mapping" }); internal static ApiUrls IndexManagementMigrateToDataStream = new ApiUrls(new[] { "/_data_stream/_migrate/{name}" }); internal static ApiUrls IndexManagementOpen = new ApiUrls(new[] { "/{index}/_open" }); - internal static ApiUrls IndexManagementPromoteDataStream = new ApiUrls(new[] { "/_data_stream/_promote/{name}" }); internal static ApiUrls IndexManagementPutAlias = new ApiUrls(new[] { "/{index}/_alias/{name}" }); internal static ApiUrls IndexManagementPutIndexTemplate = new ApiUrls(new[] { "/_index_template/{name}" }); internal static ApiUrls IndexManagementPutMapping = new ApiUrls(new[] { "/{index}/_mapping" }); internal static ApiUrls IndexManagementPutSettings = new ApiUrls(new[] { "/_settings", "/{index}/_settings" }); internal static ApiUrls IndexManagementPutTemplate = new ApiUrls(new[] { "/_template/{name}" }); - internal static ApiUrls IndexManagementRecovery = new ApiUrls(new[] { "/_recovery", "/{index}/_recovery" }); internal static ApiUrls IndexManagementRefresh = new ApiUrls(new[] { "/_refresh", "/{index}/_refresh" }); internal static ApiUrls IndexManagementReloadSearchAnalyzers = new ApiUrls(new[] { "/{index}/_reload_search_analyzers" }); internal static ApiUrls IndexManagementResolveIndex = new ApiUrls(new[] { "/_resolve/index/{name}" }); internal static ApiUrls IndexManagementRollover = new ApiUrls(new[] { "/{alias}/_rollover", "/{alias}/_rollover/{new_index}" }); internal static ApiUrls IndexManagementSegments = new ApiUrls(new[] { "/_segments", "/{index}/_segments" }); - internal static ApiUrls IndexManagementGetSettings = new ApiUrls(new[] { "/_settings", "/{index}/_settings", "/{index}/_settings/{name}", "/_settings/{name}" }); internal static ApiUrls IndexManagementShardStores = new ApiUrls(new[] { "/_shard_stores", "/{index}/_shard_stores" }); internal static ApiUrls IndexManagementShrink = new ApiUrls(new[] { "/{index}/_shrink/{target}" }); internal static ApiUrls IndexManagementSimulateIndexTemplate = new ApiUrls(new[] { "/_index_template/_simulate_index/{name}" }); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AliasResponse.g.cs index a86effab44f..b706987a7dd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AliasResponse.g.cs @@ -23,6 +23,13 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed partial class AliasResponse : ElasticsearchResponseBase +public sealed partial class AliasResponse : DictionaryResponse { + public AliasResponse(IReadOnlyDictionary dictionary) : base(dictionary) + { + } + + public AliasResponse() : base() + { + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldMappingResponse.g.cs index efa96258ed3..efb4695658b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldMappingResponse.g.cs @@ -23,6 +23,13 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed partial class FieldMappingResponse : ElasticsearchResponseBase +public sealed partial class FieldMappingResponse : DictionaryResponse { + public FieldMappingResponse(IReadOnlyDictionary dictionary) : base(dictionary) + { + } + + public FieldMappingResponse() : base() + { + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetResponse.g.cs index 6755ebfc74c..847cf9bf2ff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetResponse.g.cs @@ -23,6 +23,13 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed partial class GetResponse : ElasticsearchResponseBase +public sealed partial class GetResponse : DictionaryResponse { + public GetResponse(IReadOnlyDictionary dictionary) : base(dictionary) + { + } + + public GetResponse() : base() + { + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MappingResponse.g.cs index 623c287b322..e63bf59ae7c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MappingResponse.g.cs @@ -23,6 +23,13 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed partial class MappingResponse : ElasticsearchResponseBase +public sealed partial class MappingResponse : DictionaryResponse { + public MappingResponse(IReadOnlyDictionary dictionary) : base(dictionary) + { + } + + public MappingResponse() : base() + { + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs deleted file mode 100644 index 330f047043b..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. -// -// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ -// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ -// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ -// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ -// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ -// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ -// ------------------------------------------------ -// -// This file is automatically generated. -// Please do not edit these files manually. -// -// ------------------------------------------------ - -using Elastic.Clients.Elasticsearch.Fluent; -using Elastic.Clients.Elasticsearch.Requests; -using Elastic.Clients.Elasticsearch.Serialization; -using Elastic.Transport; -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text.Json; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed class PromoteDataStreamRequestParameters : RequestParameters -{ -} - -public sealed partial class PromoteDataStreamRequest : PlainRequest -{ - public PromoteDataStreamRequest(Elastic.Clients.Elasticsearch.IndexName name) : base(r => r.Required("name", name)) - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexManagementPromoteDataStream; - protected override HttpMethod HttpMethod => HttpMethod.POST; - protected override bool SupportsBody => false; -} - -public sealed partial class PromoteDataStreamRequestDescriptor : RequestDescriptor -{ - internal PromoteDataStreamRequestDescriptor(Action configure) => configure.Invoke(this); - public PromoteDataStreamRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName name) : base(r => r.Required("name", name)) - { - } - - internal PromoteDataStreamRequestDescriptor() - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexManagementPromoteDataStream; - protected override HttpMethod HttpMethod => HttpMethod.POST; - protected override bool SupportsBody => false; - public PromoteDataStreamRequestDescriptor Name(Elastic.Clients.Elasticsearch.IndexName name) - { - RouteValues.Required("name", name); - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs deleted file mode 100644 index 8d67ab83489..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. -// -// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ -// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ -// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ -// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ -// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ -// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ -// ------------------------------------------------ -// -// This file is automatically generated. -// Please do not edit these files manually. -// -// ------------------------------------------------ - -using Elastic.Clients.Elasticsearch.Fluent; -using Elastic.Clients.Elasticsearch.Requests; -using Elastic.Clients.Elasticsearch.Serialization; -using Elastic.Transport; -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text.Json; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed class RecoveryRequestParameters : RequestParameters -{ - [JsonIgnore] - public bool? ActiveOnly { get => Q("active_only"); set => Q("active_only", value); } - - [JsonIgnore] - public bool? Detailed { get => Q("detailed"); set => Q("detailed", value); } -} - -public sealed partial class RecoveryRequest : PlainRequest -{ - public RecoveryRequest() - { - } - - public RecoveryRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => r.Optional("index", indices)) - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexManagementRecovery; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - [JsonIgnore] - public bool? ActiveOnly { get => Q("active_only"); set => Q("active_only", value); } - - [JsonIgnore] - public bool? Detailed { get => Q("detailed"); set => Q("detailed", value); } -} - -public sealed partial class RecoveryRequestDescriptor : RequestDescriptor, RecoveryRequestParameters> -{ - internal RecoveryRequestDescriptor(Action> configure) => configure.Invoke(this); - public RecoveryRequestDescriptor() - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexManagementRecovery; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - public RecoveryRequestDescriptor ActiveOnly(bool? activeOnly = true) => Qs("active_only", activeOnly); - public RecoveryRequestDescriptor Detailed(bool? detailed = true) => Qs("detailed", detailed); - public RecoveryRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? indices) - { - RouteValues.Optional("index", indices); - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - } -} - -public sealed partial class RecoveryRequestDescriptor : RequestDescriptor -{ - internal RecoveryRequestDescriptor(Action configure) => configure.Invoke(this); - public RecoveryRequestDescriptor() - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexManagementRecovery; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - public RecoveryRequestDescriptor ActiveOnly(bool? activeOnly = true) => Qs("active_only", activeOnly); - public RecoveryRequestDescriptor Detailed(bool? detailed = true) => Qs("detailed", detailed); - public RecoveryRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? indices) - { - RouteValues.Optional("index", indices); - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SettingsRequest.g.cs deleted file mode 100644 index 7f9518c7091..00000000000 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SettingsRequest.g.cs +++ /dev/null @@ -1,179 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. -// -// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ -// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ -// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ -// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ -// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ -// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ -// ------------------------------------------------ -// -// This file is automatically generated. -// Please do not edit these files manually. -// -// ------------------------------------------------ - -using Elastic.Clients.Elasticsearch.Fluent; -using Elastic.Clients.Elasticsearch.Requests; -using Elastic.Clients.Elasticsearch.Serialization; -using Elastic.Transport; -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text.Json; -using System.Text.Json.Serialization; - -#nullable restore -namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed class SettingsRequestParameters : RequestParameters -{ - [JsonIgnore] - public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } - - [JsonIgnore] - public IList? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } - - [JsonIgnore] - public bool? FlatSettings { get => Q("flat_settings"); set => Q("flat_settings", value); } - - [JsonIgnore] - public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } - - [JsonIgnore] - public bool? IncludeDefaults { get => Q("include_defaults"); set => Q("include_defaults", value); } - - [JsonIgnore] - public bool? Local { get => Q("local"); set => Q("local", value); } - - [JsonIgnore] - public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } -} - -public sealed partial class SettingsRequest : PlainRequest -{ - public SettingsRequest() - { - } - - public SettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => r.Optional("index", indices)) - { - } - - public SettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices, Elastic.Clients.Elasticsearch.Names? name) : base(r => r.Optional("index", indices).Optional("name", name)) - { - } - - public SettingsRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r => r.Optional("name", name)) - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexManagementGetSettings; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - [JsonIgnore] - public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } - - [JsonIgnore] - public IList? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } - - [JsonIgnore] - public bool? FlatSettings { get => Q("flat_settings"); set => Q("flat_settings", value); } - - [JsonIgnore] - public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } - - [JsonIgnore] - public bool? IncludeDefaults { get => Q("include_defaults"); set => Q("include_defaults", value); } - - [JsonIgnore] - public bool? Local { get => Q("local"); set => Q("local", value); } - - [JsonIgnore] - public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } -} - -public sealed partial class SettingsRequestDescriptor : RequestDescriptor, SettingsRequestParameters> -{ - internal SettingsRequestDescriptor(Action> configure) => configure.Invoke(this); - public SettingsRequestDescriptor() - { - } - - public SettingsRequestDescriptor(Elastic.Clients.Elasticsearch.Indices? indices, Elastic.Clients.Elasticsearch.Names? name) : base(r => r.Optional("index", indices).Optional("name", name)) - { - } - - public SettingsRequestDescriptor(Elastic.Clients.Elasticsearch.Names? name) : base(r => r.Optional("name", name)) - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexManagementGetSettings; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - public SettingsRequestDescriptor AllowNoIndices(bool? allowNoIndices = true) => Qs("allow_no_indices", allowNoIndices); - public SettingsRequestDescriptor ExpandWildcards(IList? expandWildcards) => Qs("expand_wildcards", expandWildcards); - public SettingsRequestDescriptor FlatSettings(bool? flatSettings = true) => Qs("flat_settings", flatSettings); - public SettingsRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable); - public SettingsRequestDescriptor IncludeDefaults(bool? includeDefaults = true) => Qs("include_defaults", includeDefaults); - public SettingsRequestDescriptor Local(bool? local = true) => Qs("local", local); - public SettingsRequestDescriptor MasterTimeout(Elastic.Clients.Elasticsearch.Duration? masterTimeout) => Qs("master_timeout", masterTimeout); - public SettingsRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? indices) - { - RouteValues.Optional("index", indices); - return Self; - } - - public SettingsRequestDescriptor Name(Elastic.Clients.Elasticsearch.Names? name) - { - RouteValues.Optional("name", name); - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - } -} - -public sealed partial class SettingsRequestDescriptor : RequestDescriptor -{ - internal SettingsRequestDescriptor(Action configure) => configure.Invoke(this); - public SettingsRequestDescriptor() - { - } - - public SettingsRequestDescriptor(Elastic.Clients.Elasticsearch.Indices? indices, Elastic.Clients.Elasticsearch.Names? name) : base(r => r.Optional("index", indices).Optional("name", name)) - { - } - - public SettingsRequestDescriptor(Elastic.Clients.Elasticsearch.Names? name) : base(r => r.Optional("name", name)) - { - } - - internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexManagementGetSettings; - protected override HttpMethod HttpMethod => HttpMethod.GET; - protected override bool SupportsBody => false; - public SettingsRequestDescriptor AllowNoIndices(bool? allowNoIndices = true) => Qs("allow_no_indices", allowNoIndices); - public SettingsRequestDescriptor ExpandWildcards(IList? expandWildcards) => Qs("expand_wildcards", expandWildcards); - public SettingsRequestDescriptor FlatSettings(bool? flatSettings = true) => Qs("flat_settings", flatSettings); - public SettingsRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable); - public SettingsRequestDescriptor IncludeDefaults(bool? includeDefaults = true) => Qs("include_defaults", includeDefaults); - public SettingsRequestDescriptor Local(bool? local = true) => Qs("local", local); - public SettingsRequestDescriptor MasterTimeout(Elastic.Clients.Elasticsearch.Duration? masterTimeout) => Qs("master_timeout", masterTimeout); - public SettingsRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? indices) - { - RouteValues.Optional("index", indices); - return Self; - } - - public SettingsRequestDescriptor Name(Elastic.Clients.Elasticsearch.Names? name) - { - RouteValues.Optional("name", name); - return Self; - } - - protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) - { - } -} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/TemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/TemplateResponse.g.cs index 331a362d209..81f0850b4ba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/TemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/TemplateResponse.g.cs @@ -23,6 +23,13 @@ #nullable restore namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed partial class TemplateResponse : ElasticsearchResponseBase +public sealed partial class TemplateResponse : DictionaryResponse { + public TemplateResponse(IReadOnlyDictionary dictionary) : base(dictionary) + { + } + + public TemplateResponse() : base() + { + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs index cbf2fbb46cd..ae10d7068ea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs @@ -44,7 +44,11 @@ public sealed class RankEvalRequestParameters : RequestParameters { - public RankEvalRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => r.Required("index", indices)) + public RankEvalRequest() + { + } + + public RankEvalRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => r.Optional("index", indices)) { } @@ -75,11 +79,7 @@ public RankEvalRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r = public sealed partial class RankEvalRequestDescriptor : RequestDescriptor, RankEvalRequestParameters> { internal RankEvalRequestDescriptor(Action> configure) => configure.Invoke(this); - public RankEvalRequestDescriptor(Elastic.Clients.Elasticsearch.Indices indices) : base(r => r.Required("index", indices)) - { - } - - internal RankEvalRequestDescriptor() + public RankEvalRequestDescriptor() { } @@ -90,9 +90,9 @@ internal RankEvalRequestDescriptor() public RankEvalRequestDescriptor ExpandWildcards(IList? expandWildcards) => Qs("expand_wildcards", expandWildcards); public RankEvalRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable); public RankEvalRequestDescriptor SearchType(string? searchType) => Qs("search_type", searchType); - public RankEvalRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices indices) + public RankEvalRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? indices) { - RouteValues.Required("index", indices); + RouteValues.Optional("index", indices); return Self; } @@ -227,11 +227,7 @@ protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions o public sealed partial class RankEvalRequestDescriptor : RequestDescriptor { internal RankEvalRequestDescriptor(Action configure) => configure.Invoke(this); - public RankEvalRequestDescriptor(Elastic.Clients.Elasticsearch.Indices indices) : base(r => r.Required("index", indices)) - { - } - - internal RankEvalRequestDescriptor() + public RankEvalRequestDescriptor() { } @@ -242,9 +238,9 @@ internal RankEvalRequestDescriptor() public RankEvalRequestDescriptor ExpandWildcards(IList? expandWildcards) => Qs("expand_wildcards", expandWildcards); public RankEvalRequestDescriptor IgnoreUnavailable(bool? ignoreUnavailable = true) => Qs("ignore_unavailable", ignoreUnavailable); public RankEvalRequestDescriptor SearchType(string? searchType) => Qs("search_type", searchType); - public RankEvalRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices indices) + public RankEvalRequestDescriptor Indices(Elastic.Clients.Elasticsearch.Indices? indices) { - RouteValues.Required("index", indices); + RouteValues.Optional("index", indices); return Self; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Indices.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Indices.g.cs index 6ddeae35258..ec3f06f356e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Indices.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.Indices.g.cs @@ -1435,48 +1435,6 @@ public Task OpenAsync(Elastic.Clients.Elasticsearch.Ind return DoRequestAsync, OpenResponse>(descriptor); } - public PromoteDataStreamResponse PromoteDataStream(PromoteDataStreamRequest request) - { - request.BeforeRequest(); - return DoRequest(request); - } - - public Task PromoteDataStreamAsync(PromoteDataStreamRequest request, CancellationToken cancellationToken = default) - { - request.BeforeRequest(); - return DoRequestAsync(request, cancellationToken); - } - - public PromoteDataStreamResponse PromoteDataStream(Elastic.Clients.Elasticsearch.IndexName name) - { - var descriptor = new PromoteDataStreamRequestDescriptor(name); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public PromoteDataStreamResponse PromoteDataStream(Elastic.Clients.Elasticsearch.IndexName name, Action configureRequest) - { - var descriptor = new PromoteDataStreamRequestDescriptor(name); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public Task PromoteDataStreamAsync(Elastic.Clients.Elasticsearch.IndexName name, CancellationToken cancellationToken = default) - { - var descriptor = new PromoteDataStreamRequestDescriptor(name); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task PromoteDataStreamAsync(Elastic.Clients.Elasticsearch.IndexName name, Action configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new PromoteDataStreamRequestDescriptor(name); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - public PutAliasResponse PutAlias(PutAliasRequest request) { request.BeforeRequest(); @@ -1751,64 +1709,6 @@ public Task PutTemplateAsync(Elastic.Clients.Elasticsearch. return DoRequestAsync(descriptor); } - public RecoveryResponse Recovery(RecoveryRequest request) - { - request.BeforeRequest(); - return DoRequest(request); - } - - public Task RecoveryAsync(RecoveryRequest request, CancellationToken cancellationToken = default) - { - request.BeforeRequest(); - return DoRequestAsync(request, cancellationToken); - } - - public RecoveryResponse Recovery() - { - var descriptor = new RecoveryRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public RecoveryResponse Recovery(Action configureRequest) - { - var descriptor = new RecoveryRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public RecoveryResponse Recovery(Action> configureRequest) - { - var descriptor = new RecoveryRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest, RecoveryResponse>(descriptor); - } - - public Task RecoveryAsync(CancellationToken cancellationToken = default) - { - var descriptor = new RecoveryRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task RecoveryAsync(Action configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new RecoveryRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task RecoveryAsync(Action> configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new RecoveryRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync, RecoveryResponse>(descriptor); - } - public RefreshResponse Refresh(RefreshRequest request) { request.BeforeRequest(); @@ -2067,64 +1967,6 @@ public Task SegmentsAsync(Action, SegmentsResponse>(descriptor); } - public SettingsResponse GetSettings(SettingsRequest request) - { - request.BeforeRequest(); - return DoRequest(request); - } - - public Task GetSettingsAsync(SettingsRequest request, CancellationToken cancellationToken = default) - { - request.BeforeRequest(); - return DoRequestAsync(request, cancellationToken); - } - - public SettingsResponse GetSettings() - { - var descriptor = new SettingsRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public SettingsResponse GetSettings(Action configureRequest) - { - var descriptor = new SettingsRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public SettingsResponse GetSettings(Action> configureRequest) - { - var descriptor = new SettingsRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest, SettingsResponse>(descriptor); - } - - public Task GetSettingsAsync(CancellationToken cancellationToken = default) - { - var descriptor = new SettingsRequestDescriptor(); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task GetSettingsAsync(Action configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new SettingsRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task GetSettingsAsync(Action> configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new SettingsRequestDescriptor(); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync, SettingsResponse>(descriptor); - } - public ShardStoresResponse ShardStores(ShardStoresRequest request) { request.BeforeRequest(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs index 852bbe33136..078175f59e4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Client/ElasticsearchClient.g.cs @@ -1376,29 +1376,6 @@ public RankEvalResponse RankEval(Action, RankEvalResponse>(descriptor); } - public RankEvalResponse RankEval(Elastic.Clients.Elasticsearch.Indices indices) - { - var descriptor = new RankEvalRequestDescriptor(indices); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public RankEvalResponse RankEval(Elastic.Clients.Elasticsearch.Indices indices, Action configureRequest) - { - var descriptor = new RankEvalRequestDescriptor(indices); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest(descriptor); - } - - public RankEvalResponse RankEval(Elastic.Clients.Elasticsearch.Indices indices, Action> configureRequest) - { - var descriptor = new RankEvalRequestDescriptor(indices); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequest, RankEvalResponse>(descriptor); - } - public Task RankEvalAsync(CancellationToken cancellationToken = default) { var descriptor = new RankEvalRequestDescriptor(); @@ -1422,29 +1399,6 @@ public Task RankEvalAsync(Action, RankEvalResponse>(descriptor); } - public Task RankEvalAsync(Elastic.Clients.Elasticsearch.Indices indices, CancellationToken cancellationToken = default) - { - var descriptor = new RankEvalRequestDescriptor(indices); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task RankEvalAsync(Elastic.Clients.Elasticsearch.Indices indices, Action configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new RankEvalRequestDescriptor(indices); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync(descriptor); - } - - public Task RankEvalAsync(Elastic.Clients.Elasticsearch.Indices indices, Action> configureRequest, CancellationToken cancellationToken = default) - { - var descriptor = new RankEvalRequestDescriptor(indices); - configureRequest?.Invoke(descriptor); - descriptor.BeforeRequest(); - return DoRequestAsync, RankEvalResponse>(descriptor); - } - public ReindexResponse Reindex(ReindexRequest request) { request.BeforeRequest(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs index 48ebcd9ff02..0a10b13c868 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs @@ -36,7 +36,7 @@ public Analyzers(IDictionary container) : base(container) { } - public void Add(string name, IAnalyzer analyzer) => BackingDictionary.Add(name, analyzer); + public void Add(string name, IAnalyzer analyzer) => BackingDictionary.Add(Sanitize(name), analyzer); } public sealed partial class AnalyzersDescriptor : IsADictionaryDescriptor @@ -135,8 +135,11 @@ public override IAnalyzer Read(ref Utf8JsonReader reader, Type typeToConvert, Js return JsonSerializer.Deserialize(ref reader, options); case "custom": return JsonSerializer.Deserialize(ref reader, options); + case null: + return JsonSerializer.Deserialize(ref reader, options); default: - throw new JsonException("Encounted an unknown variant type which could not be deserialised."); + ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(IAnalyzer)); + return null; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilterDefinitions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilterDefinitions.g.cs index f4d41fc454d..999a81a7e02 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilterDefinitions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilterDefinitions.g.cs @@ -36,7 +36,7 @@ public CharFilterDefinitions(IDictionary containe { } - public void Add(string name, ICharFilterDefinition charFilterDefinition) => BackingDictionary.Add(name, charFilterDefinition); + public void Add(string name, ICharFilterDefinition charFilterDefinition) => BackingDictionary.Add(Sanitize(name), charFilterDefinition); } public sealed partial class CharFilterDefinitionsDescriptor : IsADictionaryDescriptor @@ -91,7 +91,8 @@ public override ICharFilterDefinition Read(ref Utf8JsonReader reader, Type typeT case "html_strip": return JsonSerializer.Deserialize(ref reader, options); default: - throw new JsonException("Encounted an unknown variant type which could not be deserialised."); + ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ICharFilterDefinition)); + return null; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs index 3e8f99ed347..ec19e459a3c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs @@ -36,7 +36,7 @@ public Normalizers(IDictionary container) : base(container) { } - public void Add(string name, INormalizer normalizer) => BackingDictionary.Add(name, normalizer); + public void Add(string name, INormalizer normalizer) => BackingDictionary.Add(Sanitize(name), normalizer); } public sealed partial class NormalizersDescriptor : IsADictionaryDescriptor @@ -76,7 +76,8 @@ public override INormalizer Read(ref Utf8JsonReader reader, Type typeToConvert, case "lowercase": return JsonSerializer.Deserialize(ref reader, options); default: - throw new JsonException("Encounted an unknown variant type which could not be deserialised."); + ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(INormalizer)); + return null; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilterDefinitions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilterDefinitions.g.cs index 61ca6c99291..3be6bba9d2e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilterDefinitions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilterDefinitions.g.cs @@ -36,7 +36,7 @@ public TokenFilterDefinitions(IDictionary contai { } - public void Add(string name, ITokenFilterDefinition tokenFilterDefinition) => BackingDictionary.Add(name, tokenFilterDefinition); + public void Add(string name, ITokenFilterDefinition tokenFilterDefinition) => BackingDictionary.Add(Sanitize(name), tokenFilterDefinition); } public sealed partial class TokenFilterDefinitionsDescriptor : IsADictionaryDescriptor @@ -306,7 +306,8 @@ public override ITokenFilterDefinition Read(ref Utf8JsonReader reader, Type type case "asciifolding": return JsonSerializer.Deserialize(ref reader, options); default: - throw new JsonException("Encounted an unknown variant type which could not be deserialised."); + ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ITokenFilterDefinition)); + return null; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenizerDefinitions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenizerDefinitions.g.cs index 5c1795b1393..36d142e5ce1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenizerDefinitions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenizerDefinitions.g.cs @@ -36,7 +36,7 @@ public TokenizerDefinitions(IDictionary container) { } - public void Add(string name, ITokenizerDefinition tokenizerDefinition) => BackingDictionary.Add(name, tokenizerDefinition); + public void Add(string name, ITokenizerDefinition tokenizerDefinition) => BackingDictionary.Add(Sanitize(name), tokenizerDefinition); } public sealed partial class TokenizerDefinitionsDescriptor : IsADictionaryDescriptor @@ -136,7 +136,8 @@ public override ITokenizerDefinition Read(ref Utf8JsonReader reader, Type typeTo case "char_group": return JsonSerializer.Deserialize(ref reader, options); default: - throw new JsonException("Encounted an unknown variant type which could not be deserialised."); + ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ITokenizerDefinition)); + return null; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AliasDefinition.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AliasDefinition.g.cs new file mode 100644 index 00000000000..589885090d8 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AliasDefinition.g.cs @@ -0,0 +1,313 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +#nullable restore +namespace Elastic.Clients.Elasticsearch.IndexManagement; +public sealed partial class AliasDefinition +{ + [JsonInclude] + [JsonPropertyName("filter")] + public Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? Filter { get; set; } + + [JsonInclude] + [JsonPropertyName("index_routing")] + public string? IndexRouting { get; set; } + + [JsonInclude] + [JsonPropertyName("is_hidden")] + public bool? IsHidden { get; set; } + + [JsonInclude] + [JsonPropertyName("is_write_index")] + public bool? IsWriteIndex { get; set; } + + [JsonInclude] + [JsonPropertyName("routing")] + public string? Routing { get; set; } + + [JsonInclude] + [JsonPropertyName("search_routing")] + public string? SearchRouting { get; set; } +} + +public sealed partial class AliasDefinitionDescriptor : SerializableDescriptor> +{ + internal AliasDefinitionDescriptor(Action> configure) => configure.Invoke(this); + public AliasDefinitionDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? FilterValue { get; set; } + + private QueryDsl.QueryContainerDescriptor FilterDescriptor { get; set; } + + private Action> FilterDescriptorAction { get; set; } + + private string? IndexRoutingValue { get; set; } + + private bool? IsHiddenValue { get; set; } + + private bool? IsWriteIndexValue { get; set; } + + private string? RoutingValue { get; set; } + + private string? SearchRoutingValue { get; set; } + + public AliasDefinitionDescriptor Filter(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? filter) + { + FilterDescriptor = null; + FilterDescriptorAction = null; + FilterValue = filter; + return Self; + } + + public AliasDefinitionDescriptor Filter(QueryDsl.QueryContainerDescriptor descriptor) + { + FilterValue = null; + FilterDescriptorAction = null; + FilterDescriptor = descriptor; + return Self; + } + + public AliasDefinitionDescriptor Filter(Action> configure) + { + FilterValue = null; + FilterDescriptor = null; + FilterDescriptorAction = configure; + return Self; + } + + public AliasDefinitionDescriptor IndexRouting(string? indexRouting) + { + IndexRoutingValue = indexRouting; + return Self; + } + + public AliasDefinitionDescriptor IsHidden(bool? isHidden = true) + { + IsHiddenValue = isHidden; + return Self; + } + + public AliasDefinitionDescriptor IsWriteIndex(bool? isWriteIndex = true) + { + IsWriteIndexValue = isWriteIndex; + return Self; + } + + public AliasDefinitionDescriptor Routing(string? routing) + { + RoutingValue = routing; + return Self; + } + + public AliasDefinitionDescriptor SearchRouting(string? searchRouting) + { + SearchRoutingValue = searchRouting; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (FilterDescriptor is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, FilterDescriptor, options); + } + else if (FilterDescriptorAction is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, new QueryDsl.QueryContainerDescriptor(FilterDescriptorAction), options); + } + else if (FilterValue is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, FilterValue, options); + } + + if (!string.IsNullOrEmpty(IndexRoutingValue)) + { + writer.WritePropertyName("index_routing"); + writer.WriteStringValue(IndexRoutingValue); + } + + if (IsHiddenValue.HasValue) + { + writer.WritePropertyName("is_hidden"); + writer.WriteBooleanValue(IsHiddenValue.Value); + } + + if (IsWriteIndexValue.HasValue) + { + writer.WritePropertyName("is_write_index"); + writer.WriteBooleanValue(IsWriteIndexValue.Value); + } + + if (!string.IsNullOrEmpty(RoutingValue)) + { + writer.WritePropertyName("routing"); + writer.WriteStringValue(RoutingValue); + } + + if (!string.IsNullOrEmpty(SearchRoutingValue)) + { + writer.WritePropertyName("search_routing"); + writer.WriteStringValue(SearchRoutingValue); + } + + writer.WriteEndObject(); + } +} + +public sealed partial class AliasDefinitionDescriptor : SerializableDescriptor +{ + internal AliasDefinitionDescriptor(Action configure) => configure.Invoke(this); + public AliasDefinitionDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? FilterValue { get; set; } + + private QueryDsl.QueryContainerDescriptor FilterDescriptor { get; set; } + + private Action FilterDescriptorAction { get; set; } + + private string? IndexRoutingValue { get; set; } + + private bool? IsHiddenValue { get; set; } + + private bool? IsWriteIndexValue { get; set; } + + private string? RoutingValue { get; set; } + + private string? SearchRoutingValue { get; set; } + + public AliasDefinitionDescriptor Filter(Elastic.Clients.Elasticsearch.QueryDsl.QueryContainer? filter) + { + FilterDescriptor = null; + FilterDescriptorAction = null; + FilterValue = filter; + return Self; + } + + public AliasDefinitionDescriptor Filter(QueryDsl.QueryContainerDescriptor descriptor) + { + FilterValue = null; + FilterDescriptorAction = null; + FilterDescriptor = descriptor; + return Self; + } + + public AliasDefinitionDescriptor Filter(Action configure) + { + FilterValue = null; + FilterDescriptor = null; + FilterDescriptorAction = configure; + return Self; + } + + public AliasDefinitionDescriptor IndexRouting(string? indexRouting) + { + IndexRoutingValue = indexRouting; + return Self; + } + + public AliasDefinitionDescriptor IsHidden(bool? isHidden = true) + { + IsHiddenValue = isHidden; + return Self; + } + + public AliasDefinitionDescriptor IsWriteIndex(bool? isWriteIndex = true) + { + IsWriteIndexValue = isWriteIndex; + return Self; + } + + public AliasDefinitionDescriptor Routing(string? routing) + { + RoutingValue = routing; + return Self; + } + + public AliasDefinitionDescriptor SearchRouting(string? searchRouting) + { + SearchRoutingValue = searchRouting; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (FilterDescriptor is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, FilterDescriptor, options); + } + else if (FilterDescriptorAction is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, new QueryDsl.QueryContainerDescriptor(FilterDescriptorAction), options); + } + else if (FilterValue is not null) + { + writer.WritePropertyName("filter"); + JsonSerializer.Serialize(writer, FilterValue, options); + } + + if (!string.IsNullOrEmpty(IndexRoutingValue)) + { + writer.WritePropertyName("index_routing"); + writer.WriteStringValue(IndexRoutingValue); + } + + if (IsHiddenValue.HasValue) + { + writer.WritePropertyName("is_hidden"); + writer.WriteBooleanValue(IsHiddenValue.Value); + } + + if (IsWriteIndexValue.HasValue) + { + writer.WritePropertyName("is_write_index"); + writer.WriteBooleanValue(IsWriteIndexValue.Value); + } + + if (!string.IsNullOrEmpty(RoutingValue)) + { + writer.WritePropertyName("routing"); + writer.WriteStringValue(RoutingValue); + } + + if (!string.IsNullOrEmpty(SearchRoutingValue)) + { + writer.WritePropertyName("search_routing"); + writer.WriteStringValue(SearchRoutingValue); + } + + writer.WriteEndObject(); + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SettingsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexAliases.g.cs similarity index 83% rename from src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SettingsResponse.g.cs rename to src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexAliases.g.cs index 327e396e9f5..a6f7790f7c8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SettingsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexAliases.g.cs @@ -17,12 +17,17 @@ using Elastic.Clients.Elasticsearch.Fluent; using Elastic.Clients.Elasticsearch.Serialization; -using Elastic.Transport.Products.Elasticsearch; +using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; #nullable restore namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed partial class SettingsResponse : ElasticsearchResponseBase +public sealed partial class IndexAliases { + [JsonInclude] + [JsonPropertyName("aliases")] + public Dictionary Aliases { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexMappingRecord.g.cs similarity index 79% rename from src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamResponse.g.cs rename to src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexMappingRecord.g.cs index bba17288677..df27ffb14c1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexMappingRecord.g.cs @@ -17,12 +17,21 @@ using Elastic.Clients.Elasticsearch.Fluent; using Elastic.Clients.Elasticsearch.Serialization; -using Elastic.Transport.Products.Elasticsearch; +using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; #nullable restore namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed partial class PromoteDataStreamResponse : ElasticsearchResponseBase +public sealed partial class IndexMappingRecord { + [JsonInclude] + [JsonPropertyName("item")] + public Elastic.Clients.Elasticsearch.Mapping.TypeMapping? Item { get; init; } + + [JsonInclude] + [JsonPropertyName("mappings")] + public Elastic.Clients.Elasticsearch.Mapping.TypeMapping Mappings { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexState.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexState.g.cs new file mode 100644 index 00000000000..57b59a3b066 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexState.g.cs @@ -0,0 +1,409 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +#nullable restore +namespace Elastic.Clients.Elasticsearch.IndexManagement; +public sealed partial class IndexState +{ + [JsonInclude] + [JsonPropertyName("aliases")] + public Dictionary? Aliases { get; set; } + + [JsonInclude] + [JsonPropertyName("data_stream")] + public Elastic.Clients.Elasticsearch.DataStreamName? DataStream { get; set; } + + [JsonInclude] + [JsonPropertyName("defaults")] + public Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? Defaults { get; set; } + + [JsonInclude] + [JsonPropertyName("mappings")] + public Elastic.Clients.Elasticsearch.Mapping.TypeMapping? Mappings { get; set; } + + [JsonInclude] + [JsonPropertyName("settings")] + public Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? Settings { get; set; } +} + +public sealed partial class IndexStateDescriptor : SerializableDescriptor> +{ + internal IndexStateDescriptor(Action> configure) => configure.Invoke(this); + public IndexStateDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? DefaultsValue { get; set; } + + private IndexSettingsDescriptor DefaultsDescriptor { get; set; } + + private Action> DefaultsDescriptorAction { get; set; } + + private Elastic.Clients.Elasticsearch.Mapping.TypeMapping? MappingsValue { get; set; } + + private Mapping.TypeMappingDescriptor MappingsDescriptor { get; set; } + + private Action> MappingsDescriptorAction { get; set; } + + private Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? SettingsValue { get; set; } + + private IndexSettingsDescriptor SettingsDescriptor { get; set; } + + private Action> SettingsDescriptorAction { get; set; } + + private Dictionary? AliasesValue { get; set; } + + private Elastic.Clients.Elasticsearch.DataStreamName? DataStreamValue { get; set; } + + public IndexStateDescriptor Defaults(Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? defaults) + { + DefaultsDescriptor = null; + DefaultsDescriptorAction = null; + DefaultsValue = defaults; + return Self; + } + + public IndexStateDescriptor Defaults(IndexSettingsDescriptor descriptor) + { + DefaultsValue = null; + DefaultsDescriptorAction = null; + DefaultsDescriptor = descriptor; + return Self; + } + + public IndexStateDescriptor Defaults(Action> configure) + { + DefaultsValue = null; + DefaultsDescriptor = null; + DefaultsDescriptorAction = configure; + return Self; + } + + public IndexStateDescriptor Mappings(Elastic.Clients.Elasticsearch.Mapping.TypeMapping? mappings) + { + MappingsDescriptor = null; + MappingsDescriptorAction = null; + MappingsValue = mappings; + return Self; + } + + public IndexStateDescriptor Mappings(Mapping.TypeMappingDescriptor descriptor) + { + MappingsValue = null; + MappingsDescriptorAction = null; + MappingsDescriptor = descriptor; + return Self; + } + + public IndexStateDescriptor Mappings(Action> configure) + { + MappingsValue = null; + MappingsDescriptor = null; + MappingsDescriptorAction = configure; + return Self; + } + + public IndexStateDescriptor Settings(Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? settings) + { + SettingsDescriptor = null; + SettingsDescriptorAction = null; + SettingsValue = settings; + return Self; + } + + public IndexStateDescriptor Settings(IndexSettingsDescriptor descriptor) + { + SettingsValue = null; + SettingsDescriptorAction = null; + SettingsDescriptor = descriptor; + return Self; + } + + public IndexStateDescriptor Settings(Action> configure) + { + SettingsValue = null; + SettingsDescriptor = null; + SettingsDescriptorAction = configure; + return Self; + } + + public IndexStateDescriptor Aliases(Func, FluentDictionary> selector) + { + AliasesValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + public IndexStateDescriptor DataStream(Elastic.Clients.Elasticsearch.DataStreamName? dataStream) + { + DataStreamValue = dataStream; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (DefaultsDescriptor is not null) + { + writer.WritePropertyName("defaults"); + JsonSerializer.Serialize(writer, DefaultsDescriptor, options); + } + else if (DefaultsDescriptorAction is not null) + { + writer.WritePropertyName("defaults"); + JsonSerializer.Serialize(writer, new IndexSettingsDescriptor(DefaultsDescriptorAction), options); + } + else if (DefaultsValue is not null) + { + writer.WritePropertyName("defaults"); + JsonSerializer.Serialize(writer, DefaultsValue, options); + } + + if (MappingsDescriptor is not null) + { + writer.WritePropertyName("mappings"); + JsonSerializer.Serialize(writer, MappingsDescriptor, options); + } + else if (MappingsDescriptorAction is not null) + { + writer.WritePropertyName("mappings"); + JsonSerializer.Serialize(writer, new Mapping.TypeMappingDescriptor(MappingsDescriptorAction), options); + } + else if (MappingsValue is not null) + { + writer.WritePropertyName("mappings"); + JsonSerializer.Serialize(writer, MappingsValue, options); + } + + if (SettingsDescriptor is not null) + { + writer.WritePropertyName("settings"); + JsonSerializer.Serialize(writer, SettingsDescriptor, options); + } + else if (SettingsDescriptorAction is not null) + { + writer.WritePropertyName("settings"); + JsonSerializer.Serialize(writer, new IndexSettingsDescriptor(SettingsDescriptorAction), options); + } + else if (SettingsValue is not null) + { + writer.WritePropertyName("settings"); + JsonSerializer.Serialize(writer, SettingsValue, options); + } + + if (AliasesValue is not null) + { + writer.WritePropertyName("aliases"); + JsonSerializer.Serialize(writer, AliasesValue, options); + } + + if (DataStreamValue is not null) + { + writer.WritePropertyName("data_stream"); + JsonSerializer.Serialize(writer, DataStreamValue, options); + } + + writer.WriteEndObject(); + } +} + +public sealed partial class IndexStateDescriptor : SerializableDescriptor +{ + internal IndexStateDescriptor(Action configure) => configure.Invoke(this); + public IndexStateDescriptor() : base() + { + } + + private Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? DefaultsValue { get; set; } + + private IndexSettingsDescriptor DefaultsDescriptor { get; set; } + + private Action DefaultsDescriptorAction { get; set; } + + private Elastic.Clients.Elasticsearch.Mapping.TypeMapping? MappingsValue { get; set; } + + private Mapping.TypeMappingDescriptor MappingsDescriptor { get; set; } + + private Action MappingsDescriptorAction { get; set; } + + private Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? SettingsValue { get; set; } + + private IndexSettingsDescriptor SettingsDescriptor { get; set; } + + private Action SettingsDescriptorAction { get; set; } + + private Dictionary? AliasesValue { get; set; } + + private Elastic.Clients.Elasticsearch.DataStreamName? DataStreamValue { get; set; } + + public IndexStateDescriptor Defaults(Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? defaults) + { + DefaultsDescriptor = null; + DefaultsDescriptorAction = null; + DefaultsValue = defaults; + return Self; + } + + public IndexStateDescriptor Defaults(IndexSettingsDescriptor descriptor) + { + DefaultsValue = null; + DefaultsDescriptorAction = null; + DefaultsDescriptor = descriptor; + return Self; + } + + public IndexStateDescriptor Defaults(Action configure) + { + DefaultsValue = null; + DefaultsDescriptor = null; + DefaultsDescriptorAction = configure; + return Self; + } + + public IndexStateDescriptor Mappings(Elastic.Clients.Elasticsearch.Mapping.TypeMapping? mappings) + { + MappingsDescriptor = null; + MappingsDescriptorAction = null; + MappingsValue = mappings; + return Self; + } + + public IndexStateDescriptor Mappings(Mapping.TypeMappingDescriptor descriptor) + { + MappingsValue = null; + MappingsDescriptorAction = null; + MappingsDescriptor = descriptor; + return Self; + } + + public IndexStateDescriptor Mappings(Action configure) + { + MappingsValue = null; + MappingsDescriptor = null; + MappingsDescriptorAction = configure; + return Self; + } + + public IndexStateDescriptor Settings(Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? settings) + { + SettingsDescriptor = null; + SettingsDescriptorAction = null; + SettingsValue = settings; + return Self; + } + + public IndexStateDescriptor Settings(IndexSettingsDescriptor descriptor) + { + SettingsValue = null; + SettingsDescriptorAction = null; + SettingsDescriptor = descriptor; + return Self; + } + + public IndexStateDescriptor Settings(Action configure) + { + SettingsValue = null; + SettingsDescriptor = null; + SettingsDescriptorAction = configure; + return Self; + } + + public IndexStateDescriptor Aliases(Func, FluentDictionary> selector) + { + AliasesValue = selector?.Invoke(new FluentDictionary()); + return Self; + } + + public IndexStateDescriptor DataStream(Elastic.Clients.Elasticsearch.DataStreamName? dataStream) + { + DataStreamValue = dataStream; + return Self; + } + + protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + writer.WriteStartObject(); + if (DefaultsDescriptor is not null) + { + writer.WritePropertyName("defaults"); + JsonSerializer.Serialize(writer, DefaultsDescriptor, options); + } + else if (DefaultsDescriptorAction is not null) + { + writer.WritePropertyName("defaults"); + JsonSerializer.Serialize(writer, new IndexSettingsDescriptor(DefaultsDescriptorAction), options); + } + else if (DefaultsValue is not null) + { + writer.WritePropertyName("defaults"); + JsonSerializer.Serialize(writer, DefaultsValue, options); + } + + if (MappingsDescriptor is not null) + { + writer.WritePropertyName("mappings"); + JsonSerializer.Serialize(writer, MappingsDescriptor, options); + } + else if (MappingsDescriptorAction is not null) + { + writer.WritePropertyName("mappings"); + JsonSerializer.Serialize(writer, new Mapping.TypeMappingDescriptor(MappingsDescriptorAction), options); + } + else if (MappingsValue is not null) + { + writer.WritePropertyName("mappings"); + JsonSerializer.Serialize(writer, MappingsValue, options); + } + + if (SettingsDescriptor is not null) + { + writer.WritePropertyName("settings"); + JsonSerializer.Serialize(writer, SettingsDescriptor, options); + } + else if (SettingsDescriptorAction is not null) + { + writer.WritePropertyName("settings"); + JsonSerializer.Serialize(writer, new IndexSettingsDescriptor(SettingsDescriptorAction), options); + } + else if (SettingsValue is not null) + { + writer.WritePropertyName("settings"); + JsonSerializer.Serialize(writer, SettingsValue, options); + } + + if (AliasesValue is not null) + { + writer.WritePropertyName("aliases"); + JsonSerializer.Serialize(writer, AliasesValue, options); + } + + if (DataStreamValue is not null) + { + writer.WritePropertyName("data_stream"); + JsonSerializer.Serialize(writer, DataStreamValue, options); + } + + writer.WriteEndObject(); + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs new file mode 100644 index 00000000000..be9dd2418df --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs @@ -0,0 +1,53 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +#nullable restore +namespace Elastic.Clients.Elasticsearch.IndexManagement; +public sealed partial class TemplateMapping +{ + [JsonInclude] + [JsonPropertyName("aliases")] + public Dictionary Aliases { get; init; } + + [JsonInclude] + [JsonPropertyName("index_patterns")] + public IReadOnlyCollection IndexPatterns { get; init; } + + [JsonInclude] + [JsonPropertyName("mappings")] + public Elastic.Clients.Elasticsearch.Mapping.TypeMapping Mappings { get; init; } + + [JsonInclude] + [JsonPropertyName("order")] + public int Order { get; init; } + + [JsonInclude] + [JsonPropertyName("settings")] + public Dictionary Settings { get; init; } + + [JsonInclude] + [JsonPropertyName("version")] + public long? Version { get; init; } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs similarity index 82% rename from src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryResponse.g.cs rename to src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs index 0583a4fa8fd..08d509d9060 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs @@ -17,12 +17,17 @@ using Elastic.Clients.Elasticsearch.Fluent; using Elastic.Clients.Elasticsearch.Serialization; -using Elastic.Transport.Products.Elasticsearch; +using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; #nullable restore namespace Elastic.Clients.Elasticsearch.IndexManagement; -public sealed partial class RecoveryResponse : ElasticsearchResponseBase +public sealed partial class TypeFieldMappings { + [JsonInclude] + [JsonPropertyName("mappings")] + public Dictionary Mappings { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FieldMapping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FieldMapping.g.cs new file mode 100644 index 00000000000..70405092dc6 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FieldMapping.g.cs @@ -0,0 +1,37 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +#nullable restore +namespace Elastic.Clients.Elasticsearch.Mapping; +public sealed partial class FieldMapping +{ + [JsonInclude] + [JsonPropertyName("full_name")] + public string FullName { get; init; } + + [JsonInclude] + [JsonPropertyName("mapping")] + public Elastic.Clients.Elasticsearch.Mapping.Properties Mapping { get; init; } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs index c484a55ab38..8939caf0b9f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs @@ -36,7 +36,7 @@ public Properties(IDictionary container) : base(contain { } - public void Add(PropertyName propertyName, IProperty property) => BackingDictionary.Add(propertyName, property); + public void Add(PropertyName propertyName, IProperty property) => BackingDictionary.Add(Sanitize(propertyName), property); } public sealed partial class PropertiesDescriptor : IsADictionaryDescriptor, Properties, PropertyName, IProperty> @@ -387,8 +387,11 @@ public override IProperty Read(ref Utf8JsonReader reader, Type typeToConvert, Js return JsonSerializer.Deserialize(ref reader, options); case "binary": return JsonSerializer.Deserialize(ref reader, options); + case null: + return JsonSerializer.Deserialize(ref reader, options); default: - throw new JsonException("Encounted an unknown variant type which could not be deserialised."); + ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(IProperty)); + return null; } } diff --git a/tests/Tests.ClusterLauncher/ClusterLaunchProgram.cs b/tests/Tests.ClusterLauncher/ClusterLaunchProgram.cs index 871fe86c04a..5ef07a77451 100644 --- a/tests/Tests.ClusterLauncher/ClusterLaunchProgram.cs +++ b/tests/Tests.ClusterLauncher/ClusterLaunchProgram.cs @@ -66,7 +66,7 @@ public static int Main(string[] arguments) try { - if (TryStartClientTestClusterBaseImplementation(cluster) || TryStartXPackClusterImplementation(cluster)) return 0; + if (TryStartClientTestClusterBaseImplementation(cluster)) return 0; Console.Error.WriteLine($"Could not create an instance of '{cluster.FullName}"); return 1; @@ -79,21 +79,12 @@ public static int Main(string[] arguments) } } - private static bool TryStartXPackClusterImplementation(Type cluster) - { - if (!(Activator.CreateInstance(cluster) is XPackCluster instance)) return false; - - Instance = instance; - using (instance) - return Run(instance); - } - - private static bool TryStartClientTestClusterBaseImplementation(Type cluster) { - if (!(Activator.CreateInstance(cluster) is ClientTestClusterBase instance)) return false; + if (Activator.CreateInstance(cluster) is not ClientTestClusterBase instance) return false; Instance = instance; + using (instance) return Run(instance); } diff --git a/tests/Tests.Core/ManagedElasticsearch/Clusters/Security.cs b/tests/Tests.Core/ManagedElasticsearch/Clusters/Security.cs deleted file mode 100644 index 2354cd996d4..00000000000 --- a/tests/Tests.Core/ManagedElasticsearch/Clusters/Security.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -namespace Tests.Core.ManagedElasticsearch.Clusters -{ - /// - /// An isolated cluster suitable for testing security APIs. - /// - public class SecurityCluster : XPackCluster - { - } -} diff --git a/tests/Tests.Core/ManagedElasticsearch/Clusters/TimeSeriesCluster.cs b/tests/Tests.Core/ManagedElasticsearch/Clusters/TimeSeriesCluster.cs deleted file mode 100644 index 0156d0356d1..00000000000 --- a/tests/Tests.Core/ManagedElasticsearch/Clusters/TimeSeriesCluster.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using Tests.Core.ManagedElasticsearch.NodeSeeders; - -namespace Tests.Core.ManagedElasticsearch.Clusters; - -public class TimeSeriesCluster : ReadOnlyCluster -{ - protected override void SeedNode() => new TimeSeriesSeeder(Client).SeedNode(); -} diff --git a/tests/Tests.Core/ManagedElasticsearch/Clusters/UnbalancedCluster.cs b/tests/Tests.Core/ManagedElasticsearch/Clusters/UnbalancedCluster.cs deleted file mode 100644 index e23790ccab4..00000000000 --- a/tests/Tests.Core/ManagedElasticsearch/Clusters/UnbalancedCluster.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System.Net.Http; - -namespace Tests.Core.ManagedElasticsearch.Clusters -{ - //TODO does this need a whole separate cluster? Re-use read-only? - public class UnbalancedCluster : ClientTestClusterBase - { - //protected override void SeedNode() => - // new DefaultSeeder(Client, new IndexSettings { NumberOfShards = 3, NumberOfReplicas = 2 }) - // .SeedNode(); - - protected override void SeedNode() - { - // TODO: Very, very temporary! - - var client = new HttpClient(); - client.PutAsync("http://127.0.0.1:9200/project", new StringContent(string.Empty)).GetAwaiter().GetResult(); - } - } -} diff --git a/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs b/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs deleted file mode 100644 index df103b83bf9..00000000000 --- a/tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to Elasticsearch B.V under one or more agreements. -// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using Elastic.Elasticsearch.Ephemeral; -using Elastic.Elasticsearch.Xunit; -using Elastic.Transport; -using Elastic.Clients.Elasticsearch; -using Elastic.Clients.Elasticsearch.Cluster; -using Tests.Core.Extensions; -using Tests.Core.ManagedElasticsearch.NodeSeeders; -using Tests.Core.ManagedElasticsearch.Tasks; -using Tests.Domain.Extensions; -using static Elastic.Stack.ArtifactsApi.Products.ElasticsearchPlugin; - -namespace Tests.Core.ManagedElasticsearch.Clusters -{ - public class XPackCluster : XunitClusterBase, ITestCluster - { - public XPackCluster() : this(new XPackClusterConfiguration()) { } - - public XPackCluster(XPackClusterConfiguration configuration) : base(configuration) { } - - public virtual ElasticsearchClient Client => - this.GetOrAddClient(s => Authenticate(ConnectionSettings(s.ApplyDomainSettings()))); - - protected virtual ElasticsearchClientSettings Authenticate(ElasticsearchClientSettings s) => s - .Authentication(new BasicAuthentication(ClusterAuthentication.Admin.Username, - ClusterAuthentication.Admin.Password)); - - protected virtual ElasticsearchClientSettings ConnectionSettings(ElasticsearchClientSettings s) => s - .ServerCertificateValidationCallback(CertificateValidations.AllowAll); - - protected sealed override void SeedCluster() - { - Client.Cluster.Health(new ClusterHealthRequest {WaitForStatus = HealthStatus.Green}); - //Client.WaitForSecurityIndices(); - SeedNode(); - Client.Cluster.Health(new ClusterHealthRequest { WaitForStatus = HealthStatus.Green}); - //Client.WaitForSecurityIndices(); - } - - protected virtual void SeedNode() => new DefaultSeeder(Client).SeedNode(); - } - - public class XPackClusterConfiguration : ClientTestClusterConfiguration - { - public XPackClusterConfiguration() : this(ClusterFeatures.SSL | ClusterFeatures.Security) { } - - public XPackClusterConfiguration(ClusterFeatures features) : base(ClusterFeatures.XPack | features, 1, - IngestAttachment) - { - var isSnapshot = !string.IsNullOrEmpty(Version.PreRelease) && - Version.PreRelease.ToLower().Contains("snapshot"); - // Get license file path from environment variable - var licenseFilePath = Environment.GetEnvironmentVariable("ES_LICENSE_FILE"); - if (!isSnapshot && !string.IsNullOrEmpty(licenseFilePath) && File.Exists(licenseFilePath)) - { - var licenseContents = File.ReadAllText(licenseFilePath); - XPackLicenseJson = licenseContents; - } - - TrialMode = XPackTrialMode.Trial; - AdditionalBeforeNodeStartedTasks.Add(new EnsureWatcherActionConfigurationInElasticsearchYaml()); - AdditionalBeforeNodeStartedTasks.Add(new EnsureWatcherActionConfigurationSecretsInKeystore()); - AdditionalBeforeNodeStartedTasks.Add(new EnsureNativeSecurityRealmEnabledInElasticsearchYaml()); - ShowElasticsearchOutputAfterStarted = true; //this.TestConfiguration.ShowElasticsearchOutputAfterStarted; - } - } -} diff --git a/tests/Tests/AsyncSearch/AsyncSearchApiTests.cs b/tests/Tests/AsyncSearch/AsyncSearchApiCoordinatedTests.cs similarity index 96% rename from tests/Tests/AsyncSearch/AsyncSearchApiTests.cs rename to tests/Tests/AsyncSearch/AsyncSearchApiCoordinatedTests.cs index ac125e1be36..178d88f7830 100644 --- a/tests/Tests/AsyncSearch/AsyncSearchApiTests.cs +++ b/tests/Tests/AsyncSearch/AsyncSearchApiCoordinatedTests.cs @@ -17,14 +17,14 @@ namespace Tests.AsyncSearch; -public class AsyncSearchApiTests : CoordinatedIntegrationTestBase +public class AsyncSearchApiCoordinatedTests : CoordinatedIntegrationTestBase { private const string SubmitStep = nameof(SubmitStep); private const string StatusStep = nameof(StatusStep); private const string GetStep = nameof(GetStep); private const string DeleteStep = nameof(DeleteStep); - public AsyncSearchApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(new CoordinatedUsage(cluster, usage) + public AsyncSearchApiCoordinatedTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(new CoordinatedUsage(cluster, usage) { { SubmitStep, u => diff --git a/tests/Tests/Document/Multiple/DeleteByQuery/DeleteByQueryApiTests.cs b/tests/Tests/Document/Multiple/DeleteByQuery/DeleteByQueryApiTests.cs index c74c09ddffe..6c4f4792c30 100644 --- a/tests/Tests/Document/Multiple/DeleteByQuery/DeleteByQueryApiTests.cs +++ b/tests/Tests/Document/Multiple/DeleteByQuery/DeleteByQueryApiTests.cs @@ -140,7 +140,7 @@ public DeleteByQueryWaitForCompletionApiTests(IntrusiveOperationCluster cluster, protected override string ExpectedUrlPathAndQuery => $"/{CallIsolatedValue}/_delete_by_query?wait_for_completion=false&conflicts=proceed"; - protected override DeleteByQueryRequestDescriptor NewDescriptor() => new (CallIsolatedValue); + protected override DeleteByQueryRequestDescriptor NewDescriptor() => new(CallIsolatedValue); protected override void ExpectResponse(DeleteByQueryResponse response) { diff --git a/tests/Tests/IndexManagement/Mapping/GetMappingApiTests.cs b/tests/Tests/IndexManagement/Mapping/GetMappingApiTests.cs new file mode 100644 index 00000000000..062be3c4e34 --- /dev/null +++ b/tests/Tests/IndexManagement/Mapping/GetMappingApiTests.cs @@ -0,0 +1,82 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using Tests.Core.ManagedElasticsearch.Clusters; +using Tests.Framework.EndpointTests.TestState; +using Tests.Framework.EndpointTests; +using Elastic.Clients.Elasticsearch.IndexManagement; +using System; +using Tests.Domain; + +namespace Tests.IndexManagement.Mapping; + +public class GetMappingApiTests : ApiIntegrationTestBase, MappingRequest> +{ + public GetMappingApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override bool ExpectIsValid => true; + protected override int ExpectStatusCode => 200; + protected override string ExpectedUrlPathAndQuery => "/project/_mapping?ignore_unavailable=true"; + protected override HttpMethod HttpMethod => HttpMethod.GET; + protected override Action> Fluent => c => c.Indices(Infer.Index()).IgnoreUnavailable(); + protected override MappingRequest Initializer => new(Infer.Index()) { IgnoreUnavailable = true }; + + protected override LazyResponses ClientUsage() => Calls( + (client, f) => client.Indices.GetMapping(f), + (client, f) => client.Indices.GetMappingAsync(f), + (client, r) => client.Indices.GetMapping(r), + (client, r) => client.Indices.GetMappingAsync(r) + ); + + protected override void ExpectResponse(MappingResponse response) + { + var projectMapping = response.Indices[Infer.Index()]; + + projectMapping.Should().NotBeNull(); + + var properties = projectMapping.Mappings.Properties; + + var leadDev = properties[Infer.Property(p => p.LeadDeveloper)]; + leadDev.Should().NotBeNull(); + + var props = response.Indices["x"]?.Mappings.Properties; + props.Should().BeNull(); + + AssertExtensionMethods(response); + } + + private static void AssertExtensionMethods(MappingResponse response) + { + /** The `GetMappingFor` extension method can be used to get a type mapping easily and safely */ + response.GetMappingFor().Should().NotBeNull(); + response.GetMappingFor(typeof(Project)).Should().NotBeNull(); + } +} + +public class GetMappingNonExistentIndexApiTests : ApiIntegrationTestBase, MappingRequest> +{ + private const string NonExistentIndex = "non-existent-index"; + + public GetMappingNonExistentIndexApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override bool ExpectIsValid => false; + protected override int ExpectStatusCode => 404; + protected override string ExpectedUrlPathAndQuery => $"/{NonExistentIndex}/_mapping"; + protected override HttpMethod HttpMethod => HttpMethod.GET; + protected override Action> Fluent => c => c.Indices(NonExistentIndex); + protected override MappingRequest Initializer => new(NonExistentIndex); + + protected override LazyResponses ClientUsage() => Calls( + (client, f) => client.Indices.GetMapping(f), + (client, f) => client.Indices.GetMappingAsync(f), + (client, r) => client.Indices.GetMapping(r), + (client, r) => client.Indices.GetMappingAsync(r) + ); + + protected override void ExpectResponse(MappingResponse response) + { + response.Indices.Should().BeEmpty(); + response.ServerError.Should().NotBeNull(); + } +} diff --git a/tests/Tests/Serialization/Mapping/MappingResponseSerializationTests.cs b/tests/Tests/Serialization/Mapping/MappingResponseSerializationTests.cs new file mode 100644 index 00000000000..b500d883b59 --- /dev/null +++ b/tests/Tests/Serialization/Mapping/MappingResponseSerializationTests.cs @@ -0,0 +1,19 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using Elastic.Clients.Elasticsearch.IndexManagement; + +namespace Tests.Serialization.Mapping; + +public class MappingResponseSerializationTests : SerializerTestBase +{ + private const string ResponseJson = @"{""project"":{""mappings"":{""_routing"":{""required"":true},""properties"":{""dateString"":{""type"":""date""}}}}}"; + + [U] + public void CanDeserialize_MappingResponse() + { + var reponse = DeserializeJsonString(ResponseJson); + reponse.Indices["project"].Mappings.Properties["dateString"].Type.Should().Be("date"); + } +}