From 6f7e995e625a4506455272dd5b37f016f6241143 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Thu, 5 Sep 2024 10:24:28 +0200 Subject: [PATCH] Fix `Slices` url parameter serialization (#8327) --- .../Types/Slices.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/Elastic.Clients.Elasticsearch.Shared/Types/Slices.cs diff --git a/src/Elastic.Clients.Elasticsearch.Shared/Types/Slices.cs b/src/Elastic.Clients.Elasticsearch.Shared/Types/Slices.cs new file mode 100644 index 00000000000..42fcbaa2879 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch.Shared/Types/Slices.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; +using System.Globalization; + +using Elastic.Transport; + +#if ELASTICSEARCH_SERVERLESS +namespace Elastic.Clients.Elasticsearch.Serverless; +#else +namespace Elastic.Clients.Elasticsearch; +#endif + +public partial class Slices : + IUrlParameter +{ + public string GetString(ITransportConfiguration settings) => + Tag switch + { + 0 => Item1.ToString(CultureInfo.InvariantCulture), + 1 => UrlFormatter.CreateString(Item2, settings)!, + _ => throw new InvalidOperationException() + }; +}