From 51114271dae2a9fa17f5339c4f36e8637d98a9cb Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 6 Nov 2023 12:01:13 +1300 Subject: [PATCH] Add support for Point In Time APIs (#405) * Add `CreatePit` & `DeletePit` methods Signed-off-by: Thomas Farr * Add `DeleteAllPits` and `GetAllPits` methods Signed-off-by: Thomas Farr * Add PIT search support Signed-off-by: Thomas Farr * Add integration tests Signed-off-by: Thomas Farr * Add docs Signed-off-by: Thomas Farr * Add changelog entry Signed-off-by: Thomas Farr * Correct Signed-off-by: Thomas Farr * Fix changelog typo Signed-off-by: Thomas Farr * Add tests for CreatePit Signed-off-by: Thomas Farr * Add tests for DeletePit Signed-off-by: Thomas Farr * Fixing tests Signed-off-by: Thomas Farr * Cleanup Signed-off-by: Thomas Farr * Add tests for GetAllPits & DeleteAllPits Signed-off-by: Thomas Farr * PitSearch tests Signed-off-by: Thomas Farr * call isolated Signed-off-by: Thomas Farr * writable cluster Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr --- CHANGELOG.md | 5 +- guides/search.md | 35 +++- .../Configuration/CodeConfiguration.cs | 3 + src/ApiGenerator/OpenSearch.openapi.json | 115 ++++++++--- .../HighLevel/Descriptors/Descriptors.cshtml | 2 +- .../Views/HighLevel/Requests/Requests.cshtml | 2 +- .../Composite/CompositeAggregationSource.cs | 1 + .../Cat/CatHelpResponseBuilder.cs | 1 + .../Extensions/Extensions.cs | 7 - .../CommonOptions/Sorting/SortFormatter.cs | 1 + .../GetFieldMapping/FieldMappingFormatter.cs | 1 + .../OpenSearch.Client.csproj | 1 + .../Functions/ScoreFunctionJsonFormatter.cs | 1 + .../Geo/BoundingBox/GeoBoundingBoxQuery.cs | 1 + .../QueryDsl/Geo/Distance/GeoDistanceQuery.cs | 1 + .../QueryDsl/Geo/Polygon/GeoPolygonQuery.cs | 1 + .../Geo/Shape/GeoShapeQueryFormatter.cs | 1 + .../Specialized/Shape/CartesianPoint.cs | 1 + .../Specialized/Shape/ShapeQueryFormatter.cs | 1 + .../TermLevel/Terms/TermsQueryFormatter.cs | 1 + .../Search/PointInTime/CreatePitRequest.cs | 16 ++ .../Search/PointInTime/CreatePitResponse.cs | 23 +++ .../PointInTime/DeleteAllPitsRequest.cs | 16 ++ .../PointInTime/DeleteAllPitsResponse.cs | 18 ++ .../Search/PointInTime/DeletePitRequest.cs | 40 ++++ .../Search/PointInTime/DeletePitResponse.cs | 29 +++ .../Search/PointInTime/GetAllPitsRequest.cs | 16 ++ .../Search/PointInTime/GetAllPitsResponse.cs | 31 +++ .../Search/Search/PointInTime/PointInTime.cs | 36 ++++ .../Search/Search/SearchRequest.cs | 32 ++- .../GetRepositoryResponseFormatter.cs | 1 + .../_Generated/ApiUrlsLookup.cs | 12 ++ .../_Generated/Descriptors.Cluster.cs | 5 - .../_Generated/Descriptors.NoNamespace.cs | 154 ++++++++++++++ .../_Generated/IOpenSearchClient.cs | 160 +++++++++++++++ .../_Generated/OpenSearchClient.cs | 189 ++++++++++++++++++ .../_Generated/Requests.Cluster.cs | 7 - .../_Generated/Requests.NoNamespace.cs | 177 ++++++++++++++++ .../Extensions/UtilExtensions.cs | 4 +- .../RequestParameters.Cluster.cs | 15 +- .../RequestParameters.NoNamespace.cs | 119 +++++++++++ .../_Generated/IOpenSearchLowLevelClient.cs | 72 +++++++ .../_Generated/OpenSearchLowLevelClient.cs | 130 ++++++++++++ tests/Tests.YamlRunner/SkipList.fs | 12 +- .../Search/PointInTime/CreatePitApiTests.cs | 76 +++++++ .../Search/PointInTime/CreatePitUrlTests.cs | 30 +++ .../PointInTime/DeleteAllPitsApiTests.cs | 81 ++++++++ .../PointInTime/DeleteAllPitsUrlTests.cs | 24 +++ .../Search/PointInTime/DeletePitApiTests.cs | 83 ++++++++ .../Search/PointInTime/DeletePitUrlTests.cs | 28 +++ .../Search/PointInTime/GetAllPitsApiTests.cs | 85 ++++++++ .../Search/PointInTime/GetAllPitsUrlTests.cs | 24 +++ .../Search/PointInTime/PitSearchApiTests.cs | 126 ++++++++++++ tests/Tests/Tests.csproj | 1 - 54 files changed, 1981 insertions(+), 73 deletions(-) create mode 100644 src/OpenSearch.Client/Search/PointInTime/CreatePitRequest.cs create mode 100644 src/OpenSearch.Client/Search/PointInTime/CreatePitResponse.cs create mode 100644 src/OpenSearch.Client/Search/PointInTime/DeleteAllPitsRequest.cs create mode 100644 src/OpenSearch.Client/Search/PointInTime/DeleteAllPitsResponse.cs create mode 100644 src/OpenSearch.Client/Search/PointInTime/DeletePitRequest.cs create mode 100644 src/OpenSearch.Client/Search/PointInTime/DeletePitResponse.cs create mode 100644 src/OpenSearch.Client/Search/PointInTime/GetAllPitsRequest.cs create mode 100644 src/OpenSearch.Client/Search/PointInTime/GetAllPitsResponse.cs create mode 100644 src/OpenSearch.Client/Search/Search/PointInTime/PointInTime.cs create mode 100644 src/OpenSearch.Client/_Generated/Descriptors.NoNamespace.cs create mode 100644 src/OpenSearch.Client/_Generated/Requests.NoNamespace.cs create mode 100644 src/OpenSearch.Net/_Generated/Api/RequestParameters/RequestParameters.NoNamespace.cs create mode 100644 tests/Tests/Search/PointInTime/CreatePitApiTests.cs create mode 100644 tests/Tests/Search/PointInTime/CreatePitUrlTests.cs create mode 100644 tests/Tests/Search/PointInTime/DeleteAllPitsApiTests.cs create mode 100644 tests/Tests/Search/PointInTime/DeleteAllPitsUrlTests.cs create mode 100644 tests/Tests/Search/PointInTime/DeletePitApiTests.cs create mode 100644 tests/Tests/Search/PointInTime/DeletePitUrlTests.cs create mode 100644 tests/Tests/Search/PointInTime/GetAllPitsApiTests.cs create mode 100644 tests/Tests/Search/PointInTime/GetAllPitsUrlTests.cs create mode 100644 tests/Tests/Search/PointInTime/PitSearchApiTests.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index efb2b486ae..e183e2c950 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Removed support for the `net461` target ([#256](https://github.com/opensearch-project/opensearch-net/pull/256)) - Fixed naming of `ClusterManagerTimeout` and `MasterTimeout` properties from `*TimeSpanout` in the low-level client ([#332](https://github.com/opensearch-project/opensearch-net/pull/332)) +### Added +- Added support for point-in-time search and associated APIs ([#405](https://github.com/opensearch-project/opensearch-net/pull/405)) + ### 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)) @@ -107,4 +110,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) [Unreleased]: https://github.com/opensearch-project/opensearch-net/compare/v1.5.0...main [1.5.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.4.0...v1.5.0 [1.4.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.3.0...v1.4.0 -[1.3.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.2.0...v1.3.0 \ No newline at end of file +[1.3.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.2.0...v1.3.0 diff --git a/guides/search.md b/guides/search.md index e22534247a..ed8d022a97 100644 --- a/guides/search.md +++ b/guides/search.md @@ -141,8 +141,41 @@ var page3 = await client.ScrollAsync("1m", page2.ScrollId); Console.WriteLine(string.Join('\n', page3.Documents)); ``` +### Pagination with Point in Time +The scroll example above has one weakness: if the index is updated while you are scrolling through the results, they will be paginated inconsistently. To avoid this, you should use the "Point in Time" feature. The following example demonstrates how to use the `point_in_time` and `pit_id` parameters to paginate through the search results: + +```csharp +var pitResp = await client.CreatePitAsync("movies", p => p.KeepAlive("1m")); + +var page1 = await client.SearchAsync(s => s + .Query(_ => query) + .Sort(_ => sort) + .Size(2) + .PointInTime(p => p.Id(pitResp.PitId).KeepAlive("1m"))); +var page2 = await client.SearchAsync(s => s + .Query(_ => query) + .Sort(_ => sort) + .Size(2) + .PointInTime(p => p.Id(pitResp.PitId).KeepAlive("1m")) + .SearchAfter(page1.Hits.Last().Sorts)); +var page3 = await client.SearchAsync(s => s + .Query(_ => query) + .Sort(_ => sort) + .Size(2) + .PointInTime(p => p.Id(pitResp.PitId).KeepAlive("1m")) + .SearchAfter(page2.Hits.Last().Sorts)); + +foreach (var doc in page1.Documents.Concat(page2.Documents).Concat(page3.Documents)) +{ + Console.WriteLine(doc.Title); +} + +await client.DeletePitAsync(p => p.PitId(pitResp.PitId)); +``` + +Note that a point-in-time is associated with an index or a set of index. So, when performing a search with a point-in-time, you DO NOT specify the index in the search. ## Cleanup ```csharp await client.Indices.DeleteAsync("movies"); -``` \ No newline at end of file +``` diff --git a/src/ApiGenerator/Configuration/CodeConfiguration.cs b/src/ApiGenerator/Configuration/CodeConfiguration.cs index 8e182c4d14..4bf1f461e3 100644 --- a/src/ApiGenerator/Configuration/CodeConfiguration.cs +++ b/src/ApiGenerator/Configuration/CodeConfiguration.cs @@ -39,6 +39,9 @@ public static class CodeConfiguration { private static readonly Glob[] OperationsToInclude = { + new("{create,delete}_pit"), + new("{delete,get}_all_pits"), + new("cluster.allocation_explain"), new("cluster.delete_component_template"), new("cluster.delete_voting_config_exclusions"), diff --git a/src/ApiGenerator/OpenSearch.openapi.json b/src/ApiGenerator/OpenSearch.openapi.json index a34c78380d..fe1126c5e3 100644 --- a/src/ApiGenerator/OpenSearch.openapi.json +++ b/src/ApiGenerator/OpenSearch.openapi.json @@ -5119,16 +5119,6 @@ "type": "string", "description": "The awareness attribute for which the health is required." } - }, - { - "name": "ensure_node_commissioned", - "in": "query", - "description": "Checks whether local node is commissioned or not. If set to true on a local call it will throw exception if node is decommissioned.", - "schema": { - "type": "boolean", - "default": false, - "description": "Checks whether local node is commissioned or not. If set to true on a local call it will throw exception if node is decommissioned." - } } ], "responses": { @@ -5280,16 +5270,6 @@ "type": "string", "description": "The awareness attribute for which the health is required." } - }, - { - "name": "ensure_node_commissioned", - "in": "query", - "description": "Checks whether local node is commissioned or not. If set to true on a local call it will throw exception if node is decommissioned.", - "schema": { - "type": "boolean", - "default": false, - "description": "Checks whether local node is commissioned or not. If set to true on a local call it will throw exception if node is decommissioned." - } } ], "responses": { @@ -6831,6 +6811,18 @@ "deprecated": true } }, + { + "name": "cluster_manager_timeout", + "in": "query", + "description": "Operation timeout for connection to cluster-manager node.", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "description": "Operation timeout for connection to cluster-manager node.", + "x-version-added": "2.0.0", + "x-data-type": "time" + } + }, { "name": "local", "in": "query", @@ -8536,6 +8528,18 @@ "deprecated": true } }, + { + "name": "cluster_manager_timeout", + "in": "query", + "description": "Operation timeout for connection to cluster-manager node.", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "description": "Operation timeout for connection to cluster-manager node.", + "x-version-added": "2.0.0", + "x-data-type": "time" + } + }, { "name": "local", "in": "query", @@ -18594,6 +18598,18 @@ "deprecated": true } }, + { + "name": "cluster_manager_timeout", + "in": "query", + "description": "Operation timeout for connection to cluster-manager node.", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "description": "Operation timeout for connection to cluster-manager node.", + "x-version-added": "2.0.0", + "x-data-type": "time" + } + }, { "name": "local", "in": "query", @@ -19451,6 +19467,18 @@ "description": "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)." } }, + { + "name": "cluster_manager_timeout", + "in": "query", + "description": "Operation timeout for connection to cluster-manager node.", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "description": "Operation timeout for connection to cluster-manager node.", + "x-version-added": "2.0.0", + "x-data-type": "time" + } + }, { "name": "expand_wildcards", "in": "query", @@ -25302,6 +25330,18 @@ "$ref": "#/components/schemas/ExpandWildcards" } }, + { + "name": "cluster_manager_timeout", + "in": "query", + "description": "Operation timeout for connection to cluster-manager node.", + "schema": { + "type": "string", + "pattern": "^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$", + "description": "Operation timeout for connection to cluster-manager node.", + "x-version-added": "2.0.0", + "x-data-type": "time" + } + }, { "name": "wait_for_active_shards", "in": "query", @@ -26631,7 +26671,8 @@ "description": "Specify the keep alive for point in time.", "schema": { "type": "string", - "description": "Specify the keep alive for point in time." + "description": "Specify the keep alive for point in time.", + "x-data-type": "time" } }, { @@ -30868,6 +30909,7 @@ }, "DeletePit_BodyParams": { "type": "object", + "description": "The point-in-time ids to be deleted", "properties": { "pit_id": { "type": "array", @@ -31170,6 +31212,9 @@ "type": "string" } }, + "dls": { + "type": "string" + }, "fls": { "type": "array", "items": { @@ -31885,19 +31930,22 @@ "description": { "type": "string" }, - "cluster_permission": { + "cluster_permissions": { "type": "array", "items": { "type": "string" } }, - "index_permission": { - "$ref": "#/components/schemas/IndexPermission" + "index_permissions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IndexPermission" + } }, "tenant_permissions": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/TenantPermission" } }, "static": { @@ -32220,6 +32268,23 @@ } } }, + "TenantPermission": { + "type": "object", + "properties": { + "tenant_patterns": { + "type": "array", + "items": { + "type": "string" + } + }, + "allowed_actions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "TenantsMap": { "type": "object", "additionalProperties": { diff --git a/src/ApiGenerator/Views/HighLevel/Descriptors/Descriptors.cshtml b/src/ApiGenerator/Views/HighLevel/Descriptors/Descriptors.cshtml index ca37a794ec..edded9028a 100644 --- a/src/ApiGenerator/Views/HighLevel/Descriptors/Descriptors.cshtml +++ b/src/ApiGenerator/Views/HighLevel/Descriptors/Descriptors.cshtml @@ -17,7 +17,7 @@ using System.Linq.Expressions; using OpenSearch.Net; using OpenSearch.Net.Utf8Json; -@if (ns != CsharpNames.RootNamespace) +@if (ns != null) { using OpenSearch.Net@(ns); diff --git a/src/ApiGenerator/Views/HighLevel/Requests/Requests.cshtml b/src/ApiGenerator/Views/HighLevel/Requests/Requests.cshtml index ccf86d4973..b0eef938ac 100644 --- a/src/ApiGenerator/Views/HighLevel/Requests/Requests.cshtml +++ b/src/ApiGenerator/Views/HighLevel/Requests/Requests.cshtml @@ -17,7 +17,7 @@ using System.Linq.Expressions; using System.Runtime.Serialization; using OpenSearch.Net; using OpenSearch.Net.Utf8Json; -@if (ns != CsharpNames.RootNamespace) +@if (ns != null) { using OpenSearch.Net@(ns); diff --git a/src/OpenSearch.Client/Aggregations/Bucket/Composite/CompositeAggregationSource.cs b/src/OpenSearch.Client/Aggregations/Bucket/Composite/CompositeAggregationSource.cs index fbc79be0f8..db86b3b970 100644 --- a/src/OpenSearch.Client/Aggregations/Bucket/Composite/CompositeAggregationSource.cs +++ b/src/OpenSearch.Client/Aggregations/Bucket/Composite/CompositeAggregationSource.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Linq.Expressions; using System.Runtime.Serialization; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; using OpenSearch.Net.Utf8Json.Resolvers; diff --git a/src/OpenSearch.Client/Cat/CatHelpResponseBuilder.cs b/src/OpenSearch.Client/Cat/CatHelpResponseBuilder.cs index bd70c86fad..84e00c875a 100644 --- a/src/OpenSearch.Client/Cat/CatHelpResponseBuilder.cs +++ b/src/OpenSearch.Client/Cat/CatHelpResponseBuilder.cs @@ -31,6 +31,7 @@ using System.Threading; using System.Threading.Tasks; using OpenSearch.Net; +using OpenSearch.Net.Extensions; namespace OpenSearch.Client.Specification.CatApi { diff --git a/src/OpenSearch.Client/CommonAbstractions/Extensions/Extensions.cs b/src/OpenSearch.Client/CommonAbstractions/Extensions/Extensions.cs index 2e9e7bebde..932b481de5 100644 --- a/src/OpenSearch.Client/CommonAbstractions/Extensions/Extensions.cs +++ b/src/OpenSearch.Client/CommonAbstractions/Extensions/Extensions.cs @@ -114,13 +114,6 @@ internal static string ToEnumValue(this T enumValue) where T : struct return null; } - internal static string Utf8String(this ref ArraySegment segment) => - StringEncoding.UTF8.GetString(segment.Array, segment.Offset, segment.Count); - - internal static string Utf8String(this byte[] bytes) => bytes == null ? null : Encoding.UTF8.GetString(bytes, 0, bytes.Length); - - internal static byte[] Utf8Bytes(this string s) => s.IsNullOrEmpty() ? null : Encoding.UTF8.GetBytes(s); - internal static bool IsNullOrEmpty(this IndexName value) => value == null || value.GetHashCode() == 0; internal static bool IsNullable(this Type type) => diff --git a/src/OpenSearch.Client/CommonOptions/Sorting/SortFormatter.cs b/src/OpenSearch.Client/CommonOptions/Sorting/SortFormatter.cs index 196016fd70..14118e00e5 100644 --- a/src/OpenSearch.Client/CommonOptions/Sorting/SortFormatter.cs +++ b/src/OpenSearch.Client/CommonOptions/Sorting/SortFormatter.cs @@ -27,6 +27,7 @@ */ using System.Collections.Generic; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; using OpenSearch.Net.Utf8Json.Resolvers; diff --git a/src/OpenSearch.Client/Indices/MappingManagement/GetFieldMapping/FieldMappingFormatter.cs b/src/OpenSearch.Client/Indices/MappingManagement/GetFieldMapping/FieldMappingFormatter.cs index c3fb7efc6d..c199dcec34 100644 --- a/src/OpenSearch.Client/Indices/MappingManagement/GetFieldMapping/FieldMappingFormatter.cs +++ b/src/OpenSearch.Client/Indices/MappingManagement/GetFieldMapping/FieldMappingFormatter.cs @@ -27,6 +27,7 @@ */ using System.Collections.Generic; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; using OpenSearch.Net.Utf8Json.Resolvers; diff --git a/src/OpenSearch.Client/OpenSearch.Client.csproj b/src/OpenSearch.Client/OpenSearch.Client.csproj index a338eb97a6..f2519f6e9c 100644 --- a/src/OpenSearch.Client/OpenSearch.Client.csproj +++ b/src/OpenSearch.Client/OpenSearch.Client.csproj @@ -19,6 +19,7 @@ + diff --git a/src/OpenSearch.Client/QueryDsl/Compound/FunctionScore/Functions/ScoreFunctionJsonFormatter.cs b/src/OpenSearch.Client/QueryDsl/Compound/FunctionScore/Functions/ScoreFunctionJsonFormatter.cs index 574d9fbc50..da73d16ca4 100644 --- a/src/OpenSearch.Client/QueryDsl/Compound/FunctionScore/Functions/ScoreFunctionJsonFormatter.cs +++ b/src/OpenSearch.Client/QueryDsl/Compound/FunctionScore/Functions/ScoreFunctionJsonFormatter.cs @@ -28,6 +28,7 @@ using System; using OpenSearch.Net; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; diff --git a/src/OpenSearch.Client/QueryDsl/Geo/BoundingBox/GeoBoundingBoxQuery.cs b/src/OpenSearch.Client/QueryDsl/Geo/BoundingBox/GeoBoundingBoxQuery.cs index 0a163437c2..18247687e9 100644 --- a/src/OpenSearch.Client/QueryDsl/Geo/BoundingBox/GeoBoundingBoxQuery.cs +++ b/src/OpenSearch.Client/QueryDsl/Geo/BoundingBox/GeoBoundingBoxQuery.cs @@ -27,6 +27,7 @@ */ using System; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; diff --git a/src/OpenSearch.Client/QueryDsl/Geo/Distance/GeoDistanceQuery.cs b/src/OpenSearch.Client/QueryDsl/Geo/Distance/GeoDistanceQuery.cs index ff41ecaff5..a68e386966 100644 --- a/src/OpenSearch.Client/QueryDsl/Geo/Distance/GeoDistanceQuery.cs +++ b/src/OpenSearch.Client/QueryDsl/Geo/Distance/GeoDistanceQuery.cs @@ -26,6 +26,7 @@ * under the License. */ +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; diff --git a/src/OpenSearch.Client/QueryDsl/Geo/Polygon/GeoPolygonQuery.cs b/src/OpenSearch.Client/QueryDsl/Geo/Polygon/GeoPolygonQuery.cs index 6aa633ce07..24f0c96b0c 100644 --- a/src/OpenSearch.Client/QueryDsl/Geo/Polygon/GeoPolygonQuery.cs +++ b/src/OpenSearch.Client/QueryDsl/Geo/Polygon/GeoPolygonQuery.cs @@ -27,6 +27,7 @@ */ using System.Collections.Generic; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; diff --git a/src/OpenSearch.Client/QueryDsl/Geo/Shape/GeoShapeQueryFormatter.cs b/src/OpenSearch.Client/QueryDsl/Geo/Shape/GeoShapeQueryFormatter.cs index 78530db7d7..b1d210c3d1 100644 --- a/src/OpenSearch.Client/QueryDsl/Geo/Shape/GeoShapeQueryFormatter.cs +++ b/src/OpenSearch.Client/QueryDsl/Geo/Shape/GeoShapeQueryFormatter.cs @@ -27,6 +27,7 @@ */ using System; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; diff --git a/src/OpenSearch.Client/QueryDsl/Specialized/Shape/CartesianPoint.cs b/src/OpenSearch.Client/QueryDsl/Specialized/Shape/CartesianPoint.cs index 763c77c11f..0001b8bc0a 100644 --- a/src/OpenSearch.Client/QueryDsl/Specialized/Shape/CartesianPoint.cs +++ b/src/OpenSearch.Client/QueryDsl/Specialized/Shape/CartesianPoint.cs @@ -32,6 +32,7 @@ using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; using OpenSearch.Client; +using OpenSearch.Net.Extensions; namespace OpenSearch.Client { diff --git a/src/OpenSearch.Client/QueryDsl/Specialized/Shape/ShapeQueryFormatter.cs b/src/OpenSearch.Client/QueryDsl/Specialized/Shape/ShapeQueryFormatter.cs index 90c2ffdc73..0660c89fd7 100644 --- a/src/OpenSearch.Client/QueryDsl/Specialized/Shape/ShapeQueryFormatter.cs +++ b/src/OpenSearch.Client/QueryDsl/Specialized/Shape/ShapeQueryFormatter.cs @@ -27,6 +27,7 @@ */ using System; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; diff --git a/src/OpenSearch.Client/QueryDsl/TermLevel/Terms/TermsQueryFormatter.cs b/src/OpenSearch.Client/QueryDsl/TermLevel/Terms/TermsQueryFormatter.cs index d4c177aa20..b4d12d8ffb 100644 --- a/src/OpenSearch.Client/QueryDsl/TermLevel/Terms/TermsQueryFormatter.cs +++ b/src/OpenSearch.Client/QueryDsl/TermLevel/Terms/TermsQueryFormatter.cs @@ -27,6 +27,7 @@ */ using System.Collections.Generic; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Internal; diff --git a/src/OpenSearch.Client/Search/PointInTime/CreatePitRequest.cs b/src/OpenSearch.Client/Search/PointInTime/CreatePitRequest.cs new file mode 100644 index 0000000000..7db0af0408 --- /dev/null +++ b/src/OpenSearch.Client/Search/PointInTime/CreatePitRequest.cs @@ -0,0 +1,16 @@ +/* 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("create_pit")] +[ReadAs(typeof(CreatePitRequest))] +public partial interface ICreatePitRequest { } + +public partial class CreatePitRequest { } + +public partial class CreatePitDescriptor { } diff --git a/src/OpenSearch.Client/Search/PointInTime/CreatePitResponse.cs b/src/OpenSearch.Client/Search/PointInTime/CreatePitResponse.cs new file mode 100644 index 0000000000..13d1fe8660 --- /dev/null +++ b/src/OpenSearch.Client/Search/PointInTime/CreatePitResponse.cs @@ -0,0 +1,23 @@ +/* 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 CreatePitResponse : ResponseBase +{ + [DataMember(Name = "pit_id")] + public string PitId { get; internal set; } + + [DataMember(Name = "_shards")] + public ShardStatistics Shards { get; internal set; } + + [DataMember(Name = "creation_time")] + public long CreationTime { get; internal set; } +} diff --git a/src/OpenSearch.Client/Search/PointInTime/DeleteAllPitsRequest.cs b/src/OpenSearch.Client/Search/PointInTime/DeleteAllPitsRequest.cs new file mode 100644 index 0000000000..a45efd2716 --- /dev/null +++ b/src/OpenSearch.Client/Search/PointInTime/DeleteAllPitsRequest.cs @@ -0,0 +1,16 @@ +/* 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("delete_all_pits")] +[ReadAs(typeof(DeleteAllPitsRequest))] +public partial interface IDeleteAllPitsRequest { } + +public partial class DeleteAllPitsRequest { } + +public partial class DeleteAllPitsDescriptor { } diff --git a/src/OpenSearch.Client/Search/PointInTime/DeleteAllPitsResponse.cs b/src/OpenSearch.Client/Search/PointInTime/DeleteAllPitsResponse.cs new file mode 100644 index 0000000000..fa86aeedb2 --- /dev/null +++ b/src/OpenSearch.Client/Search/PointInTime/DeleteAllPitsResponse.cs @@ -0,0 +1,18 @@ +/* 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 DeleteAllPitsResponse : ResponseBase +{ + [DataMember(Name = "pits")] + public IReadOnlyCollection Pits { get; internal set; } +} diff --git a/src/OpenSearch.Client/Search/PointInTime/DeletePitRequest.cs b/src/OpenSearch.Client/Search/PointInTime/DeletePitRequest.cs new file mode 100644 index 0000000000..456d18a6e8 --- /dev/null +++ b/src/OpenSearch.Client/Search/PointInTime/DeletePitRequest.cs @@ -0,0 +1,40 @@ +/* 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.Linq; +using System.Runtime.Serialization; + +namespace OpenSearch.Client; + +[MapsApi("delete_pit")] +[ReadAs(typeof(DeletePitRequest))] +public partial interface IDeletePitRequest +{ + [DataMember(Name = "pit_id")] + IEnumerable PitId { get; set; } +} + +public partial class DeletePitRequest +{ + public DeletePitRequest(IEnumerable pitId) : this(pitId?.ToArray()) { } + + public DeletePitRequest(params string[] pitId) => PitId = pitId; + + public IEnumerable PitId { get; set; } +} + +public partial class DeletePitDescriptor +{ + IEnumerable IDeletePitRequest.PitId { get; set; } + + public DeletePitDescriptor PitId(IEnumerable pitId) => + Assign(pitId?.ToArray(), (r, v) => r.PitId = v); + + public DeletePitDescriptor PitId(params string[] pitId) => + Assign(pitId, (r, v) => r.PitId = v); +} diff --git a/src/OpenSearch.Client/Search/PointInTime/DeletePitResponse.cs b/src/OpenSearch.Client/Search/PointInTime/DeletePitResponse.cs new file mode 100644 index 0000000000..7324c22e9b --- /dev/null +++ b/src/OpenSearch.Client/Search/PointInTime/DeletePitResponse.cs @@ -0,0 +1,29 @@ +/* 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; +using OpenSearch.Net; + +namespace OpenSearch.Client; + +[DataContract] +public class DeletePitResponse : ResponseBase +{ + [DataMember(Name = "pits")] + public IReadOnlyCollection Pits { get; internal set; } = EmptyReadOnly.Collection; +} + +[DataContract] +public class DeletedPit +{ + [DataMember(Name = "pit_id")] + public string PitId { get; set; } + + [DataMember(Name = "successful")] + public bool Successful { get; set; } +} diff --git a/src/OpenSearch.Client/Search/PointInTime/GetAllPitsRequest.cs b/src/OpenSearch.Client/Search/PointInTime/GetAllPitsRequest.cs new file mode 100644 index 0000000000..8a777b3463 --- /dev/null +++ b/src/OpenSearch.Client/Search/PointInTime/GetAllPitsRequest.cs @@ -0,0 +1,16 @@ +/* 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("get_all_pits")] +[ReadAs(typeof(GetAllPitsRequest))] +public partial interface IGetAllPitsRequest { } + +public partial class GetAllPitsRequest { } + +public partial class GetAllPitsDescriptor { } diff --git a/src/OpenSearch.Client/Search/PointInTime/GetAllPitsResponse.cs b/src/OpenSearch.Client/Search/PointInTime/GetAllPitsResponse.cs new file mode 100644 index 0000000000..a179c63f09 --- /dev/null +++ b/src/OpenSearch.Client/Search/PointInTime/GetAllPitsResponse.cs @@ -0,0 +1,31 @@ +/* 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 GetAllPitsResponse : ResponseBase +{ + [DataMember(Name = "pits")] + public IReadOnlyCollection Pits { get; internal set; } +} + +[DataContract] +public class PitDetail +{ + [DataMember(Name = "pit_id")] + public string PitId { get; internal set; } + + [DataMember(Name = "creation_time")] + public long CreationTime { get; internal set; } + + [DataMember(Name = "keep_alive")] + public long KeepAlive { get; internal set; } +} diff --git a/src/OpenSearch.Client/Search/Search/PointInTime/PointInTime.cs b/src/OpenSearch.Client/Search/Search/PointInTime/PointInTime.cs new file mode 100644 index 0000000000..53a8eb2aec --- /dev/null +++ b/src/OpenSearch.Client/Search/Search/PointInTime/PointInTime.cs @@ -0,0 +1,36 @@ +/* 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; + +[ReadAs(typeof(PointInTime))] +public interface IPointInTime +{ + [DataMember(Name = "id")] + string Id { get; set; } + + [DataMember(Name = "keep_alive")] + Time KeepAlive { get; set; } +} + +public class PointInTime : IPointInTime +{ + public string Id { get; set; } + public Time KeepAlive { get; set; } +} + +public class PointInTimeDescriptor : DescriptorBase, IPointInTime +{ + string IPointInTime.Id { get; set; } + Time IPointInTime.KeepAlive { get; set; } + + public PointInTimeDescriptor Id(string id) => Assign(id, (a, v) => a.Id = v); + + public PointInTimeDescriptor KeepAlive(Time keepAlive) => Assign(keepAlive, (a, v) => a.KeepAlive = v); +} diff --git a/src/OpenSearch.Client/Search/Search/SearchRequest.cs b/src/OpenSearch.Client/Search/Search/SearchRequest.cs index e5863fed8d..47e688ed66 100644 --- a/src/OpenSearch.Client/Search/Search/SearchRequest.cs +++ b/src/OpenSearch.Client/Search/Search/SearchRequest.cs @@ -97,6 +97,17 @@ public partial interface ISearchRequest : ITypedSearchRequest [DataMember(Name = "min_score")] double? MinScore { get; set; } + /// + /// Search against a dataset frozen at a point-in-time (PIT) + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time/ + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + /// + /// + [DataMember(Name = "pit")] + IPointInTime PointInTime { get; set; } + /// /// Specify a query to apply to the search hits at the very end of a search request, /// after aggregations have already been calculated. Useful when both search hits and aggregations @@ -240,6 +251,8 @@ public partial class SearchRequest /// public double? MinScore { get; set; } /// + public IPointInTime PointInTime { get; set; } + /// public QueryContainer PostFilter { get; set; } /// public bool? Profile { get; set; } @@ -285,10 +298,7 @@ public partial class SearchRequest protected sealed override void RequestDefaults(SearchRequestParameters parameters) => TypedKeys = true; - protected override string ResolveUrl(RouteValues routeValues, IConnectionSettingsValues settings) - { - return base.ResolveUrl(routeValues, settings); - } + protected override string ResolveUrl(RouteValues routeValues, IConnectionSettingsValues settings) => base.ResolveUrl(routeValues, settings); } [DataContract] @@ -318,6 +328,7 @@ public partial class SearchDescriptor where TInferDocument : cla IHighlight ISearchRequest.Highlight { get; set; } IDictionary ISearchRequest.IndicesBoost { get; set; } double? ISearchRequest.MinScore { get; set; } + IPointInTime ISearchRequest.PointInTime { get; set; } QueryContainer ISearchRequest.PostFilter { get; set; } bool? ISearchRequest.Profile { get; set; } QueryContainer ISearchRequest.Query { get; set; } @@ -519,9 +530,14 @@ public SearchDescriptor RuntimeFields(Func RuntimeFields(Func, IPromise> runtimeFieldsSelector) where TSource : class => Assign(runtimeFieldsSelector, (a, v) => a.RuntimeFields = v?.Invoke(new RuntimeFieldsDescriptor())?.Value); - protected override string ResolveUrl(RouteValues routeValues, IConnectionSettingsValues settings) - { - return base.ResolveUrl(routeValues, settings); - } + /// + public SearchDescriptor PointInTime(Func selector) => + Assign(selector, (a, v) => + { + a.PointInTime = v?.Invoke(new PointInTimeDescriptor()); + if (a.PointInTime != null) a.RouteValues.Remove("index"); + }); + + protected override string ResolveUrl(RouteValues routeValues, IConnectionSettingsValues settings) => base.ResolveUrl(routeValues, settings); } } diff --git a/src/OpenSearch.Client/Snapshot/Repositories/GetRepository/GetRepositoryResponseFormatter.cs b/src/OpenSearch.Client/Snapshot/Repositories/GetRepository/GetRepositoryResponseFormatter.cs index 4bd14d845f..ec1f49b262 100644 --- a/src/OpenSearch.Client/Snapshot/Repositories/GetRepository/GetRepositoryResponseFormatter.cs +++ b/src/OpenSearch.Client/Snapshot/Repositories/GetRepository/GetRepositoryResponseFormatter.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using OpenSearch.Net; +using OpenSearch.Net.Extensions; using OpenSearch.Net.Utf8Json; using OpenSearch.Net.Utf8Json.Resolvers; diff --git a/src/OpenSearch.Client/_Generated/ApiUrlsLookup.cs b/src/OpenSearch.Client/_Generated/ApiUrlsLookup.cs index db47501d1f..9510d7bec1 100644 --- a/src/OpenSearch.Client/_Generated/ApiUrlsLookup.cs +++ b/src/OpenSearch.Client/_Generated/ApiUrlsLookup.cs @@ -59,6 +59,9 @@ internal static partial class ApiUrlsLookups internal static readonly ApiUrls ClusterPendingTasks = new(new[] { "_cluster/pending_tasks" }); + internal static readonly ApiUrls NoNamespaceCreatePit = + new(new[] { "{index}/_search/point_in_time" }); + internal static readonly ApiUrls DanglingIndicesDeleteDanglingIndex = new(new[] { "_dangling/{index_uuid}" }); @@ -67,6 +70,15 @@ internal static partial class ApiUrlsLookups internal static readonly ApiUrls DanglingIndicesList = new(new[] { "_dangling" }); + internal static readonly ApiUrls NoNamespaceDeleteAllPits = + new(new[] { "_search/point_in_time/_all" }); + + internal static readonly ApiUrls NoNamespaceDeletePit = + new(new[] { "_search/point_in_time" }); + + internal static readonly ApiUrls NoNamespaceGetAllPits = + new(new[] { "_search/point_in_time/_all" }); + internal static readonly ApiUrls IngestDeletePipeline = new(new[] { "_ingest/pipeline/{id}" }); diff --git a/src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs b/src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs index 234b1b72ae..2eb94a0396 100644 --- a/src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs +++ b/src/OpenSearch.Client/_Generated/Descriptors.Cluster.cs @@ -185,11 +185,6 @@ public ClusterHealthDescriptor ClusterHealthLevel(ClusterHealthLevel? clusterhea public ClusterHealthDescriptor ClusterManagerTimeout(Time clustermanagertimeout) => Qs("cluster_manager_timeout", clustermanagertimeout); - /// Checks whether local node is commissioned or not. If set to true on a local call it will throw exception if node is decommissioned. - public ClusterHealthDescriptor EnsureNodeCommissioned( - bool? ensurenodecommissioned = true - ) => Qs("ensure_node_commissioned", ensurenodecommissioned); - /// Whether to expand wildcard expression to concrete indices that are open, closed or both. public ClusterHealthDescriptor ExpandWildcards(ExpandWildcards? expandwildcards) => Qs("expand_wildcards", expandwildcards); diff --git a/src/OpenSearch.Client/_Generated/Descriptors.NoNamespace.cs b/src/OpenSearch.Client/_Generated/Descriptors.NoNamespace.cs new file mode 100644 index 0000000000..3eb30c27c2 --- /dev/null +++ b/src/OpenSearch.Client/_Generated/Descriptors.NoNamespace.cs @@ -0,0 +1,154 @@ +/* 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. +*/ +/* +* Modifications Copyright OpenSearch Contributors. See +* GitHub history for details. +* +* Licensed to Elasticsearch B.V. under one or more contributor +* license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright +* ownership. Elasticsearch B.V. licenses this file to you under +* the Apache License, Version 2.0 (the "License"); you may +* not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Linq.Expressions; + +using OpenSearch.Net; +using OpenSearch.Net.Utf8Json; + +// ReSharper disable RedundantBaseConstructorCall +// ReSharper disable UnusedTypeParameter +// ReSharper disable PartialMethodWithSinglePart +// ReSharper disable RedundantNameQualifier +namespace OpenSearch.Client +{ + /// Descriptor for CreatePit https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + public partial class CreatePitDescriptor + : RequestDescriptorBase, + ICreatePitRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceCreatePit; + + /// /{index}/_search/point_in_time + /// this parameter is required + public CreatePitDescriptor(Indices index) + : base(r => r.Required("index", index)) { } + + /// Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected CreatePitDescriptor() + : base() { } + + // values part of the url path + Indices ICreatePitRequest.Index => Self.RouteValues.Get("index"); + + /// Comma-separated list of indices; use the special string `_all` or Indices.All to perform the operation on all indices. + public CreatePitDescriptor Index(Indices index) => + Assign(index, (a, v) => a.RouteValues.Required("index", v)); + + /// a shortcut into calling Index(typeof(TOther)) + public CreatePitDescriptor Index() + where TOther : class => + Assign(typeof(TOther), (a, v) => a.RouteValues.Required("index", (Indices)v)); + + /// A shortcut into calling Index(Indices.All) + public CreatePitDescriptor AllIndices() => Index(Indices.All); + + // Request parameters + /// Allow if point in time can be created with partial failures. + public CreatePitDescriptor AllowPartialPitCreation(bool? allowpartialpitcreation = true) => + Qs("allow_partial_pit_creation", allowpartialpitcreation); + + /// Whether to expand wildcard expression to concrete indices that are open, closed or both. + public CreatePitDescriptor ExpandWildcards(ExpandWildcards? expandwildcards) => + Qs("expand_wildcards", expandwildcards); + + /// Specify the keep alive for point in time. + public CreatePitDescriptor KeepAlive(Time keepalive) => Qs("keep_alive", keepalive); + + /// Specify the node or shard the operation should be performed on. + public CreatePitDescriptor Preference(string preference) => Qs("preference", preference); + + /// + /// A document is routed to a particular shard in an index using the following formula + /// shard_num = hash(_routing) % num_primary_shards + /// OpenSearch will use the document id if not provided. + /// For requests that are constructed from/for a document OpenSearch.Client will automatically infer the routing key + /// if that document has a or a routing mapping on for its type exists on + /// + public CreatePitDescriptor Routing(Routing routing) => Qs("routing", routing); + } + + /// Descriptor for DeleteAllPits https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + public partial class DeleteAllPitsDescriptor + : RequestDescriptorBase< + DeleteAllPitsDescriptor, + DeleteAllPitsRequestParameters, + IDeleteAllPitsRequest + >, + IDeleteAllPitsRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceDeleteAllPits; + // values part of the url path + // Request parameters + } + + /// Descriptor for DeletePit https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + public partial class DeletePitDescriptor + : RequestDescriptorBase, + IDeletePitRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceDeletePit; + // values part of the url path + // Request parameters + } + + /// Descriptor for GetAllPits https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#list-all-pits + public partial class GetAllPitsDescriptor + : RequestDescriptorBase< + GetAllPitsDescriptor, + GetAllPitsRequestParameters, + IGetAllPitsRequest + >, + IGetAllPitsRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceGetAllPits; + // values part of the url path + // Request parameters + } +} diff --git a/src/OpenSearch.Client/_Generated/IOpenSearchClient.cs b/src/OpenSearch.Client/_Generated/IOpenSearchClient.cs index a6fbe1df5b..8fa9a0bccc 100644 --- a/src/OpenSearch.Client/_Generated/IOpenSearchClient.cs +++ b/src/OpenSearch.Client/_Generated/IOpenSearchClient.cs @@ -74,6 +74,166 @@ public partial interface IOpenSearchClient /// Nodes APIs NodesNamespace Nodes { get; } + /// + /// POST request to the create_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + CreatePitResponse CreatePit( + Indices index, + Func selector = null + ); + + /// + /// POST request to the create_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + Task CreatePitAsync( + Indices index, + Func selector = null, + CancellationToken ct = default + ); + + /// + /// POST request to the create_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + CreatePitResponse CreatePit(ICreatePitRequest request); + + /// + /// POST request to the create_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + Task CreatePitAsync( + ICreatePitRequest request, + CancellationToken ct = default + ); + + /// + /// DELETE request to the delete_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + DeleteAllPitsResponse DeleteAllPits( + Func selector = null + ); + + /// + /// DELETE request to the delete_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + Task DeleteAllPitsAsync( + Func selector = null, + CancellationToken ct = default + ); + + /// + /// DELETE request to the delete_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + DeleteAllPitsResponse DeleteAllPits(IDeleteAllPitsRequest request); + + /// + /// DELETE request to the delete_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + Task DeleteAllPitsAsync( + IDeleteAllPitsRequest request, + CancellationToken ct = default + ); + + /// + /// DELETE request to the delete_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + DeletePitResponse DeletePit(Func selector = null); + + /// + /// DELETE request to the delete_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + Task DeletePitAsync( + Func selector = null, + CancellationToken ct = default + ); + + /// + /// DELETE request to the delete_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + DeletePitResponse DeletePit(IDeletePitRequest request); + + /// + /// DELETE request to the delete_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + Task DeletePitAsync( + IDeletePitRequest request, + CancellationToken ct = default + ); + + /// + /// GET request to the get_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#list-all-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + GetAllPitsResponse GetAllPits( + Func selector = null + ); + + /// + /// GET request to the get_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#list-all-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + Task GetAllPitsAsync( + Func selector = null, + CancellationToken ct = default + ); + + /// + /// GET request to the get_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#list-all-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + GetAllPitsResponse GetAllPits(IGetAllPitsRequest request); + + /// + /// GET request to the get_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#list-all-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + Task GetAllPitsAsync( + IGetAllPitsRequest request, + CancellationToken ct = default + ); + /// Snapshot APIs SnapshotNamespace Snapshot { get; } diff --git a/src/OpenSearch.Client/_Generated/OpenSearchClient.cs b/src/OpenSearch.Client/_Generated/OpenSearchClient.cs index fa5f242a9e..1d52dc3340 100644 --- a/src/OpenSearch.Client/_Generated/OpenSearchClient.cs +++ b/src/OpenSearch.Client/_Generated/OpenSearchClient.cs @@ -88,5 +88,194 @@ partial void SetupGeneratedNamespaces() Snapshot = new SnapshotNamespace(this); Tasks = new TasksNamespace(this); } + + /// + /// POST request to the create_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public CreatePitResponse CreatePit( + Indices index, + Func selector = null + ) => CreatePit(selector.InvokeOrDefault(new CreatePitDescriptor(index: index))); + + /// + /// POST request to the create_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public Task CreatePitAsync( + Indices index, + Func selector = null, + CancellationToken ct = default + ) => CreatePitAsync(selector.InvokeOrDefault(new CreatePitDescriptor(index: index)), ct); + + /// + /// POST request to the create_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public CreatePitResponse CreatePit(ICreatePitRequest request) => + DoRequest(request, request.RequestParameters); + + /// + /// POST request to the create_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public Task CreatePitAsync( + ICreatePitRequest request, + CancellationToken ct = default + ) => + DoRequestAsync( + request, + request.RequestParameters, + ct + ); + + /// + /// DELETE request to the delete_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public DeleteAllPitsResponse DeleteAllPits( + Func selector = null + ) => DeleteAllPits(selector.InvokeOrDefault(new DeleteAllPitsDescriptor())); + + /// + /// DELETE request to the delete_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public Task DeleteAllPitsAsync( + Func selector = null, + CancellationToken ct = default + ) => DeleteAllPitsAsync(selector.InvokeOrDefault(new DeleteAllPitsDescriptor()), ct); + + /// + /// DELETE request to the delete_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public DeleteAllPitsResponse DeleteAllPits(IDeleteAllPitsRequest request) => + DoRequest( + request, + request.RequestParameters + ); + + /// + /// DELETE request to the delete_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public Task DeleteAllPitsAsync( + IDeleteAllPitsRequest request, + CancellationToken ct = default + ) => + DoRequestAsync( + request, + request.RequestParameters, + ct + ); + + /// + /// DELETE request to the delete_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public DeletePitResponse DeletePit( + Func selector = null + ) => DeletePit(selector.InvokeOrDefault(new DeletePitDescriptor())); + + /// + /// DELETE request to the delete_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public Task DeletePitAsync( + Func selector = null, + CancellationToken ct = default + ) => DeletePitAsync(selector.InvokeOrDefault(new DeletePitDescriptor()), ct); + + /// + /// DELETE request to the delete_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public DeletePitResponse DeletePit(IDeletePitRequest request) => + DoRequest(request, request.RequestParameters); + + /// + /// DELETE request to the delete_pit API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#delete-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public Task DeletePitAsync( + IDeletePitRequest request, + CancellationToken ct = default + ) => + DoRequestAsync( + request, + request.RequestParameters, + ct + ); + + /// + /// GET request to the get_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#list-all-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public GetAllPitsResponse GetAllPits( + Func selector = null + ) => GetAllPits(selector.InvokeOrDefault(new GetAllPitsDescriptor())); + + /// + /// GET request to the get_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#list-all-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public Task GetAllPitsAsync( + Func selector = null, + CancellationToken ct = default + ) => GetAllPitsAsync(selector.InvokeOrDefault(new GetAllPitsDescriptor()), ct); + + /// + /// GET request to the get_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#list-all-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public GetAllPitsResponse GetAllPits(IGetAllPitsRequest request) => + DoRequest(request, request.RequestParameters); + + /// + /// GET request to the get_all_pits API, read more about this API online: + /// + /// https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#list-all-pits + /// + /// Supported by OpenSearch servers of version 2.4.0 or greater. + public Task GetAllPitsAsync( + IGetAllPitsRequest 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 fe5fb86e91..4a667a102c 100644 --- a/src/OpenSearch.Client/_Generated/Requests.Cluster.cs +++ b/src/OpenSearch.Client/_Generated/Requests.Cluster.cs @@ -217,13 +217,6 @@ public Time ClusterManagerTimeout set => Q("cluster_manager_timeout", value); } - /// Checks whether local node is commissioned or not. If set to true on a local call it will throw exception if node is decommissioned. - public bool? EnsureNodeCommissioned - { - get => Q("ensure_node_commissioned"); - set => Q("ensure_node_commissioned", value); - } - /// Whether to expand wildcard expression to concrete indices that are open, closed or both. public ExpandWildcards? ExpandWildcards { diff --git a/src/OpenSearch.Client/_Generated/Requests.NoNamespace.cs b/src/OpenSearch.Client/_Generated/Requests.NoNamespace.cs new file mode 100644 index 0000000000..5ab1abdbcd --- /dev/null +++ b/src/OpenSearch.Client/_Generated/Requests.NoNamespace.cs @@ -0,0 +1,177 @@ +/* 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. +*/ +/* +* Modifications Copyright OpenSearch Contributors. See +* GitHub history for details. +* +* Licensed to Elasticsearch B.V. under one or more contributor +* license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright +* ownership. Elasticsearch B.V. licenses this file to you under +* the Apache License, Version 2.0 (the "License"); you may +* not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Linq.Expressions; +using System.Runtime.Serialization; +using OpenSearch.Net; +using OpenSearch.Net.Utf8Json; + +// ReSharper disable RedundantBaseConstructorCall +// ReSharper disable UnusedTypeParameter +// ReSharper disable PartialMethodWithSinglePart +// ReSharper disable RedundantNameQualifier +namespace OpenSearch.Client +{ + [InterfaceDataContract] + public partial interface ICreatePitRequest : IRequest + { + [IgnoreDataMember] + Indices Index { get; } + } + + /// Request for CreatePit https://opensearch.org/docs/latest/search-plugins/point-in-time-api/#create-a-pit + public partial class CreatePitRequest + : PlainRequestBase, + ICreatePitRequest + { + protected ICreatePitRequest Self => this; + internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceCreatePit; + + /// /{index}/_search/point_in_time + /// this parameter is required + public CreatePitRequest(Indices index) + : base(r => r.Required("index", index)) { } + + /// Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected CreatePitRequest() + : base() { } + + // values part of the url path + [IgnoreDataMember] + Indices ICreatePitRequest.Index => Self.RouteValues.Get("index"); + + // Request parameters + /// Allow if point in time can be created with partial failures. + public bool? AllowPartialPitCreation + { + get => Q("allow_partial_pit_creation"); + set => Q("allow_partial_pit_creation", value); + } + + /// Whether to expand wildcard expression to concrete indices that are open, closed or both. + public ExpandWildcards? ExpandWildcards + { + get => Q("expand_wildcards"); + set => Q("expand_wildcards", value); + } + + /// Specify the keep alive for point in time. + public Time KeepAlive + { + get => Q