From 7eedc009e05c706f2554a1a27a92fc382bac5126 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 13 Nov 2023 20:27:05 +1300 Subject: [PATCH] Add support for component template APIs (#411) * Generate `cluster.put_component_template` Signed-off-by: Thomas Farr * Implement high-level DeleteComponentTemplate Signed-off-by: Thomas Farr * Implement high-level ComponentTemplateExists Signed-off-by: Thomas Farr * Fix license Signed-off-by: Thomas Farr * Remove old put_component_template Signed-off-by: Thomas Farr * Implement high-level GetComponentTemplate Signed-off-by: Thomas Farr * Add tests for ComponentTemplateExists Signed-off-by: Thomas Farr * Add tests for DeleteComponentTemplate Signed-off-by: Thomas Farr * Add tests for GetComponentTemplate Signed-off-by: Thomas Farr * Implement high-level PutComponentTemplate Signed-off-by: Thomas Farr * Add component template CRUD tests Signed-off-by: Thomas Farr * Add naming convention exception for ComponentTemplateExists Signed-off-by: Thomas Farr * Update guide Signed-off-by: Thomas Farr * Formatting Signed-off-by: Thomas Farr * Add changelog entry Signed-off-by: Thomas Farr * Fix license header Signed-off-by: Thomas Farr * Fix namespaces Signed-off-by: Thomas Farr * Fix license header Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr --- CHANGELOG.md | 1 + guides/index-template.md | 34 ++- .../Configuration/CodeConfiguration.cs | 5 +- .../ComponentTemplate/ComponentTemplate.cs | 73 ++++++ .../ComponentTemplateExistsRequest.cs | 15 ++ .../DeleteComponentTemplateRequest.cs | 15 ++ .../DeleteComponentTemplateResponse.cs | 13 + .../GetComponentTemplateRequest.cs | 15 ++ .../GetComponentTemplateResponse.cs | 28 +++ .../PutComponentTemplateRequest.cs | 38 +++ .../PutComponentTemplateResponse.cs | 13 + .../IndicesExists/ExistsResponse.cs | 11 +- .../_Generated/ApiUrlsLookup.cs | 12 + .../_Generated/Descriptors.Cluster.cs | 172 +++++++++++++ .../_Generated/OpenSearchClient.Cluster.cs | 224 +++++++++++++++++ .../_Generated/Requests.Cluster.cs | 234 ++++++++++++++++++ .../RequestParameters.Cluster.cs | 36 --- .../OpenSearchLowLevelClient.Cluster.cs | 13 - .../RequestParameters.Cluster.cs | 46 +++- .../OpenSearchLowLevelClient.Cluster.cs | 45 +++- .../ComponentTemplateCrudTests.cs | 139 +++++++++++ .../ComponentTemplateExistsApiTests.cs | 37 +++ .../ComponentTemplateExistsUrlTests.cs | 28 +++ .../DeleteComponentTemplateApiTests.cs | 36 +++ .../DeleteComponentTemplateUrlTests.cs | 28 +++ .../GetComponentTemplateApiTests.cs | 74 ++++++ .../GetComponentTemplateUrlTests.cs | 35 +++ .../PutComponentTemplateApiTests.cs | 115 +++++++++ .../PutComponentTemplateUrlTests.cs | 28 +++ .../CodeStandards/NamingConventions.doc.cs | 1 + tests/Tests/Tests.csproj | 1 + 31 files changed, 1481 insertions(+), 84 deletions(-) create mode 100644 src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplate.cs create mode 100644 src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplateExistsRequest.cs create mode 100644 src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateRequest.cs create mode 100644 src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateResponse.cs create mode 100644 src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateRequest.cs create mode 100644 src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateResponse.cs create mode 100644 src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateRequest.cs create mode 100644 src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateResponse.cs create mode 100644 tests/Tests/Cluster/ComponentTemplate/ComponentTemplateCrudTests.cs create mode 100644 tests/Tests/Cluster/ComponentTemplate/ComponentTemplateExistsApiTests.cs create mode 100644 tests/Tests/Cluster/ComponentTemplate/ComponentTemplateExistsUrlTests.cs create mode 100644 tests/Tests/Cluster/ComponentTemplate/DeleteComponentTemplateApiTests.cs create mode 100644 tests/Tests/Cluster/ComponentTemplate/DeleteComponentTemplateUrlTests.cs create mode 100644 tests/Tests/Cluster/ComponentTemplate/GetComponentTemplateApiTests.cs create mode 100644 tests/Tests/Cluster/ComponentTemplate/GetComponentTemplateUrlTests.cs create mode 100644 tests/Tests/Cluster/ComponentTemplate/PutComponentTemplateApiTests.cs create mode 100644 tests/Tests/Cluster/ComponentTemplate/PutComponentTemplateUrlTests.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c1d85bd87..8bf530af7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Added - Added support for point-in-time search and associated APIs ([#405](https://github.com/opensearch-project/opensearch-net/pull/405)) +- Added support for the component template APIs ([#411](https://github.com/opensearch-project/opensearch-net/pull/411)) ### Removed - Removed the `Features` API which is not supported by OpenSearch from the low-level client ([#331](https://github.com/opensearch-project/opensearch-net/pull/331)) diff --git a/guides/index-template.md b/guides/index-template.md index 3c843debd4..96fe338803 100644 --- a/guides/index-template.md +++ b/guides/index-template.md @@ -116,22 +116,19 @@ Composable index templates are a new type of index template that allow you to de ```csharp // Create a component template -var createResponse = client.LowLevel.Cluster.PutComponentTemplate("books_mappings", PostData.Serializable(new -{ - template = new - { - mappings = new - { - properties = new - { - title = new { type = "text" }, - author = new { type = "text" }, - published_on = new { type = "date" }, - pages = new { type = "integer" } - } - } - } -})); +client.Cluster.PutComponentTemplate("books_mappings", ct => ct + .Template(t => t + .Map(m => m + .Properties(p => p + .Text(tp => tp + .Name("title")) + .Text(tp => tp + .Name("author")) + .Date(d => d + .Name("published_on")) + .Number(n => n + .Name("pages") + .Type(NumberType.Integer)))))); // Create an index template for "books" var createBooksTemplateResponse = client.LowLevel.Indices.PutTemplateV2ForAll("books", PostData.Serializable(new @@ -178,7 +175,6 @@ When we create an index named `books-fiction-horror`, OpenSearch will apply the client.Indices.Create("books-fiction-horror"); var getResponse = client.Indices.Get("books-fiction-horror"); Console.WriteLine(getResponse.Indices["books-fiction-horror"].Settings.NumberOfShards); // 1 Console.WriteLine(getResponse.Indices["books-fiction-horror"].Mappings.Properties["pages"].Type); // integer -Console.WriteLine($"Create response: {componentTemplateCreateResponse}"); // Create response: {"acknowledged":true} ``` ### Get an Index Template @@ -204,5 +200,5 @@ Let's delete all resources created in this guide: ```csharp client.Indices.Delete("books-"); client.LowLevel.Indices.DeleteTemplateV2ForAll("books-fiction"); -client.LowLevel.Cluster.DeleteComponentTemplate("books_mappings"); -``` \ No newline at end of file +client.Cluster.DeleteComponentTemplate("books_mappings"); +``` diff --git a/src/ApiGenerator/Configuration/CodeConfiguration.cs b/src/ApiGenerator/Configuration/CodeConfiguration.cs index 4bf1f461e3..beafe56cae 100644 --- a/src/ApiGenerator/Configuration/CodeConfiguration.cs +++ b/src/ApiGenerator/Configuration/CodeConfiguration.cs @@ -43,14 +43,13 @@ public static class CodeConfiguration new("{delete,get}_all_pits"), new("cluster.allocation_explain"), - new("cluster.delete_component_template"), new("cluster.delete_voting_config_exclusions"), - new("cluster.exists_component_template"), - new("cluster.get_component_template"), new("cluster.get_settings"), new("cluster.health"), new("cluster.pending_tasks"), + new("cluster.*_component_template"), + new("dangling_indices.*"), new("ingest.*"), new("nodes.*"), diff --git a/src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplate.cs b/src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplate.cs new file mode 100644 index 0000000000..9cb9ee41ab --- /dev/null +++ b/src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplate.cs @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using OpenSearch.Net.Utf8Json; + +namespace OpenSearch.Client; + +[ReadAs(typeof(ComponentTemplate))] +public interface IComponentTemplate +{ + [DataMember(Name = "template")] + ITemplate Template { get; set; } + + [DataMember(Name = "version")] + long? Version { get; set; } + + [DataMember(Name = "_meta")] + [JsonFormatter(typeof(VerbatimDictionaryInterfaceKeysFormatter))] + IDictionary Meta { get; set; } +} + +public class ComponentTemplate : IComponentTemplate +{ + public ITemplate Template { get; set; } + public long? Version { get; set; } + public IDictionary Meta { get; set; } +} + +[ReadAs(typeof(Template))] +public interface ITemplate +{ + [DataMember(Name = "aliases")] + IAliases Aliases { get; set; } + + [DataMember(Name = "mappings")] + ITypeMapping Mappings { get; set; } + + [DataMember(Name = "settings")] + IIndexSettings Settings { get; set; } +} + +public class Template : ITemplate +{ + public IAliases Aliases { get; set; } + public ITypeMapping Mappings { get; set; } + public IIndexSettings Settings { get; set; } +} + +public class TemplateDescriptor : DescriptorBase, ITemplate +{ + IAliases ITemplate.Aliases { get; set; } + ITypeMapping ITemplate.Mappings { get; set; } + IIndexSettings ITemplate.Settings { get; set; } + + public TemplateDescriptor Aliases(Func> aliasDescriptor) => + Assign(aliasDescriptor, (a, v) => a.Aliases = v?.Invoke(new AliasesDescriptor())?.Value); + + public TemplateDescriptor Map(Func, ITypeMapping> selector) where T : class => + Assign(selector, (a, v) => a.Mappings = v?.Invoke(new TypeMappingDescriptor())); + + public TemplateDescriptor Map(Func, ITypeMapping> selector) => + Assign(selector, (a, v) => a.Mappings = v?.Invoke(new TypeMappingDescriptor())); + + public TemplateDescriptor Settings(Func> settingsSelector) => + Assign(settingsSelector, (a, v) => a.Settings = v?.Invoke(new IndexSettingsDescriptor())?.Value); +} diff --git a/src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplateExistsRequest.cs b/src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplateExistsRequest.cs new file mode 100644 index 0000000000..1a6874e27b --- /dev/null +++ b/src/OpenSearch.Client/Cluster/ComponentTemplate/ComponentTemplateExistsRequest.cs @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +namespace OpenSearch.Client; + +[MapsApi("cluster.exists_component_template")] +public partial interface IComponentTemplateExistsRequest { } + +public partial class ComponentTemplateExistsRequest { } + +public partial class ComponentTemplateExistsDescriptor { } diff --git a/src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateRequest.cs b/src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateRequest.cs new file mode 100644 index 0000000000..68b627b0ba --- /dev/null +++ b/src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateRequest.cs @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +namespace OpenSearch.Client; + +[MapsApi("cluster.delete_component_template")] +public partial interface IDeleteComponentTemplateRequest { } + +public partial class DeleteComponentTemplateRequest { } + +public partial class DeleteComponentTemplateDescriptor { } diff --git a/src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateResponse.cs b/src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateResponse.cs new file mode 100644 index 0000000000..a232cc759e --- /dev/null +++ b/src/OpenSearch.Client/Cluster/ComponentTemplate/DeleteComponentTemplateResponse.cs @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +using System.Runtime.Serialization; + +namespace OpenSearch.Client; + +[DataContract] +public class DeleteComponentTemplateResponse : AcknowledgedResponseBase { } diff --git a/src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateRequest.cs b/src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateRequest.cs new file mode 100644 index 0000000000..48c4d3b4e5 --- /dev/null +++ b/src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateRequest.cs @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +namespace OpenSearch.Client; + +[MapsApi("cluster.get_component_template")] +public partial interface IGetComponentTemplateRequest { } + +public partial class GetComponentTemplateRequest { } + +public partial class GetComponentTemplateDescriptor { } diff --git a/src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateResponse.cs b/src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateResponse.cs new file mode 100644 index 0000000000..07a3be9fd1 --- /dev/null +++ b/src/OpenSearch.Client/Cluster/ComponentTemplate/GetComponentTemplateResponse.cs @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace OpenSearch.Client; + +[DataContract] +public class GetComponentTemplateResponse : ResponseBase +{ + [DataMember(Name = "component_templates")] + public IReadOnlyCollection ComponentTemplates { get; internal set; } +} + +[DataContract] +public class NamedComponentTemplate +{ + [DataMember(Name = "name")] + public string Name { get; internal set; } + + [DataMember(Name = "component_template")] + public ComponentTemplate ComponentTemplate { get; internal set; } +} diff --git a/src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateRequest.cs b/src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateRequest.cs new file mode 100644 index 0000000000..09da0006b6 --- /dev/null +++ b/src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateRequest.cs @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +using System; +using System.Collections.Generic; + +namespace OpenSearch.Client; + +[MapsApi("cluster.put_component_template")] +public partial interface IPutComponentTemplateRequest : IComponentTemplate { } + +public partial class PutComponentTemplateRequest +{ + public ITemplate Template { get; set; } + public long? Version { get; set; } + public IDictionary Meta { get; set; } +} + +public partial class PutComponentTemplateDescriptor +{ + ITemplate IComponentTemplate.Template { get; set; } + long? IComponentTemplate.Version { get; set; } + IDictionary IComponentTemplate.Meta { get; set; } + + public PutComponentTemplateDescriptor Version(long? version) => Assign(version, (a, v) => a.Version = v); + + public PutComponentTemplateDescriptor Meta(Func, FluentDictionary> metaSelector) => + Assign(metaSelector(new FluentDictionary()), (a, v) => a.Meta = v); + + public PutComponentTemplateDescriptor Meta(Dictionary metaDictionary) => Assign(metaDictionary, (a, v) => a.Meta = v); + + public PutComponentTemplateDescriptor Template(Func selector) => + Assign(selector, (a, v) => a.Template = v?.Invoke(new TemplateDescriptor())); +} diff --git a/src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateResponse.cs b/src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateResponse.cs new file mode 100644 index 0000000000..1786a1f449 --- /dev/null +++ b/src/OpenSearch.Client/Cluster/ComponentTemplate/PutComponentTemplateResponse.cs @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +using System.Runtime.Serialization; + +namespace OpenSearch.Client; + +[DataContract] +public class PutComponentTemplateResponse : AcknowledgedResponseBase { } diff --git a/src/OpenSearch.Client/Indices/IndexManagement/IndicesExists/ExistsResponse.cs b/src/OpenSearch.Client/Indices/IndexManagement/IndicesExists/ExistsResponse.cs index ceb8b37e7f..fff77c92df 100644 --- a/src/OpenSearch.Client/Indices/IndexManagement/IndicesExists/ExistsResponse.cs +++ b/src/OpenSearch.Client/Indices/IndexManagement/IndicesExists/ExistsResponse.cs @@ -28,11 +28,10 @@ using System.Runtime.Serialization; -namespace OpenSearch.Client +namespace OpenSearch.Client; + +[DataContract] +public class ExistsResponse : ResponseBase { - [DataContract] - public class ExistsResponse : ResponseBase - { - public bool Exists => ApiCall != null && ApiCall.Success && ApiCall.HttpStatusCode == 200; - } + public bool Exists => ApiCall is { Success: true, HttpStatusCode: 200 }; } diff --git a/src/OpenSearch.Client/_Generated/ApiUrlsLookup.cs b/src/OpenSearch.Client/_Generated/ApiUrlsLookup.cs index 9510d7bec1..b849882adf 100644 --- a/src/OpenSearch.Client/_Generated/ApiUrlsLookup.cs +++ b/src/OpenSearch.Client/_Generated/ApiUrlsLookup.cs @@ -48,9 +48,18 @@ internal static partial class ApiUrlsLookups internal static readonly ApiUrls ClusterAllocationExplain = new(new[] { "_cluster/allocation/explain" }); + internal static readonly ApiUrls ClusterDeleteComponentTemplate = + new(new[] { "_component_template/{name}" }); + internal static readonly ApiUrls ClusterDeleteVotingConfigExclusions = new(new[] { "_cluster/voting_config_exclusions" }); + internal static readonly ApiUrls ClusterComponentTemplateExists = + new(new[] { "_component_template/{name}" }); + + internal static readonly ApiUrls ClusterGetComponentTemplate = + new(new[] { "_component_template", "_component_template/{name}" }); + internal static readonly ApiUrls ClusterGetSettings = new(new[] { "_cluster/settings" }); internal static readonly ApiUrls ClusterHealth = @@ -59,6 +68,9 @@ internal static partial class ApiUrlsLookups internal static readonly ApiUrls ClusterPendingTasks = new(new[] { "_cluster/pending_tasks" }); + internal static readonly ApiUrls ClusterPutComponentTemplate = + new(new[] { "_component_template/{name}" }); + internal static readonly ApiUrls NoNamespaceCreatePit = new(new[] { "{index}/_search/point_in_time" }); diff --git a/src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs b/src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs index 810634648c..75eb9a9964 100644 --- a/src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs +++ b/src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs @@ -81,6 +81,48 @@ public ClusterAllocationExplainDescriptor IncludeYesDecisions( ) => Qs("include_yes_decisions", includeyesdecisions); } + /// Descriptor for DeleteComponentTemplate https://opensearch.org/docs/latest + public partial class DeleteComponentTemplateDescriptor + : RequestDescriptorBase< + DeleteComponentTemplateDescriptor, + DeleteComponentTemplateRequestParameters, + IDeleteComponentTemplateRequest + >, + IDeleteComponentTemplateRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.ClusterDeleteComponentTemplate; + + /// /_component_template/{name} + /// this parameter is required + public DeleteComponentTemplateDescriptor(Name name) + : base(r => r.Required("name", name)) { } + + /// Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected DeleteComponentTemplateDescriptor() + : base() { } + + // values part of the url path + Name IDeleteComponentTemplateRequest.Name => Self.RouteValues.Get("name"); + + // Request parameters + /// Operation timeout for connection to cluster-manager node. + /// Supported by OpenSearch servers of version 2.0.0 or greater. + public DeleteComponentTemplateDescriptor ClusterManagerTimeout( + Time clustermanagertimeout + ) => Qs("cluster_manager_timeout", clustermanagertimeout); + + /// Operation timeout for connection to master node. + [Obsolete( + "Deprecated as of: 2.0.0, reason: To promote inclusive language, use 'cluster_manager_timeout' instead." + )] + public DeleteComponentTemplateDescriptor MasterTimeout(Time mastertimeout) => + Qs("master_timeout", mastertimeout); + + /// Operation timeout. + public DeleteComponentTemplateDescriptor Timeout(Time timeout) => Qs("timeout", timeout); + } + /// Descriptor for DeleteVotingConfigExclusions https://opensearch.org/docs/latest public partial class DeleteVotingConfigExclusionsDescriptor : RequestDescriptorBase< @@ -99,6 +141,92 @@ public DeleteVotingConfigExclusionsDescriptor WaitForRemoval(bool? waitforremova Qs("wait_for_removal", waitforremoval); } + /// Descriptor for ComponentTemplateExists https://opensearch.org/docs/latest + public partial class ComponentTemplateExistsDescriptor + : RequestDescriptorBase< + ComponentTemplateExistsDescriptor, + ComponentTemplateExistsRequestParameters, + IComponentTemplateExistsRequest + >, + IComponentTemplateExistsRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.ClusterComponentTemplateExists; + + /// /_component_template/{name} + /// this parameter is required + public ComponentTemplateExistsDescriptor(Name name) + : base(r => r.Required("name", name)) { } + + /// Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected ComponentTemplateExistsDescriptor() + : base() { } + + // values part of the url path + Name IComponentTemplateExistsRequest.Name => Self.RouteValues.Get("name"); + + // Request parameters + /// Operation timeout for connection to cluster-manager node. + /// Supported by OpenSearch servers of version 2.0.0 or greater. + public ComponentTemplateExistsDescriptor ClusterManagerTimeout( + Time clustermanagertimeout + ) => Qs("cluster_manager_timeout", clustermanagertimeout); + + /// Return local information, do not retrieve the state from cluster-manager node. + public ComponentTemplateExistsDescriptor Local(bool? local = true) => Qs("local", local); + + /// Operation timeout for connection to master node. + [Obsolete( + "Deprecated as of: 2.0.0, reason: To promote inclusive language, use 'cluster_manager_timeout' instead." + )] + public ComponentTemplateExistsDescriptor MasterTimeout(Time mastertimeout) => + Qs("master_timeout", mastertimeout); + } + + /// Descriptor for GetComponentTemplate https://opensearch.org/docs/latest + public partial class GetComponentTemplateDescriptor + : RequestDescriptorBase< + GetComponentTemplateDescriptor, + GetComponentTemplateRequestParameters, + IGetComponentTemplateRequest + >, + IGetComponentTemplateRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.ClusterGetComponentTemplate; + + /// /_component_template + public GetComponentTemplateDescriptor() + : base() { } + + /// /_component_template/{name} + /// Optional, accepts null + public GetComponentTemplateDescriptor(Names name) + : base(r => r.Optional("name", name)) { } + + // values part of the url path + Names IGetComponentTemplateRequest.Name => Self.RouteValues.Get("name"); + + /// The Comma-separated names of the component templates. + public GetComponentTemplateDescriptor Name(Names name) => + Assign(name, (a, v) => a.RouteValues.Optional("name", v)); + + // Request parameters + /// Operation timeout for connection to cluster-manager node. + /// Supported by OpenSearch servers of version 2.0.0 or greater. + public GetComponentTemplateDescriptor ClusterManagerTimeout(Time clustermanagertimeout) => + Qs("cluster_manager_timeout", clustermanagertimeout); + + /// Return local information, do not retrieve the state from cluster-manager node. + public GetComponentTemplateDescriptor Local(bool? local = true) => Qs("local", local); + + /// Operation timeout for connection to master node. + [Obsolete( + "Deprecated as of: 2.0.0, reason: To promote inclusive language, use 'cluster_manager_timeout' instead." + )] + public GetComponentTemplateDescriptor MasterTimeout(Time mastertimeout) => + Qs("master_timeout", mastertimeout); + } + /// Descriptor for GetSettings https://opensearch.org/docs/latest/api-reference/cluster-api/cluster-settings/ public partial class ClusterGetSettingsDescriptor : RequestDescriptorBase< @@ -257,4 +385,48 @@ public ClusterPendingTasksDescriptor ClusterManagerTimeout(Time clustermanagerti public ClusterPendingTasksDescriptor MasterTimeout(Time mastertimeout) => Qs("master_timeout", mastertimeout); } + + /// Descriptor for PutComponentTemplate + public partial class PutComponentTemplateDescriptor + : RequestDescriptorBase< + PutComponentTemplateDescriptor, + PutComponentTemplateRequestParameters, + IPutComponentTemplateRequest + >, + IPutComponentTemplateRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.ClusterPutComponentTemplate; + + /// /_component_template/{name} + /// this parameter is required + public PutComponentTemplateDescriptor(Name name) + : base(r => r.Required("name", name)) { } + + /// Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected PutComponentTemplateDescriptor() + : base() { } + + // values part of the url path + Name IPutComponentTemplateRequest.Name => Self.RouteValues.Get("name"); + + // Request parameters + /// Operation timeout for connection to cluster-manager node. + /// Supported by OpenSearch servers of version 2.0.0 or greater. + public PutComponentTemplateDescriptor ClusterManagerTimeout(Time clustermanagertimeout) => + Qs("cluster_manager_timeout", clustermanagertimeout); + + /// Whether the index template should only be added if new or can also replace an existing one. + public PutComponentTemplateDescriptor Create(bool? create = true) => Qs("create", create); + + /// Operation timeout for connection to master node. + [Obsolete( + "Deprecated as of: 2.0.0, reason: To promote inclusive language, use 'cluster_manager_timeout' instead." + )] + public PutComponentTemplateDescriptor MasterTimeout(Time mastertimeout) => + Qs("master_timeout", mastertimeout); + + /// Operation timeout. + public PutComponentTemplateDescriptor Timeout(Time timeout) => Qs("timeout", timeout); + } } diff --git a/src/OpenSearch.Client/_Generated/OpenSearchClient.Cluster.cs b/src/OpenSearch.Client/_Generated/OpenSearchClient.Cluster.cs index c2ddd0c528..d429a1f42a 100644 --- a/src/OpenSearch.Client/_Generated/OpenSearchClient.Cluster.cs +++ b/src/OpenSearch.Client/_Generated/OpenSearchClient.Cluster.cs @@ -115,6 +115,63 @@ public Task AllocationExplainAsync( ct ); + /// + /// DELETE request to the cluster.delete_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public DeleteComponentTemplateResponse DeleteComponentTemplate( + Name name, + Func selector = null + ) => + DeleteComponentTemplate( + selector.InvokeOrDefault(new DeleteComponentTemplateDescriptor(name: name)) + ); + + /// + /// DELETE request to the cluster.delete_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public Task DeleteComponentTemplateAsync( + Name name, + Func selector = + null, + CancellationToken ct = default + ) => + DeleteComponentTemplateAsync( + selector.InvokeOrDefault(new DeleteComponentTemplateDescriptor(name: name)), + ct + ); + + /// + /// DELETE request to the cluster.delete_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public DeleteComponentTemplateResponse DeleteComponentTemplate( + IDeleteComponentTemplateRequest request + ) => + DoRequest( + request, + request.RequestParameters + ); + + /// + /// DELETE request to the cluster.delete_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public Task DeleteComponentTemplateAsync( + IDeleteComponentTemplateRequest request, + CancellationToken ct = default + ) => + DoRequestAsync( + request, + request.RequestParameters, + ct + ); + /// /// DELETE request to the cluster.delete_voting_config_exclusions API, read more about this API online: /// @@ -174,6 +231,117 @@ public Task DeleteVotingConfigExclusionsAs DeleteVotingConfigExclusionsResponse >(request, request.RequestParameters, ct); + /// + /// HEAD request to the cluster.exists_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public ExistsResponse ComponentTemplateExists( + Name name, + Func selector = null + ) => + ComponentTemplateExists( + selector.InvokeOrDefault(new ComponentTemplateExistsDescriptor(name: name)) + ); + + /// + /// HEAD request to the cluster.exists_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public Task ComponentTemplateExistsAsync( + Name name, + Func selector = + null, + CancellationToken ct = default + ) => + ComponentTemplateExistsAsync( + selector.InvokeOrDefault(new ComponentTemplateExistsDescriptor(name: name)), + ct + ); + + /// + /// HEAD request to the cluster.exists_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public ExistsResponse ComponentTemplateExists(IComponentTemplateExistsRequest request) => + DoRequest( + request, + request.RequestParameters + ); + + /// + /// HEAD request to the cluster.exists_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public Task ComponentTemplateExistsAsync( + IComponentTemplateExistsRequest request, + CancellationToken ct = default + ) => + DoRequestAsync( + request, + request.RequestParameters, + ct + ); + + /// + /// GET request to the cluster.get_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public GetComponentTemplateResponse GetComponentTemplate( + Names name = null, + Func selector = null + ) => + GetComponentTemplate( + selector.InvokeOrDefault(new GetComponentTemplateDescriptor().Name(name: name)) + ); + + /// + /// GET request to the cluster.get_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public Task GetComponentTemplateAsync( + Names name = null, + Func selector = null, + CancellationToken ct = default + ) => + GetComponentTemplateAsync( + selector.InvokeOrDefault(new GetComponentTemplateDescriptor().Name(name: name)), + ct + ); + + /// + /// GET request to the cluster.get_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public GetComponentTemplateResponse GetComponentTemplate( + IGetComponentTemplateRequest request + ) => + DoRequest( + request, + request.RequestParameters + ); + + /// + /// GET request to the cluster.get_component_template API, read more about this API online: + /// + /// https://opensearch.org/docs/latest + /// + public Task GetComponentTemplateAsync( + IGetComponentTemplateRequest request, + CancellationToken ct = default + ) => + DoRequestAsync( + request, + request.RequestParameters, + ct + ); + /// /// GET request to the cluster.get_settings API, read more about this API online: /// @@ -314,5 +482,61 @@ public Task PendingTasksAsync( request.RequestParameters, ct ); + + /// + /// PUT request to the cluster.put_component_template API, read more about this API online: + /// + /// + /// + public PutComponentTemplateResponse PutComponentTemplate( + Name name, + Func selector + ) => + PutComponentTemplate( + selector.InvokeOrDefault(new PutComponentTemplateDescriptor(name: name)) + ); + + /// + /// PUT request to the cluster.put_component_template API, read more about this API online: + /// + /// + /// + public Task PutComponentTemplateAsync( + Name name, + Func selector, + CancellationToken ct = default + ) => + PutComponentTemplateAsync( + selector.InvokeOrDefault(new PutComponentTemplateDescriptor(name: name)), + ct + ); + + /// + /// PUT request to the cluster.put_component_template API, read more about this API online: + /// + /// + /// + public PutComponentTemplateResponse PutComponentTemplate( + IPutComponentTemplateRequest request + ) => + DoRequest( + request, + request.RequestParameters + ); + + /// + /// PUT request to the cluster.put_component_template API, read more about this API online: + /// + /// + /// + public Task PutComponentTemplateAsync( + IPutComponentTemplateRequest request, + CancellationToken ct = default + ) => + DoRequestAsync( + request, + request.RequestParameters, + ct + ); } } diff --git a/src/OpenSearch.Client/_Generated/Requests.Cluster.cs b/src/OpenSearch.Client/_Generated/Requests.Cluster.cs index 38174ffad5..34566239c9 100644 --- a/src/OpenSearch.Client/_Generated/Requests.Cluster.cs +++ b/src/OpenSearch.Client/_Generated/Requests.Cluster.cs @@ -88,6 +88,63 @@ public bool? IncludeYesDecisions } } + [InterfaceDataContract] + public partial interface IDeleteComponentTemplateRequest + : IRequest + { + [IgnoreDataMember] + Name Name { get; } + } + + /// Request for DeleteComponentTemplate https://opensearch.org/docs/latest + public partial class DeleteComponentTemplateRequest + : PlainRequestBase, + IDeleteComponentTemplateRequest + { + protected IDeleteComponentTemplateRequest Self => this; + internal override ApiUrls ApiUrls => ApiUrlsLookups.ClusterDeleteComponentTemplate; + + /// /_component_template/{name} + /// this parameter is required + public DeleteComponentTemplateRequest(Name name) + : base(r => r.Required("name", name)) { } + + /// Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected DeleteComponentTemplateRequest() + : base() { } + + // values part of the url path + [IgnoreDataMember] + Name IDeleteComponentTemplateRequest.Name => Self.RouteValues.Get("name"); + + // Request parameters + /// Operation timeout for connection to cluster-manager node. + /// Supported by OpenSearch servers of version 2.0.0 or greater. + public Time ClusterManagerTimeout + { + get => Q