From c649794c6a9940b666da775a901781dc183bd609 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Wed, 29 Nov 2023 14:06:38 +1300 Subject: [PATCH] Re-add and deprecate replaced operations to avoid breaking changes Signed-off-by: Thomas Farr --- CHANGELOG.md | 3 + .../RequestParameters.Cluster.cs | 103 ++++++++++++++++++ .../RequestParameters.Indices.cs | 73 +++++++++++++ .../OpenSearchLowLevelClient.Cluster.cs | 15 +++ .../OpenSearchLowLevelClient.Indices.cs | 44 ++++++++ 5 files changed, 238 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdb6dd40dc..ac2aed1471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added support for the component template APIs ([#411](https://github.com/opensearch-project/opensearch-net/pull/411)) - Added support for the composable index template APIs ([#437](https://github.com/opensearch-project/opensearch-net/pull/437)) +### Deprecated +- Deprecated the low-level `IndexTemplateV2` APIs in favour of the new `ComposableIndexTemplate` APIs ([#454](https://github.com/opensearch-project/opensearch-net/pull/454)) + ### Dependencies - Bumps `FSharp.Data` from 6.2.0 to 6.3.0 - Bumps `BenchMarkDotNet` from 0.13.7 to 0.13.10 diff --git a/src/OpenSearch.Net/Api/RequestParameters/RequestParameters.Cluster.cs b/src/OpenSearch.Net/Api/RequestParameters/RequestParameters.Cluster.cs index a8c810f3d5..5a88931f6f 100644 --- a/src/OpenSearch.Net/Api/RequestParameters/RequestParameters.Cluster.cs +++ b/src/OpenSearch.Net/Api/RequestParameters/RequestParameters.Cluster.cs @@ -56,6 +56,30 @@ public bool? IncludeYesDecisions } } + ///Request options for DeleteComponentTemplate https://opensearch.org/docs/latest/opensearch/index-templates/ + public partial class DeleteComponentTemplateRequestParameters : RequestParameters + { +#pragma warning disable 618 + ///Specify timeout for connection to master node + /// + [Obsolete($"Replaced by {nameof(MasterTimeout)}")] + public TimeSpan MasterTimeSpanout + { + get => Q("master_timeout"); + set => Q("master_timeout", value); + } + + ///Specify timeout for connection to cluster_manager node + /// + [Obsolete($"Replaced by {nameof(ClusterManagerTimeout)}")] + public TimeSpan ClusterManagerTimeSpanout + { + get => Q("cluster_manager_timeout"); + set => Q("cluster_manager_timeout", value); + } +#pragma warning restore 618 + } + ///Request options for DeleteVotingConfigExclusions public class DeleteVotingConfigExclusionsRequestParameters : RequestParameters { @@ -69,6 +93,61 @@ public bool? WaitForRemoval } } + ///Request options for ExistsComponentTemplate https://opensearch.org/docs/latest/opensearch/index-templates/ + /// + [Obsolete($"Replaced by {nameof(ComponentTemplateExistsRequestParameters)}")] + public class ExistsComponentTemplateRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.HEAD; + public override bool SupportsBody => false; + ///Return local information, do not retrieve the state from cluster_manager node (default: false) + public bool? Local + { + get => Q("local"); + set => Q("local", value); + } + + ///Explicit operation timeout for connection to master node + ///Deprecated as of OpenSearch 2.0, use instead + public TimeSpan MasterTimeSpanout + { + get => Q("master_timeout"); + set => Q("master_timeout", value); + } + + ///Explicit operation timeout for connection to cluster_manager node + ///Introduced in OpenSearch 2.0 instead of + public TimeSpan ClusterManagerTimeSpanout + { + get => Q("cluster_manager_timeout"); + set => Q("cluster_manager_timeout", value); + } + } + + ///Request options for GetComponentTemplate https://opensearch.org/docs/latest/opensearch/index-templates/ + public partial class GetComponentTemplateRequestParameters : RequestParameters + { +#pragma warning disable 618 + ///Specify timeout for connection to master node + /// + [Obsolete($"Replaced by {nameof(MasterTimeout)}")] + public TimeSpan MasterTimeSpanout + { + get => Q("master_timeout"); + set => Q("master_timeout", value); + } + + ///Specify timeout for connection to cluster_manager node + /// + [Obsolete($"Replaced by {nameof(ClusterManagerTimeout)}")] + public TimeSpan ClusterManagerTimeSpanout + { + get => Q("cluster_manager_timeout"); + set => Q("cluster_manager_timeout", value); + } +#pragma warning restore 618 + } + ///Request options for GetSettings https://opensearch.org/docs/latest/opensearch/rest-api/cluster-settings/ public class ClusterGetSettingsRequestParameters : RequestParameters { @@ -266,6 +345,30 @@ public TimeSpan Timeout } } + ///Request options for PutComponentTemplate https://opensearch.org/docs/latest/opensearch/index-templates/ + public partial class PutComponentTemplateRequestParameters : RequestParameters + { +#pragma warning disable 618 + ///Specify timeout for connection to master node + /// + [Obsolete($"Replaced by {nameof(MasterTimeout)}")] + public TimeSpan MasterTimeSpanout + { + get => Q("master_timeout"); + set => Q("master_timeout", value); + } + + ///Specify timeout for connection to cluster_manager node + /// + [Obsolete($"Replaced by {nameof(ClusterManagerTimeout)}")] + public TimeSpan ClusterManagerTimeSpanout + { + get => Q("cluster_manager_timeout"); + set => Q("cluster_manager_timeout", value); + } +#pragma warning restore 618 + } + ///Request options for PutSettings https://opensearch.org/docs/latest/opensearch/rest-api/cluster-settings/ public class ClusterPutSettingsRequestParameters : RequestParameters { diff --git a/src/OpenSearch.Net/Api/RequestParameters/RequestParameters.Indices.cs b/src/OpenSearch.Net/Api/RequestParameters/RequestParameters.Indices.cs index 67d69e2c5d..50907638f9 100644 --- a/src/OpenSearch.Net/Api/RequestParameters/RequestParameters.Indices.cs +++ b/src/OpenSearch.Net/Api/RequestParameters/RequestParameters.Indices.cs @@ -389,6 +389,37 @@ public TimeSpan Timeout } } + ///Request options for DeleteTemplateV2 https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ + /// + [Obsolete($"Replaced by {nameof(DeleteComposableIndexTemplateRequestParameters)}")] + public class DeleteIndexTemplateV2RequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE; + public override bool SupportsBody => false; + ///Specify timeout for connection to master node + ///Deprecated as of OpenSearch 2.0, use instead + public TimeSpan MasterTimeSpanout + { + get => Q("master_timeout"); + set => Q("master_timeout", value); + } + + ///Specify timeout for connection to cluster_manager node + ///Introduced in OpenSearch 2.0 instead of + public TimeSpan ClusterManagerTimeSpanout + { + get => Q("cluster_manager_timeout"); + set => Q("cluster_manager_timeout", value); + } + + ///Explicit operation timeout + public TimeSpan Timeout + { + get => Q("timeout"); + set => Q("timeout", value); + } + } + ///Request options for DeleteTemplate https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ public class DeleteIndexTemplateRequestParameters : RequestParameters { @@ -504,6 +535,8 @@ public bool? Local } ///Request options for ExistsTemplate https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ + /// + [Obsolete($"Replaced by {nameof(ComposableIndexTemplateExistsRequestParameters)}")] public class ExistsIndexTemplateRequestParameters : RequestParameters { public override HttpMethod DefaultHttpMethod => HttpMethod.HEAD; @@ -906,6 +939,8 @@ public bool? Local } ///Request options for GetTemplateV2 https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ + /// + [Obsolete($"Replaced by {nameof(GetComposableIndexTemplateRequestParameters)}")] public class GetIndexTemplateV2RequestParameters : RequestParameters { public override HttpMethod DefaultHttpMethod => HttpMethod.GET; @@ -1195,6 +1230,44 @@ public TimeSpan Timeout } } + ///Request options for PutTemplateV2 https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ + /// + [Obsolete($"Replaced by {nameof(PutComposableIndexTemplateRequestParameters)}")] + public class PutIndexTemplateV2RequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.PUT; + public override bool SupportsBody => true; + ///User defined reason for creating/updating the index template + public string Cause + { + get => Q("cause"); + set => Q("cause", value); + } + + ///Whether the index template should only be added if new or can also replace an existing one + public bool? Create + { + get => Q("create"); + set => Q("create", value); + } + + ///Specify timeout for connection to master node + ///Deprecated as of OpenSearch 2.0, use instead + public TimeSpan MasterTimeSpanout + { + get => Q("master_timeout"); + set => Q("master_timeout", value); + } + + ///Specify timeout for connection to cluster_manager node + ///Introduced in OpenSearch 2.0 instead of + public TimeSpan ClusterManagerTimeSpanout + { + get => Q("cluster_manager_timeout"); + set => Q("cluster_manager_timeout", value); + } + } + ///Request options for PutMapping https://opensearch.org/docs/latest/opensearch/rest-api/update-mapping/ public class PutMappingRequestParameters : RequestParameters { diff --git a/src/OpenSearch.Net/OpenSearchLowLevelClient.Cluster.cs b/src/OpenSearch.Net/OpenSearchLowLevelClient.Cluster.cs index 137df362b3..7b57939fad 100644 --- a/src/OpenSearch.Net/OpenSearchLowLevelClient.Cluster.cs +++ b/src/OpenSearch.Net/OpenSearchLowLevelClient.Cluster.cs @@ -71,6 +71,21 @@ public TResponse DeleteVotingConfigExclusions(DeleteVotingConfigExclu [MapsApi("cluster.delete_voting_config_exclusions", "")] public Task DeleteVotingConfigExclusionsAsync(DeleteVotingConfigExclusionsRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(DELETE, "_cluster/voting_config_exclusions", ctx, null, RequestParams(requestParameters)); + ///HEAD on /_component_template/{name} https://opensearch.org/docs/latest/opensearch/index-templates/ + ///The name of the template + ///Request specific configuration such as querystring parameters & request specific connection settings. + /// + [Obsolete($"Replaced by {nameof(ComponentTemplateExists)}")] + public TResponse ExistsComponentTemplate(string name, ExistsComponentTemplateRequestParameters requestParameters = null) + where TResponse : class, IOpenSearchResponse, new() => DoRequest(HEAD, Url($"_component_template/{name:name}"), null, RequestParams(requestParameters)); + ///HEAD on /_component_template/{name} https://opensearch.org/docs/latest/opensearch/index-templates/ + ///The name of the template + ///Request specific configuration such as querystring parameters & request specific connection settings. + /// + [MapsApi("cluster.exists_component_template", "name")] + [Obsolete($"Replaced by {nameof(ComponentTemplateExistsAsync)}")] + public Task ExistsComponentTemplateAsync(string name, ExistsComponentTemplateRequestParameters requestParameters = null, CancellationToken ctx = default) + where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(HEAD, Url($"_component_template/{name:name}"), ctx, null, RequestParams(requestParameters)); ///GET on /_cluster/settings https://opensearch.org/docs/latest/opensearch/rest-api/cluster-settings/ ///Request specific configuration such as querystring parameters & request specific connection settings. public TResponse GetSettings(ClusterGetSettingsRequestParameters requestParameters = null) diff --git a/src/OpenSearch.Net/OpenSearchLowLevelClient.Indices.cs b/src/OpenSearch.Net/OpenSearchLowLevelClient.Indices.cs index e8b4338843..f788ad1693 100644 --- a/src/OpenSearch.Net/OpenSearchLowLevelClient.Indices.cs +++ b/src/OpenSearch.Net/OpenSearchLowLevelClient.Indices.cs @@ -171,6 +171,21 @@ public TResponse DeleteAlias(string index, string name, DeleteAliasRe [MapsApi("indices.delete_alias", "index, name")] public Task DeleteAliasAsync(string index, string name, DeleteAliasRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(DELETE, Url($"{index:index}/_alias/{name:name}"), ctx, null, RequestParams(requestParameters)); + ///DELETE on /_index_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ + ///The name of the template + ///Request specific configuration such as querystring parameters & request specific connection settings. + /// + [Obsolete($"Replaced by {nameof(DeleteComposableTemplateForAll)}")] + public TResponse DeleteTemplateV2ForAll(string name, DeleteIndexTemplateV2RequestParameters requestParameters = null) + where TResponse : class, IOpenSearchResponse, new() => DoRequest(DELETE, Url($"_index_template/{name:name}"), null, RequestParams(requestParameters)); + ///DELETE on /_index_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ + ///The name of the template + ///Request specific configuration such as querystring parameters & request specific connection settings. + /// + [MapsApi("indices.delete_index_template", "name")] + [Obsolete($"Replaced by {nameof(DeleteComposableTemplateForAllAsync)}")] + public Task DeleteTemplateV2ForAllAsync(string name, DeleteIndexTemplateV2RequestParameters requestParameters = null, CancellationToken ctx = default) + where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(DELETE, Url($"_index_template/{name:name}"), ctx, null, RequestParams(requestParameters)); ///DELETE on /_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ ///The name of the template ///Request specific configuration such as querystring parameters & request specific connection settings. @@ -220,12 +235,16 @@ public Task AliasExistsAsync(string index, string name, Al ///HEAD on /_index_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ ///The name of the template ///Request specific configuration such as querystring parameters & request specific connection settings. + /// + [Obsolete($"Replaced by {nameof(ComposableTemplateExistsForAll)}")] public TResponse ExistsTemplateForAll(string name, ExistsIndexTemplateRequestParameters requestParameters = null) where TResponse : class, IOpenSearchResponse, new() => DoRequest(HEAD, Url($"_index_template/{name:name}"), null, RequestParams(requestParameters)); ///HEAD on /_index_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ ///The name of the template ///Request specific configuration such as querystring parameters & request specific connection settings. + /// [MapsApi("indices.exists_index_template", "name")] + [Obsolete($"Replaced by {nameof(ComposableTemplateExistsForAllAsync)}")] public Task ExistsTemplateForAllAsync(string name, ExistsIndexTemplateRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(HEAD, Url($"_index_template/{name:name}"), ctx, null, RequestParams(requestParameters)); ///HEAD on /_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ @@ -375,22 +394,30 @@ public Task GetFieldMappingAsync(string index, string fiel where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(GET, Url($"{index:index}/_mapping/field/{fields:fields}"), ctx, null, RequestParams(requestParameters)); ///GET on /_index_template https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ ///Request specific configuration such as querystring parameters & request specific connection settings. + /// + [Obsolete($"Replaced by {nameof(GetComposableTemplateForAll)}")] public TResponse GetTemplateV2ForAll(GetIndexTemplateV2RequestParameters requestParameters = null) where TResponse : class, IOpenSearchResponse, new() => DoRequest(GET, "_index_template", null, RequestParams(requestParameters)); ///GET on /_index_template https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ ///Request specific configuration such as querystring parameters & request specific connection settings. + /// [MapsApi("indices.get_index_template", "")] + [Obsolete($"Replaced by {nameof(GetComposableTemplateForAllAsync)}")] public Task GetTemplateV2ForAllAsync(GetIndexTemplateV2RequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(GET, "_index_template", ctx, null, RequestParams(requestParameters)); ///GET on /_index_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ ///The comma separated names of the index templates ///Request specific configuration such as querystring parameters & request specific connection settings. + /// + [Obsolete($"Replaced by {nameof(GetComposableTemplateForAll)}")] public TResponse GetTemplateV2ForAll(string name, GetIndexTemplateV2RequestParameters requestParameters = null) where TResponse : class, IOpenSearchResponse, new() => DoRequest(GET, Url($"_index_template/{name:name}"), null, RequestParams(requestParameters)); ///GET on /_index_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ ///The comma separated names of the index templates ///Request specific configuration such as querystring parameters & request specific connection settings. + /// [MapsApi("indices.get_index_template", "name")] + [Obsolete($"Replaced by {nameof(GetComposableTemplateForAllAsync)}")] public Task GetTemplateV2ForAllAsync(string name, GetIndexTemplateV2RequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(GET, Url($"_index_template/{name:name}"), ctx, null, RequestParams(requestParameters)); ///GET on /_mapping https://opensearch.org/docs/latest/opensearch/rest-api/update-mapping/ @@ -503,6 +530,23 @@ public TResponse PutAlias(string index, string name, PostData body, P [MapsApi("indices.put_alias", "index, name, body")] public Task PutAliasAsync(string index, string name, PostData body, PutAliasRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(PUT, Url($"{index:index}/_alias/{name:name}"), ctx, body, RequestParams(requestParameters)); + ///PUT on /_index_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ + ///The name of the template + ///The template definition + ///Request specific configuration such as querystring parameters & request specific connection settings. + /// + [Obsolete($"Replaced by {nameof(PutComposableTemplateForAll)}")] + public TResponse PutTemplateV2ForAll(string name, PostData body, PutIndexTemplateV2RequestParameters requestParameters = null) + where TResponse : class, IOpenSearchResponse, new() => DoRequest(PUT, Url($"_index_template/{name:name}"), body, RequestParams(requestParameters)); + ///PUT on /_index_template/{name} https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-templates/ + ///The name of the template + ///The template definition + ///Request specific configuration such as querystring parameters & request specific connection settings. + /// + [Obsolete($"Replaced by {nameof(PutComposableTemplateForAllAsync)}")] + [MapsApi("indices.put_index_template", "name, body")] + public Task PutTemplateV2ForAllAsync(string name, PostData body, PutIndexTemplateV2RequestParameters requestParameters = null, CancellationToken ctx = default) + where TResponse : class, IOpenSearchResponse, new() => DoRequestAsync(PUT, Url($"_index_template/{name:name}"), ctx, body, RequestParams(requestParameters)); ///PUT on /{index}/_mapping https://opensearch.org/docs/latest/opensearch/rest-api/update-mapping/ ///A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. ///The mapping definition