From 621ed0cff64fbab0c0126a06fe8150b420bfbae6 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 6 Sep 2024 11:36:58 +1200 Subject: [PATCH 01/11] Fix codegen integer handling Signed-off-by: Thomas Farr --- java-codegen/opensearch-openapi.yaml | 1905 ++++++++++++----- .../client/codegen/model/SpecTransformer.java | 23 +- .../client/codegen/openapi/OpenApiSchema.java | 4 + 3 files changed, 1450 insertions(+), 482 deletions(-) diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index 889bedbbdf..90a04f5f5f 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -1501,34 +1501,6 @@ paths: responses: '200': $ref: '#/components/responses/nodes.hot_threads@200' - /_cluster/nodes/{node_id}/hotthreads: - get: - operationId: nodes.hot_threads.3 - x-operation-group: nodes.hot_threads - x-ignorable: true - deprecated: true - x-deprecation-message: The hot threads API accepts `hotthreads` but only `hot_threads` is documented - x-version-added: '1.0' - x-version-deprecated: '1.0' - description: Returns information about hot threads on each node in the cluster. - externalDocs: - url: https://opensearch.org/docs/latest/api-reference/nodes-apis/nodes-hot-threads/ - parameters: - - $ref: '#/components/parameters/nodes.hot_threads::path.node_id' - - $ref: '#/components/parameters/nodes.hot_threads::query.ignore_idle_threads' - - $ref: '#/components/parameters/nodes.hot_threads::query.interval' - - $ref: '#/components/parameters/nodes.hot_threads::query.snapshots' - - $ref: '#/components/parameters/nodes.hot_threads::query.threads' - - $ref: '#/components/parameters/nodes.hot_threads::query.timeout' - - $ref: '#/components/parameters/nodes.hot_threads::query.type' - - $ref: '#/components/parameters/_global::query.pretty' - - $ref: '#/components/parameters/_global::query.human' - - $ref: '#/components/parameters/_global::query.error_trace' - - $ref: '#/components/parameters/_global::query.source' - - $ref: '#/components/parameters/_global::query.filter_path' - responses: - '200': - $ref: '#/components/responses/nodes.hot_threads@200' /_cluster/nodes/hot_threads: get: operationId: nodes.hot_threads.0 @@ -1556,33 +1528,6 @@ paths: responses: '200': $ref: '#/components/responses/nodes.hot_threads@200' - /_cluster/nodes/hotthreads: - get: - operationId: nodes.hot_threads.1 - x-operation-group: nodes.hot_threads - x-ignorable: true - deprecated: true - x-deprecation-message: The hot threads API accepts `hotthreads` but only `hot_threads` is documented - x-version-added: '1.0' - x-version-deprecated: '1.0' - description: Returns information about hot threads on each node in the cluster. - externalDocs: - url: https://opensearch.org/docs/latest/api-reference/nodes-apis/nodes-hot-threads/ - parameters: - - $ref: '#/components/parameters/nodes.hot_threads::query.ignore_idle_threads' - - $ref: '#/components/parameters/nodes.hot_threads::query.interval' - - $ref: '#/components/parameters/nodes.hot_threads::query.snapshots' - - $ref: '#/components/parameters/nodes.hot_threads::query.threads' - - $ref: '#/components/parameters/nodes.hot_threads::query.timeout' - - $ref: '#/components/parameters/nodes.hot_threads::query.type' - - $ref: '#/components/parameters/_global::query.pretty' - - $ref: '#/components/parameters/_global::query.human' - - $ref: '#/components/parameters/_global::query.error_trace' - - $ref: '#/components/parameters/_global::query.source' - - $ref: '#/components/parameters/_global::query.filter_path' - responses: - '200': - $ref: '#/components/responses/nodes.hot_threads@200' /_cluster/pending_tasks: get: operationId: cluster.pending_tasks.0 @@ -1663,6 +1608,8 @@ paths: - $ref: '#/components/parameters/_global::query.error_trace' - $ref: '#/components/parameters/_global::query.source' - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/cluster.put_weighted_routing' responses: '200': $ref: '#/components/responses/cluster.put_weighted_routing@200' @@ -1674,6 +1621,8 @@ paths: description: Delete weighted shard routing weights. externalDocs: url: https://opensearch.org/docs/latest/api-reference/cluster-api/cluster-awareness/#example-deleting-weights + requestBody: + $ref: '#/components/requestBodies/cluster.delete_weighted_routing' responses: '200': $ref: '#/components/responses/cluster.delete_weighted_routing@200' @@ -3101,34 +3050,6 @@ paths: responses: '200': $ref: '#/components/responses/nodes.hot_threads@200' - /_nodes/{node_id}/hotthreads: - get: - operationId: nodes.hot_threads.7 - x-operation-group: nodes.hot_threads - x-ignorable: true - deprecated: true - x-deprecation-message: The hot threads API accepts `hotthreads` but only `hot_threads` is documented - x-version-added: '1.0' - x-version-deprecated: '1.0' - description: Returns information about hot threads on each node in the cluster. - externalDocs: - url: https://opensearch.org/docs/latest/api-reference/nodes-apis/nodes-hot-threads/ - parameters: - - $ref: '#/components/parameters/nodes.hot_threads::path.node_id' - - $ref: '#/components/parameters/nodes.hot_threads::query.ignore_idle_threads' - - $ref: '#/components/parameters/nodes.hot_threads::query.interval' - - $ref: '#/components/parameters/nodes.hot_threads::query.snapshots' - - $ref: '#/components/parameters/nodes.hot_threads::query.threads' - - $ref: '#/components/parameters/nodes.hot_threads::query.timeout' - - $ref: '#/components/parameters/nodes.hot_threads::query.type' - - $ref: '#/components/parameters/_global::query.pretty' - - $ref: '#/components/parameters/_global::query.human' - - $ref: '#/components/parameters/_global::query.error_trace' - - $ref: '#/components/parameters/_global::query.source' - - $ref: '#/components/parameters/_global::query.filter_path' - responses: - '200': - $ref: '#/components/responses/nodes.hot_threads@200' /_nodes/{node_id}/reload_secure_settings: post: operationId: nodes.reload_secure_settings.1 @@ -3293,33 +3214,6 @@ paths: responses: '200': $ref: '#/components/responses/nodes.hot_threads@200' - /_nodes/hotthreads: - get: - operationId: nodes.hot_threads.5 - x-operation-group: nodes.hot_threads - x-ignorable: true - deprecated: true - x-deprecation-message: The hot threads API accepts `hotthreads` but only `hot_threads` is documented - x-version-added: '1.0' - x-version-deprecated: '1.0' - description: Returns information about hot threads on each node in the cluster. - externalDocs: - url: https://opensearch.org/docs/latest/api-reference/nodes-apis/nodes-hot-threads/ - parameters: - - $ref: '#/components/parameters/nodes.hot_threads::query.ignore_idle_threads' - - $ref: '#/components/parameters/nodes.hot_threads::query.interval' - - $ref: '#/components/parameters/nodes.hot_threads::query.snapshots' - - $ref: '#/components/parameters/nodes.hot_threads::query.threads' - - $ref: '#/components/parameters/nodes.hot_threads::query.timeout' - - $ref: '#/components/parameters/nodes.hot_threads::query.type' - - $ref: '#/components/parameters/_global::query.pretty' - - $ref: '#/components/parameters/_global::query.human' - - $ref: '#/components/parameters/_global::query.error_trace' - - $ref: '#/components/parameters/_global::query.source' - - $ref: '#/components/parameters/_global::query.filter_path' - responses: - '200': - $ref: '#/components/responses/nodes.hot_threads@200' /_nodes/reload_secure_settings: post: operationId: nodes.reload_secure_settings.0 @@ -3473,6 +3367,81 @@ paths: $ref: '#/components/responses/security.get_sslinfo@200' '500': $ref: '#/components/responses/security.get_sslinfo@500' + /_plugins/_asynchronous_search: + post: + operationId: asynchronous_search.search.0 + x-operation-group: asynchronous_search.search + x-version-added: '1.0' + description: Perform an asynchronous search. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/async/index/#rest-api + parameters: + - $ref: '#/components/parameters/asynchronous_search.search::query.index' + - $ref: '#/components/parameters/asynchronous_search.search::query.keep_alive' + - $ref: '#/components/parameters/asynchronous_search.search::query.keep_on_completion' + - $ref: '#/components/parameters/asynchronous_search.search::query.wait_for_completion_timeout' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/asynchronous_search.search' + responses: + '200': + $ref: '#/components/responses/asynchronous_search.search@200' + /_plugins/_asynchronous_search/{id}: + delete: + operationId: asynchronous_search.delete.0 + x-operation-group: asynchronous_search.delete + x-version-added: '1.0' + description: Delete asynchronous search. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/async/index/#delete-searches-and-results + parameters: + - $ref: '#/components/parameters/asynchronous_search.delete::path.id' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/asynchronous_search.delete@200' + get: + operationId: asynchronous_search.get.0 + x-operation-group: asynchronous_search.get + x-version-added: '1.0' + description: Get partial responses from asynchronous search. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/async/index/#get-partial-results + parameters: + - $ref: '#/components/parameters/asynchronous_search.get::path.id' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/asynchronous_search.get@200' + /_plugins/_asynchronous_search/stats: + get: + operationId: asynchronous_search.stats.0 + x-operation-group: asynchronous_search.stats + x-version-added: '1.0' + description: Monitoring of asynchronous searches that are running, completed, and/or persisted. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/async/index/#monitor-stats + responses: + '200': + $ref: '#/components/responses/asynchronous_search.stats@200' + parameters: + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' /_plugins/_knn/{node_id}/stats: get: operationId: knn.stats.2 @@ -11006,6 +10975,89 @@ paths: responses: '200': $ref: '#/components/responses/indices.validate_query@200' + /_opendistro/_asynchronous_search: + post: + operationId: asynchronous_search.search.0_superseded + x-operation-group: asynchronous_search.search + x-version-added: '1.0' + description: Perform an asynchronous search. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/async/index/#rest-api + parameters: + - $ref: '#/components/parameters/asynchronous_search.search::query.index' + - $ref: '#/components/parameters/asynchronous_search.search::query.keep_alive' + - $ref: '#/components/parameters/asynchronous_search.search::query.keep_on_completion' + - $ref: '#/components/parameters/asynchronous_search.search::query.wait_for_completion_timeout' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/asynchronous_search.search' + responses: + '200': + $ref: '#/components/responses/asynchronous_search.search@200' + deprecated: true + x-ignorable: true + /_opendistro/_asynchronous_search/stats: + get: + operationId: asynchronous_search.stats.0_superseded + x-operation-group: asynchronous_search.stats + x-version-added: '1.0' + description: Monitoring of asynchronous searches that are running, completed, and/or persisted. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/async/index/#monitor-stats + responses: + '200': + $ref: '#/components/responses/asynchronous_search.stats@200' + parameters: + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + deprecated: true + x-ignorable: true + /_opendistro/_asynchronous_search/{id}: + get: + operationId: asynchronous_search.get.0_superseded + x-operation-group: asynchronous_search.get + x-version-added: '1.0' + description: Get partial responses from asynchronous search. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/async/index/#get-partial-results + parameters: + - $ref: '#/components/parameters/asynchronous_search.get::path.id' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/asynchronous_search.get@200' + deprecated: true + x-ignorable: true + delete: + operationId: asynchronous_search.delete.0_superseded + x-operation-group: asynchronous_search.delete + x-version-added: '1.0' + description: Delete asynchronous search. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/async/index/#delete-searches-and-results + parameters: + - $ref: '#/components/parameters/asynchronous_search.delete::path.id' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/asynchronous_search.delete@200' + deprecated: true + x-ignorable: true /_opendistro/_knn/stats/{stat}: get: operationId: knn.stats.1_superseded @@ -12876,6 +12928,112 @@ paths: $ref: '#/components/responses/sql.post_stats@200' deprecated: true x-ignorable: true + /_cluster/nodes/hotthreads: + get: + operationId: nodes.hot_threads.0_superseded + x-operation-group: nodes.hot_threads + x-ignorable: true + deprecated: true + x-deprecation-message: The hot accepts /_cluster/nodes as prefix for backwards compatibility reasons + x-version-added: '1.0' + x-version-deprecated: '1.0' + description: Returns information about hot threads on each node in the cluster. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/nodes-apis/nodes-hot-threads/ + parameters: + - $ref: '#/components/parameters/nodes.hot_threads::query.ignore_idle_threads' + - $ref: '#/components/parameters/nodes.hot_threads::query.interval' + - $ref: '#/components/parameters/nodes.hot_threads::query.snapshots' + - $ref: '#/components/parameters/nodes.hot_threads::query.threads' + - $ref: '#/components/parameters/nodes.hot_threads::query.timeout' + - $ref: '#/components/parameters/nodes.hot_threads::query.type' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/nodes.hot_threads@200' + /_cluster/nodes/{node_id}/hotthreads: + get: + operationId: nodes.hot_threads.2_superseded + x-operation-group: nodes.hot_threads + x-ignorable: true + deprecated: true + x-deprecation-message: The hot accepts /_cluster/nodes as prefix for backwards compatibility reasons + x-version-added: '1.0' + x-version-deprecated: '1.0' + description: Returns information about hot threads on each node in the cluster. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/nodes-apis/nodes-hot-threads/ + parameters: + - $ref: '#/components/parameters/nodes.hot_threads::path.node_id' + - $ref: '#/components/parameters/nodes.hot_threads::query.ignore_idle_threads' + - $ref: '#/components/parameters/nodes.hot_threads::query.interval' + - $ref: '#/components/parameters/nodes.hot_threads::query.snapshots' + - $ref: '#/components/parameters/nodes.hot_threads::query.threads' + - $ref: '#/components/parameters/nodes.hot_threads::query.timeout' + - $ref: '#/components/parameters/nodes.hot_threads::query.type' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/nodes.hot_threads@200' + /_nodes/{node_id}/hotthreads: + get: + operationId: nodes.hot_threads.6_superseded + x-operation-group: nodes.hot_threads + x-version-added: '1.0' + description: Returns information about hot threads on each node in the cluster. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/nodes-apis/nodes-hot-threads/ + parameters: + - $ref: '#/components/parameters/nodes.hot_threads::path.node_id' + - $ref: '#/components/parameters/nodes.hot_threads::query.ignore_idle_threads' + - $ref: '#/components/parameters/nodes.hot_threads::query.interval' + - $ref: '#/components/parameters/nodes.hot_threads::query.snapshots' + - $ref: '#/components/parameters/nodes.hot_threads::query.threads' + - $ref: '#/components/parameters/nodes.hot_threads::query.timeout' + - $ref: '#/components/parameters/nodes.hot_threads::query.type' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/nodes.hot_threads@200' + deprecated: true + x-ignorable: true + /_nodes/hotthreads: + get: + operationId: nodes.hot_threads.4_superseded + x-operation-group: nodes.hot_threads + x-version-added: '1.0' + description: Returns information about hot threads on each node in the cluster. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/nodes-apis/nodes-hot-threads/ + parameters: + - $ref: '#/components/parameters/nodes.hot_threads::query.ignore_idle_threads' + - $ref: '#/components/parameters/nodes.hot_threads::query.interval' + - $ref: '#/components/parameters/nodes.hot_threads::query.snapshots' + - $ref: '#/components/parameters/nodes.hot_threads::query.threads' + - $ref: '#/components/parameters/nodes.hot_threads::query.timeout' + - $ref: '#/components/parameters/nodes.hot_threads::query.type' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/nodes.hot_threads@200' + deprecated: true + x-ignorable: true components: parameters: _global::query.pretty: @@ -12920,6 +13078,40 @@ components: items: type: string x-global: true + asynchronous_search.delete::path.id: + name: id + in: path + schema: + type: string + asynchronous_search.get::path.id: + name: id + in: path + schema: + type: string + asynchronous_search.search::query.index: + name: index + in: query + description: The name of the index to be searched. + schema: + type: string + asynchronous_search.search::query.keep_alive: + name: keep_alive + in: query + description: The amount of time that the result is saved in the cluster. + schema: + type: string + asynchronous_search.search::query.keep_on_completion: + name: keep_on_completion + in: query + description: Whether you want to save the results in the cluster after the search is complete. + schema: + type: boolean + asynchronous_search.search::query.wait_for_completion_timeout: + name: wait_for_completion_timeout + in: query + description: The amount of time that you plan to wait for the results. + schema: + type: string bulk::path.index: in: path name: index @@ -13188,7 +13380,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.allocation::query.s: @@ -13257,7 +13449,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.cluster_manager::query.s: @@ -13549,7 +13741,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.indices::query.pri: @@ -13633,7 +13825,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.master::query.s: @@ -13702,7 +13894,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.nodeattrs::query.s: @@ -13791,7 +13983,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.nodes::query.s: @@ -13866,7 +14058,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.pending_tasks::query.s: @@ -13992,7 +14184,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.plugins::query.s: @@ -14156,7 +14348,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.repositories::query.s: @@ -14381,7 +14573,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.segments::query.s: @@ -14468,7 +14660,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.shards::query.s: @@ -14555,7 +14747,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.snapshots::query.s: @@ -14726,7 +14918,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.templates::query.s: @@ -14805,7 +14997,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true cat.thread_pool::query.s: @@ -14889,7 +15081,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.delete_component_template::query.timeout: in: query @@ -14952,7 +15144,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.get_component_template::path.name: in: path @@ -14991,7 +15183,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.get_decommission_awareness::path.awareness_attribute_name: name: awareness_attribute_name @@ -15034,7 +15226,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.get_settings::query.timeout: in: query @@ -15105,7 +15297,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.health::query.timeout: in: query @@ -15185,7 +15377,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.post_voting_config_exclusions::query.node_ids: in: query @@ -15254,7 +15446,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.put_component_template::query.timeout: name: timeout @@ -15301,7 +15493,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.put_settings::query.timeout: in: query @@ -15347,7 +15539,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.reroute::query.metric: in: query @@ -15440,7 +15632,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. cluster.state::query.wait_for_metadata_version: in: query @@ -15768,7 +15960,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. dangling_indices.delete_dangling_index::query.timeout: in: query @@ -15808,7 +16000,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. dangling_indices.import_dangling_index::query.timeout: in: query @@ -16150,7 +16342,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. delete_script::query.timeout: in: query @@ -16601,7 +16793,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. get_source::path.id: in: path @@ -16935,7 +17127,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.add_block::query.timeout: in: query @@ -17083,7 +17275,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.clone::query.task_execution_timeout: name: task_execution_timeout @@ -17170,7 +17362,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.close::query.timeout: in: query @@ -17229,7 +17421,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.create::query.timeout: in: query @@ -17297,7 +17489,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.delete_alias::query.timeout: in: query @@ -17339,7 +17531,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.delete_index_template::query.timeout: in: query @@ -17375,7 +17567,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.delete_template::query.timeout: in: query @@ -17444,7 +17636,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.delete::query.timeout: in: query @@ -17547,7 +17739,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.exists_template::path.name: in: path @@ -17588,7 +17780,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.exists::path.index: in: path @@ -17952,7 +18144,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.get_mapping::path.index: in: path @@ -18027,7 +18219,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.get_settings::path.index: in: path @@ -18121,7 +18313,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.get_template::path.name: in: path @@ -18167,7 +18359,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.get_upgrade::path.index: name: index @@ -18277,7 +18469,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.open::path.index: in: path @@ -18336,7 +18528,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.open::query.task_execution_timeout: name: task_execution_timeout @@ -18410,7 +18602,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.put_alias::query.timeout: in: query @@ -18458,7 +18650,7 @@ components: description: Operation timeout for connection to master node. schema: $ref: '#/components/schemas/_common:Duration' - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. deprecated: true indices.put_mapping::path.index: @@ -18513,7 +18705,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.put_mapping::query.timeout: in: query @@ -18599,7 +18791,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.put_settings::query.preserve_existing: in: query @@ -18651,7 +18843,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.put_template::query.order: in: query @@ -18795,7 +18987,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.rollover::query.timeout: in: query @@ -18947,7 +19139,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.shrink::query.task_execution_timeout: name: task_execution_timeout @@ -19028,7 +19220,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.simulate_template::path.name: in: path @@ -19071,7 +19263,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.split::path.index: in: path @@ -19114,7 +19306,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.split::query.task_execution_timeout: name: task_execution_timeout @@ -19255,7 +19447,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. indices.update_aliases::query.timeout: in: query @@ -19445,7 +19637,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. ingest.delete_pipeline::query.timeout: in: query @@ -19484,7 +19676,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. ingest.put_pipeline::path.id: in: path @@ -19509,7 +19701,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. ingest.put_pipeline::query.timeout: in: query @@ -20895,7 +21087,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. put_script::query.timeout: in: query @@ -22135,7 +22327,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.cleanup_repository::query.timeout: in: query @@ -22183,7 +22375,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.create_repository::path.repository: in: path @@ -22208,7 +22400,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.create_repository::query.timeout: in: query @@ -22255,7 +22447,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.create::query.wait_for_completion: in: query @@ -22288,7 +22480,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.delete_repository::query.timeout: in: query @@ -22328,7 +22520,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.get_repository::path.repository: in: path @@ -22361,7 +22553,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.get::path.repository: in: path @@ -22405,7 +22597,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.get::query.verbose: in: query @@ -22445,7 +22637,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.restore::query.wait_for_completion: in: query @@ -22494,7 +22686,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.verify_repository::path.repository: in: path @@ -22519,7 +22711,7 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. snapshot.verify_repository::query.timeout: in: query @@ -23363,6 +23555,11 @@ components: style: form x-default: '1' requestBodies: + asynchronous_search.search: + content: + application/json: + schema: + $ref: '#/components/schemas/asynchronous_search._common:Search' bulk: content: application/x-ndjson: @@ -23414,6 +23611,11 @@ components: description: Specifies the ID of the shard that you would like an explanation for. type: number description: The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' + cluster.delete_weighted_routing: + content: + application/json: + schema: + $ref: '#/components/schemas/cluster.weighted_routing:WeightsBase' cluster.put_component_template: content: application/json: @@ -23451,6 +23653,11 @@ components: additionalProperties: {} description: The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). required: true + cluster.put_weighted_routing: + content: + application/json: + schema: + $ref: '#/components/schemas/cluster.weighted_routing:Weights' cluster.reroute: content: application/json: @@ -24344,10 +24551,10 @@ components: knn: description: Defines the approximate kNN search to run. oneOf: - - $ref: '#/components/schemas/_common:KnnQuery' + - $ref: '#/components/schemas/_common.query_dsl:KnnQuery' - type: array items: - $ref: '#/components/schemas/_common:KnnQuery' + $ref: '#/components/schemas/_common.query_dsl:KnnQuery' rank: $ref: '#/components/schemas/_common:RankContainer' min_score: @@ -24864,6 +25071,29 @@ components: $ref: '#/components/schemas/_common:Conflicts' description: The search definition using the Query DSL responses: + asynchronous_search.delete@200: + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean + asynchronous_search.get@200: + content: + application/json: + schema: + $ref: '#/components/schemas/asynchronous_search._common:ResponseBody' + asynchronous_search.search@200: + content: + application/json: + schema: + $ref: '#/components/schemas/asynchronous_search._common:ResponseBody' + asynchronous_search.stats@200: + content: + application/json: + schema: + $ref: '#/components/schemas/asynchronous_search._common:StatsResponse' bulk@200: content: application/json: @@ -25215,11 +25445,19 @@ components: application/json: schema: $ref: '#/components/schemas/_common:AcknowledgedResponseBase' - cluster.delete_decommission_awareness@200: {} + cluster.delete_decommission_awareness@200: + content: + application/json: + schema: + $ref: '#/components/schemas/_common:AcknowledgedResponseBase' cluster.delete_voting_config_exclusions@200: content: application/json: {} - cluster.delete_weighted_routing@200: {} + cluster.delete_weighted_routing@200: + content: + application/json: + schema: + $ref: '#/components/schemas/_common:AcknowledgedResponseBase' cluster.exists_component_template@200: content: application/json: {} @@ -25235,7 +25473,11 @@ components: $ref: '#/components/schemas/cluster._common:ComponentTemplate' required: - component_templates - cluster.get_decommission_awareness@200: {} + cluster.get_decommission_awareness@200: + content: + application/json: + schema: + $ref: '#/components/schemas/cluster.decommission_awareness:DecommissionStatusResponse' cluster.get_settings@200: content: application/json: @@ -25244,20 +25486,21 @@ components: properties: persistent: type: object - additionalProperties: - type: object + additionalProperties: true transient: type: object - additionalProperties: - type: object + additionalProperties: true defaults: type: object - additionalProperties: - type: object + additionalProperties: true required: - persistent - transient - cluster.get_weighted_routing@200: {} + cluster.get_weighted_routing@200: + content: + application/json: + schema: + $ref: '#/components/schemas/cluster.weighted_routing:WeightsResponse' cluster.health@200: content: application/json: @@ -25283,7 +25526,11 @@ components: application/json: schema: $ref: '#/components/schemas/_common:AcknowledgedResponseBase' - cluster.put_decommission_awareness@200: {} + cluster.put_decommission_awareness@200: + content: + application/json: + schema: + $ref: '#/components/schemas/_common:AcknowledgedResponseBase' cluster.put_settings@200: content: application/json: @@ -25302,7 +25549,11 @@ components: - acknowledged - persistent - transient - cluster.put_weighted_routing@200: {} + cluster.put_weighted_routing@200: + content: + application/json: + schema: + type: object cluster.remote_info@200: content: application/json: @@ -25346,6 +25597,8 @@ components: schema: type: object properties: + terminated_early: + type: boolean count: type: number _shards: @@ -26239,7 +26492,9 @@ components: $ref: '#/components/schemas/_core.mtermvectors:TermVectorsResult' required: - docs - nodes.hot_threads@200: {} + nodes.hot_threads@200: + content: + text/plain: {} nodes.info@200: content: application/json: @@ -28363,38 +28618,34 @@ components: - source _common:Ip: type: string - _common:KnnQuery: + _common:KnnField: type: object properties: - field: - $ref: '#/components/schemas/_common:Field' - query_vector: + vector: $ref: '#/components/schemas/_common:QueryVector' - query_vector_builder: - $ref: '#/components/schemas/_common:QueryVectorBuilder' k: - description: The final number of nearest neighbors to return as top hits + description: The final number of nearest neighbors to return as top hits. type: number - num_candidates: - description: The number of nearest neighbor candidates to consider per shard + min_score: + description: The minimum similarity score for a neighbor to be considered a hit. type: number - boost: - description: Boost value to apply to kNN scores + x-version-added: '2.14' + max_distance: + description: The maximum physical distance in vector space for a neighbor to be considered a hit. type: number + x-version-added: '2.14' filter: - description: Filters for the kNN search query + description: Filters for the kNN search query. oneOf: - $ref: '#/components/schemas/_common.query_dsl:QueryContainer' - type: array items: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' - similarity: - description: The minimum similarity for a vector to be considered a match + boost: + description: Boost value to apply to kNN scores type: number required: - - field - - k - - num_candidates + - vector _common:LatLonGeoLocation: type: object properties: @@ -28599,13 +28850,13 @@ components: $ref: '#/components/schemas/_common:ErrorCause' total: description: Total number of nodes selected by the request. - type: number + type: integer successful: description: Number of nodes that responded successfully to the request. - type: number + type: integer failed: description: Number of nodes that rejected the request or failed to respond. If this value is not 0, a reason for the rejection or failure is included in the response. - type: number + type: integer required: - failed - successful @@ -28772,13 +29023,6 @@ components: type: array items: type: number - _common:QueryVectorBuilder: - type: object - properties: - text_embedding: - $ref: '#/components/schemas/_common:TextEmbedding' - minProperties: 1 - maxProperties: 1 _common:RankBase: type: object _common:RankContainer: @@ -29015,9 +29259,11 @@ components: type: object properties: bulk: - type: number + type: integer + format: int64 search: - type: number + type: integer + format: int64 required: - bulk - search @@ -29310,7 +29556,7 @@ components: - terms_memory_in_bytes - version_map_memory_in_bytes _common:SequenceNumber: - type: number + type: integer format: int64 _common:ShardFailure: type: object @@ -29322,7 +29568,7 @@ components: reason: $ref: '#/components/schemas/_common:ErrorCause' shard: - type: number + type: integer status: type: string required: @@ -29533,16 +29779,6 @@ components: oneOf: - type: string - type: number - _common:TextEmbedding: - type: object - properties: - model_id: - type: string - model_text: - type: string - required: - - model_id - - model_text _common:TimeOfDay: description: Time of day, expressed as HH:MM:SS. type: string @@ -29609,16 +29845,17 @@ components: type: string x-version-removed: '2.0' _common:uint: - type: number + type: integer _common:ulong: type: number _common:UnitMillis: description: Time unit for milliseconds. - type: number + type: integer format: int64 _common:UnitNanos: description: Time unit for nanoseconds. - type: number + type: integer + format: int64 _common:UnitSeconds: description: Time unit for seconds. type: number @@ -29627,7 +29864,7 @@ components: _common:Uuid: type: string _common:VersionNumber: - type: number + type: integer format: int64 _common:VersionString: type: string @@ -29697,7 +29934,7 @@ components: _index: $ref: '#/components/schemas/_common:IndexName' _primary_term: - type: number + type: integer format: int64 result: $ref: '#/components/schemas/_common:Result' @@ -37025,6 +37262,12 @@ components: $ref: '#/components/schemas/_common:Field' required: - pattern + _common.query_dsl:KnnQuery: + type: object + additionalProperties: + $ref: '#/components/schemas/_common:KnnField' + minProperties: 1 + maxProperties: 1 _common.query_dsl:Like: description: Text that we want similar documents for or a lookup to a document's field for the text. oneOf: @@ -37566,6 +37809,8 @@ components: $ref: '#/components/schemas/_common.query_dsl:IntervalsQuery' minProperties: 1 maxProperties: 1 + knn: + $ref: '#/components/schemas/_common.query_dsl:KnnQuery' match: description: |- Returns documents that match a provided text, number, date or boolean value. @@ -38204,10 +38449,27 @@ components: type: boolean required: - value + _common.query_dsl:Terms: + oneOf: + - type: array + items: + type: string + - type: object + properties: + index: + $ref: '#/components/schemas/_common:IndexName' + id: + $ref: '#/components/schemas/_common:Id' + path: + $ref: '#/components/schemas/_common:Field' + routing: + $ref: '#/components/schemas/_common:Routing' + additionalProperties: true + description: Object for fetching terms. _common.query_dsl:TermsQuery: - allOf: + anyOf: - $ref: '#/components/schemas/_common.query_dsl:QueryBase' - - type: object + - $ref: '#/components/schemas/_common.query_dsl:Terms' _common.query_dsl:TermsSetQuery: allOf: - $ref: '#/components/schemas/_common.query_dsl:QueryBase' @@ -38218,10 +38480,7 @@ components: minimum_should_match_script: $ref: '#/components/schemas/_common:Script' terms: - description: Array of terms you wish to find in the provided field. - type: array - items: - type: string + $ref: '#/components/schemas/_common.query_dsl:Terms' required: - terms _common.query_dsl:TextExpansionQuery: @@ -38749,10 +39008,10 @@ components: knn: description: Defines the approximate kNN search to run. oneOf: - - $ref: '#/components/schemas/_common:KnnQuery' + - $ref: '#/components/schemas/_common.query_dsl:KnnQuery' - type: array items: - $ref: '#/components/schemas/_common:KnnQuery' + $ref: '#/components/schemas/_common.query_dsl:KnnQuery' from: description: |- Starting document offset. By default, you cannot page through more than 10,000 @@ -40294,6 +40553,186 @@ components: properties: get: $ref: '#/components/schemas/_common:InlineGet' + asynchronous_search._common:AsynchronousSearchStats: + type: object + properties: + submitted: + type: integer + initialized: + type: integer + search_failed: + type: integer + search_completed: + type: integer + rejected: + type: integer + persist_failed: + type: integer + cancelled: + type: integer + running_current: + type: integer + persisted: + type: integer + asynchronous_search._common:NodesStats: + type: object + properties: + asynchronous_search_stats: + $ref: '#/components/schemas/asynchronous_search._common:AsynchronousSearchStats' + asynchronous_search._common:ResponseBody: + type: object + properties: + id: + type: string + state: + type: string + start_time_in_millis: + type: number + expiration_time_in_millis: + type: number + took: + type: number + response: + $ref: '#/components/schemas/_core.search:ResponseBody' + asynchronous_search._common:Search: + type: object + properties: + aggregations: + description: Defines the aggregations that are run as part of the search request. + type: object + additionalProperties: + $ref: '#/components/schemas/_common.aggregations:AggregationContainer' + collapse: + $ref: '#/components/schemas/_core.search:FieldCollapse' + explain: + description: If true, returns detailed information about score computation as part of a hit. + type: boolean + ext: + description: Configuration of search extensions defined by OpenSearch plugins. + type: object + additionalProperties: + type: object + from: + description: |- + Starting document offset. + Needs to be non-negative. + By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. + To page through more hits, use the `search_after` parameter. + type: number + highlight: + $ref: '#/components/schemas/_core.search:Highlight' + track_total_hits: + $ref: '#/components/schemas/_core.search:TrackHits' + indices_boost: + description: Boosts the _score of documents from specified indices. + type: array + items: + type: object + additionalProperties: + type: number + docvalue_fields: + description: |- + Array of wildcard (`*`) patterns. + The request returns doc values for field names matching these patterns in the `hits.fields` property of the response. + type: array + items: + $ref: '#/components/schemas/_common.query_dsl:FieldAndFormat' + rank: + $ref: '#/components/schemas/_common:RankContainer' + min_score: + description: |- + Minimum `_score` for matching documents. + Documents with a lower `_score` are not included in the search results. + type: number + post_filter: + $ref: '#/components/schemas/_common.query_dsl:QueryContainer' + profile: + description: |- + Set to `true` to return detailed timing information about the execution of individual components in a search request. + NOTE: This is a debugging tool and adds significant overhead to search execution. + type: boolean + query: + $ref: '#/components/schemas/_common.query_dsl:QueryContainer' + script_fields: + description: Retrieve a script evaluation (based on different fields) for each hit. + type: object + additionalProperties: + $ref: '#/components/schemas/_common:ScriptField' + search_after: + $ref: '#/components/schemas/_common:SortResults' + size: + description: |- + The number of hits to return. + By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. + To page through more hits, use the `search_after` parameter. + type: number + slice: + $ref: '#/components/schemas/_common:SlicedScroll' + sort: + $ref: '#/components/schemas/_common:Sort' + _source: + $ref: '#/components/schemas/_core.search:SourceConfig' + fields: + description: |- + Array of wildcard (`*`) patterns. + The request returns values for field names matching these patterns in the `hits.fields` property of the response. + type: array + items: + $ref: '#/components/schemas/_common.query_dsl:FieldAndFormat' + suggest: + $ref: '#/components/schemas/_core.search:Suggester' + terminate_after: + description: |- + Maximum number of documents to collect for each shard. + If a query reaches this limit, OpenSearch terminates the query early. + OpenSearch collects documents before sorting. + Use with caution. + OpenSearch applies this parameter to each shard handling the request. + When possible, let OpenSearch perform early termination automatically. + Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. + If set to `0` (default), the query does not terminate early. + type: number + timeout: + description: |- + Specifies the period of time to wait for a response from each shard. + If no response is received before the timeout expires, the request fails and returns an error. + Defaults to no timeout. + type: string + track_scores: + description: If true, calculate and return document scores, even if the scores are not used for sorting. + type: boolean + version: + description: If true, returns document version as part of a hit. + type: boolean + seq_no_primary_term: + description: If `true`, returns sequence number and primary term of the last modification of each hit. + type: boolean + stored_fields: + $ref: '#/components/schemas/_common:Fields' + pit: + $ref: '#/components/schemas/_core.search:PointInTimeReference' + runtime_mappings: + $ref: '#/components/schemas/_common.mapping:RuntimeFields' + stats: + description: |- + Stats groups to associate with the search. + Each group maintains a statistics aggregation for its associated searches. + You can retrieve these stats using the indices stats API. + type: array + items: + type: string + description: The search definition using the Query DSL. + asynchronous_search._common:StatsResponse: + type: object + properties: + _nodes: + $ref: '#/components/schemas/_common:NodeStatistics' + cluster_name: + type: string + nodes: + type: object + additionalProperties: + $ref: '#/components/schemas/asynchronous_search._common:NodesStats' cat._common:CatPitSegmentsRecord: type: object properties: @@ -40596,352 +41035,640 @@ components: - string completion.size: description: size of completion - type: string + type: + - 'null' + - string pri.completion.size: description: size of completion - type: string + type: + - 'null' + - string fielddata.memory_size: description: used fielddata cache - type: string + type: + - 'null' + - string pri.fielddata.memory_size: description: used fielddata cache - type: string + type: + - 'null' + - string fielddata.evictions: description: fielddata evictions - type: string + type: + - 'null' + - string pri.fielddata.evictions: description: fielddata evictions - type: string + type: + - 'null' + - string query_cache.memory_size: description: used query cache - type: string + type: + - 'null' + - string pri.query_cache.memory_size: description: used query cache - type: string + type: + - 'null' + - string query_cache.evictions: description: query cache evictions - type: string + type: + - 'null' + - string pri.query_cache.evictions: description: query cache evictions - type: string + type: + - 'null' + - string request_cache.memory_size: description: used request cache - type: string + type: + - 'null' + - string pri.request_cache.memory_size: description: used request cache - type: string + type: + - 'null' + - string request_cache.evictions: description: request cache evictions - type: string + type: + - 'null' + - string pri.request_cache.evictions: description: request cache evictions - type: string + type: + - 'null' + - string request_cache.hit_count: description: request cache hit count - type: string + type: + - 'null' + - string pri.request_cache.hit_count: description: request cache hit count - type: string + type: + - 'null' + - string request_cache.miss_count: description: request cache miss count - type: string + type: + - 'null' + - string pri.request_cache.miss_count: description: request cache miss count - type: string + type: + - 'null' + - string flush.total: description: number of flushes - type: string + type: + - 'null' + - string pri.flush.total: description: number of flushes - type: string + type: + - 'null' + - string flush.total_time: description: time spent in flush - type: string + type: + - 'null' + - string pri.flush.total_time: description: time spent in flush - type: string + type: + - 'null' + - string get.current: description: number of current get ops - type: string + type: + - 'null' + - string pri.get.current: description: number of current get ops - type: string + type: + - 'null' + - string get.time: description: time spent in get - type: string + type: + - 'null' + - string pri.get.time: description: time spent in get - type: string + type: + - 'null' + - string get.total: description: number of get ops - type: string + type: + - 'null' + - string pri.get.total: description: number of get ops - type: string + type: + - 'null' + - string get.exists_time: description: time spent in successful gets - type: string + type: + - 'null' + - string pri.get.exists_time: description: time spent in successful gets - type: string + type: + - 'null' + - string get.exists_total: description: number of successful gets - type: string + type: + - 'null' + - string pri.get.exists_total: description: number of successful gets - type: string + type: + - 'null' + - string get.missing_time: description: time spent in failed gets - type: string + type: + - 'null' + - string pri.get.missing_time: description: time spent in failed gets - type: string + type: + - 'null' + - string get.missing_total: description: number of failed gets - type: string + type: + - 'null' + - string pri.get.missing_total: description: number of failed gets - type: string + type: + - 'null' + - string indexing.delete_current: description: number of current deletions - type: string + type: + - 'null' + - string pri.indexing.delete_current: description: number of current deletions - type: string + type: + - 'null' + - string indexing.delete_time: description: time spent in deletions - type: string + type: + - 'null' + - string pri.indexing.delete_time: description: time spent in deletions - type: string + type: + - 'null' + - string indexing.delete_total: description: number of delete ops - type: string + type: + - 'null' + - string pri.indexing.delete_total: description: number of delete ops - type: string + type: + - 'null' + - string indexing.index_current: description: number of current indexing ops - type: string + type: + - 'null' + - string pri.indexing.index_current: description: number of current indexing ops - type: string + type: + - 'null' + - string indexing.index_time: description: time spent in indexing - type: string + type: + - 'null' + - string pri.indexing.index_time: description: time spent in indexing - type: string + type: + - 'null' + - string indexing.index_total: description: number of indexing ops - type: string + type: + - 'null' + - string pri.indexing.index_total: description: number of indexing ops - type: string + type: + - 'null' + - string indexing.index_failed: description: number of failed indexing ops - type: string + type: + - 'null' + - string pri.indexing.index_failed: description: number of failed indexing ops - type: string + type: + - 'null' + - string merges.current: description: number of current merges - type: string + type: + - 'null' + - string pri.merges.current: description: number of current merges - type: string + type: + - 'null' + - string merges.current_docs: description: number of current merging docs - type: string + type: + - 'null' + - string pri.merges.current_docs: description: number of current merging docs - type: string + type: + - 'null' + - string merges.current_size: description: size of current merges - type: string + type: + - 'null' + - string pri.merges.current_size: description: size of current merges - type: string + type: + - 'null' + - string merges.total: description: number of completed merge ops - type: string + type: + - 'null' + - string pri.merges.total: description: number of completed merge ops - type: string + type: + - 'null' + - string merges.total_docs: description: docs merged - type: string + type: + - 'null' + - string pri.merges.total_docs: description: docs merged - type: string + type: + - 'null' + - string merges.total_size: description: size merged - type: string + type: + - 'null' + - string pri.merges.total_size: description: size merged - type: string + type: + - 'null' + - string merges.total_time: description: time spent in merges - type: string + type: + - 'null' + - string pri.merges.total_time: description: time spent in merges - type: string + type: + - 'null' + - string refresh.total: description: total refreshes - type: string + type: + - 'null' + - string pri.refresh.total: description: total refreshes - type: string + type: + - 'null' + - string refresh.time: description: time spent in refreshes - type: string + type: + - 'null' + - string pri.refresh.time: description: time spent in refreshes - type: string + type: + - 'null' + - string refresh.external_total: description: total external refreshes - type: string + type: + - 'null' + - string pri.refresh.external_total: description: total external refreshes - type: string + type: + - 'null' + - string refresh.external_time: description: time spent in external refreshes - type: string + type: + - 'null' + - string pri.refresh.external_time: description: time spent in external refreshes - type: string + type: + - 'null' + - string refresh.listeners: description: number of pending refresh listeners - type: string + type: + - 'null' + - string pri.refresh.listeners: description: number of pending refresh listeners - type: string + type: + - 'null' + - string search.fetch_current: description: current fetch phase ops - type: string + type: + - 'null' + - string pri.search.fetch_current: description: current fetch phase ops - type: string + type: + - 'null' + - string search.fetch_time: description: time spent in fetch phase - type: string + type: + - 'null' + - string pri.search.fetch_time: description: time spent in fetch phase - type: string + type: + - 'null' + - string search.fetch_total: description: total fetch ops - type: string + type: + - 'null' + - string pri.search.fetch_total: description: total fetch ops - type: string + type: + - 'null' + - string search.open_contexts: description: open search contexts - type: string + type: + - 'null' + - string pri.search.open_contexts: description: open search contexts - type: string + type: + - 'null' + - string search.query_current: description: current query phase ops - type: string + type: + - 'null' + - string pri.search.query_current: description: current query phase ops - type: string + type: + - 'null' + - string search.query_time: description: time spent in query phase - type: string + type: + - 'null' + - string pri.search.query_time: description: time spent in query phase - type: string + type: + - 'null' + - string search.query_total: description: total query phase ops - type: string + type: + - 'null' + - string pri.search.query_total: description: total query phase ops - type: string + type: + - 'null' + - string + search.concurrent_query_current: + type: + - 'null' + - string + pri.search.concurrent_query_current: + type: + - 'null' + - string + search.concurrent_query_time: + type: + - 'null' + - string + pri.search.concurrent_query_time: + type: + - 'null' + - string + search.concurrent_query_total: + type: + - 'null' + - string + pri.search.concurrent_query_total: + type: + - 'null' + - string + search.concurrent_avg_slice_count: + type: + - 'null' + - string + pri.search.concurrent_avg_slice_count: + type: + - 'null' + - string search.scroll_current: description: open scroll contexts - type: string + type: + - 'null' + - string pri.search.scroll_current: description: open scroll contexts - type: string + type: + - 'null' + - string search.scroll_time: description: time scroll contexts held open - type: string + type: + - 'null' + - string pri.search.scroll_time: description: time scroll contexts held open - type: string + type: + - 'null' + - string search.scroll_total: description: completed scroll contexts - type: string + type: + - 'null' + - string pri.search.scroll_total: description: completed scroll contexts - type: string + type: + - 'null' + - string + search.point_in_time_current: + type: + - 'null' + - string + pri.search.point_in_time_current: + type: + - 'null' + - string + search.point_in_time_time: + type: + - 'null' + - string + pri.search.point_in_time_time: + type: + - 'null' + - string + search.point_in_time_total: + type: + - 'null' + - string + pri.search.point_in_time_total: + type: + - 'null' + - string segments.count: description: number of segments - type: string + type: + - 'null' + - string pri.segments.count: description: number of segments - type: string + type: + - 'null' + - string segments.memory: description: memory used by segments - type: string + type: + - 'null' + - string pri.segments.memory: description: memory used by segments - type: string + type: + - 'null' + - string segments.index_writer_memory: description: memory used by index writer - type: string + type: + - 'null' + - string pri.segments.index_writer_memory: description: memory used by index writer - type: string + type: + - 'null' + - string segments.version_map_memory: description: memory used by version map - type: string + type: + - 'null' + - string pri.segments.version_map_memory: description: memory used by version map - type: string + type: + - 'null' + - string segments.fixed_bitset_memory: description: memory used by fixed bit sets for nested object field types and export type filters for types referred in _parent fields - type: string + type: + - 'null' + - string pri.segments.fixed_bitset_memory: description: memory used by fixed bit sets for nested object field types and export type filters for types referred in _parent fields - type: string + type: + - 'null' + - string warmer.current: description: current warmer ops - type: string + type: + - 'null' + - string pri.warmer.current: description: current warmer ops - type: string + type: + - 'null' + - string warmer.total: description: total warmer ops - type: string + type: + - 'null' + - string pri.warmer.total: description: total warmer ops - type: string + type: + - 'null' + - string warmer.total_time: description: time spent in warmers - type: string + type: + - 'null' + - string pri.warmer.total_time: description: time spent in warmers - type: string + type: + - 'null' + - string suggest.current: description: number of current suggest ops - type: string + type: + - 'null' + - string pri.suggest.current: description: number of current suggest ops - type: string + type: + - 'null' + - string suggest.time: description: time spend in suggest - type: string + type: + - 'null' + - string pri.suggest.time: description: time spend in suggest - type: string + type: + - 'null' + - string suggest.total: description: number of suggest ops - type: string + type: + - 'null' + - string pri.suggest.total: description: number of suggest ops - type: string + type: + - 'null' + - string memory.total: description: total used memory type: string @@ -40951,36 +41678,6 @@ components: search.throttled: description: indicates if the index is search throttled type: string - bulk.total_operations: - description: number of bulk shard ops - type: string - pri.bulk.total_operations: - description: number of bulk shard ops - type: string - bulk.total_time: - description: time spend in shard bulk - type: string - pri.bulk.total_time: - description: time spend in shard bulk - type: string - bulk.total_size_in_bytes: - description: total size in bytes of shard bulk - type: string - pri.bulk.total_size_in_bytes: - description: total size in bytes of shard bulk - type: string - bulk.avg_time: - description: average time spend in shard bulk - type: string - pri.bulk.avg_time: - description: average time spend in shard bulk - type: string - bulk.avg_size_in_bytes: - description: average size in bytes of shard bulk - type: string - pri.bulk.avg_size_in_bytes: - description: average size in bytes of shard bulk - type: string cat.master:MasterRecord: type: object properties: @@ -41121,7 +41818,7 @@ components: Indicates whether the node is the elected master node. Returned values include `*`(elected master) and `-`(not elected master). type: string - x-version-deprecated: 2.0.0 + x-version-deprecated: '2.0' x-deprecation-message: To promote inclusive language, use 'cluster_manager' instead. name: $ref: '#/components/schemas/_common:Name' @@ -41272,6 +41969,14 @@ components: search.query_total: description: The total query phase operations. type: string + search.concurrent_query_current: + type: string + search.concurrent_query_time: + type: string + search.concurrent_query_total: + type: string + search.concurrent_avg_slice_count: + type: string search.scroll_current: description: The open scroll contexts. type: string @@ -41281,6 +41986,12 @@ components: search.scroll_total: description: The completed scroll contexts. type: string + search.point_in_time_current: + type: string + search.point_in_time_time: + type: string + search.point_in_time_total: + type: string segments.count: description: The number of segments. type: string @@ -41364,11 +42075,11 @@ components: start_time: $ref: '#/components/schemas/_common:DateTime' start_time_millis: - $ref: '#/components/schemas/_common:EpochTimeUnitMillis' + $ref: '#/components/schemas/_common:StringifiedEpochTimeUnitMillis' stop_time: $ref: '#/components/schemas/_common:DateTime' stop_time_millis: - $ref: '#/components/schemas/_common:EpochTimeUnitMillis' + $ref: '#/components/schemas/_common:StringifiedEpochTimeUnitMillis' time: $ref: '#/components/schemas/_common:Duration' type: @@ -41531,7 +42242,9 @@ components: - string id: description: The unique identifier for the node. - type: string + type: + - 'null' + - string node: description: The name of node. type: @@ -41539,7 +42252,9 @@ components: - string sync_id: description: The sync identifier. - type: string + type: + - 'null' + - string unassigned.reason: description: |- The reason for the last change to the state of an unassigned shard. @@ -41562,204 +42277,372 @@ components: `REINITIALIZED`: When a shard moves from started back to initializing. `REPLICA_ADDED`: Unassigned as a result of explicit addition of a replica. `REROUTE_CANCELLED`: Unassigned as a result of explicit cancel reroute command. - type: string + type: + - 'null' + - string unassigned.at: description: The time at which the shard became unassigned in Coordinated Universal Time (UTC). - type: string + type: + - 'null' + - string unassigned.for: description: The time at which the shard was requested to be unassigned in Coordinated Universal Time (UTC). - type: string + type: + - 'null' + - string unassigned.details: description: |- Additional details as to why the shard became unassigned. It does not explain why the shard is not assigned; use the cluster allocation explain API for that information. - type: string + type: + - 'null' + - string recoverysource.type: description: The type of recovery source. - type: string + type: + - 'null' + - string completion.size: description: The size of completion. - type: string + type: + - 'null' + - string fielddata.memory_size: description: The used fielddata cache memory. - type: string + type: + - 'null' + - string fielddata.evictions: description: The fielddata cache evictions. - type: string + type: + - 'null' + - string query_cache.memory_size: description: The used query cache memory. - type: string + type: + - 'null' + - string query_cache.evictions: description: The query cache evictions. - type: string + type: + - 'null' + - string flush.total: description: The number of flushes. - type: string + type: + - 'null' + - string flush.total_time: description: The time spent in flush. - type: string + type: + - 'null' + - string get.current: description: The number of current get operations. - type: string + type: + - 'null' + - string get.time: description: The time spent in get operations. - type: string + type: + - 'null' + - string get.total: description: The number of get operations. - type: string + type: + - 'null' + - string get.exists_time: description: The time spent in successful get operations. - type: string + type: + - 'null' + - string get.exists_total: description: The number of successful get operations. - type: string + type: + - 'null' + - string get.missing_time: description: The time spent in failed get operations. - type: string + type: + - 'null' + - string get.missing_total: description: The number of failed get operations. - type: string + type: + - 'null' + - string indexing.delete_current: description: The number of current deletion operations. - type: string + type: + - 'null' + - string indexing.delete_time: description: The time spent in deletion operations. - type: string + type: + - 'null' + - string indexing.delete_total: description: The number of delete operations. - type: string + type: + - 'null' + - string indexing.index_current: description: The number of current indexing operations. - type: string + type: + - 'null' + - string indexing.index_time: description: The time spent in indexing operations. - type: string + type: + - 'null' + - string indexing.index_total: description: The number of indexing operations. - type: string + type: + - 'null' + - string indexing.index_failed: description: The number of failed indexing operations. - type: string + type: + - 'null' + - string merges.current: description: The number of current merge operations. - type: string + type: + - 'null' + - string merges.current_docs: description: The number of current merging documents. - type: string + type: + - 'null' + - string merges.current_size: description: The size of current merge operations. - type: string + type: + - 'null' + - string merges.total: description: The number of completed merge operations. - type: string + type: + - 'null' + - string merges.total_docs: description: The number of merged documents. - type: string + type: + - 'null' + - string merges.total_size: description: The size of current merges. - type: string + type: + - 'null' + - string merges.total_time: description: The time spent merging documents. - type: string + type: + - 'null' + - string refresh.total: description: The total number of refreshes. - type: string + type: + - 'null' + - string refresh.time: description: The time spent in refreshes. - type: string + type: + - 'null' + - string refresh.external_total: description: The total number of external refreshes. - type: string + type: + - 'null' + - string refresh.external_time: description: The time spent in external refreshes. - type: string + type: + - 'null' + - string refresh.listeners: description: The number of pending refresh listeners. - type: string + type: + - 'null' + - string search.fetch_current: description: The current fetch phase operations. - type: string + type: + - 'null' + - string search.fetch_time: description: The time spent in fetch phase. - type: string + type: + - 'null' + - string search.fetch_total: description: The total number of fetch operations. - type: string + type: + - 'null' + - string search.open_contexts: description: The number of open search contexts. - type: string + type: + - 'null' + - string search.query_current: description: The current query phase operations. - type: string + type: + - 'null' + - string search.query_time: description: The time spent in query phase. - type: string + type: + - 'null' + - string search.query_total: description: The total number of query phase operations. - type: string + type: + - 'null' + - string + search.concurrent_query_current: + type: + - 'null' + - string + search.concurrent_query_time: + type: + - 'null' + - string + search.concurrent_query_total: + type: + - 'null' + - string + search.concurrent_avg_slice_count: + type: + - 'null' + - string search.scroll_current: description: The open scroll contexts. - type: string + type: + - 'null' + - string search.scroll_time: description: The time scroll contexts were held open. - type: string + type: + - 'null' + - string search.scroll_total: description: The number of completed scroll contexts. - type: string + type: + - 'null' + - string + search.point_in_time_current: + type: + - 'null' + - string + search.point_in_time_time: + type: + - 'null' + - string + search.point_in_time_total: + type: + - 'null' + - string + search.search_idle_reactivate_count_total: + type: + - 'null' + - string segments.count: description: The number of segments. - type: string + type: + - 'null' + - string segments.memory: description: The memory used by segments. - type: string + type: + - 'null' + - string segments.index_writer_memory: description: The memory used by the index writer. - type: string + type: + - 'null' + - string segments.version_map_memory: description: The memory used by the version map. - type: string + type: + - 'null' + - string segments.fixed_bitset_memory: description: The memory used by fixed bit sets for nested object field types and export type filters for types referred in `_parent` fields. - type: string + type: + - 'null' + - string seq_no.max: description: The maximum sequence number. - type: string + type: + - 'null' + - string seq_no.local_checkpoint: description: The local checkpoint. - type: string + type: + - 'null' + - string seq_no.global_checkpoint: description: The global checkpoint. - type: string + type: + - 'null' + - string warmer.current: description: The number of current warmer operations. - type: string + type: + - 'null' + - string warmer.total: description: The total number of warmer operations. - type: string + type: + - 'null' + - string warmer.total_time: description: The time spent in warmer operations. - type: string + type: + - 'null' + - string path.data: description: The shard data path. - type: string + type: + - 'null' + - string path.state: description: The shard state path. - type: string + type: + - 'null' + - string bulk.total_operations: description: The number of bulk shard operations. - type: string + type: + - 'null' + - string bulk.total_time: description: The time spent in shard bulk operations. - type: string + type: + - 'null' + - string bulk.total_size_in_bytes: description: The total size in bytes of shard bulk operations. - type: string + type: + - 'null' + - string bulk.avg_time: description: The average time spent in shard bulk operations. - type: string + type: + - 'null' + - string bulk.avg_size_in_bytes: description: The average size in bytes of shard bulk operations. - type: string + type: + - 'null' + - string + docs.deleted: + type: + - 'null' + - string cat.snapshots:SnapshotsRecord: type: object properties: @@ -41922,6 +42805,8 @@ components: completed: description: The number of completed tasks. type: string + total_wait_time: + type: string core: description: The core number of active threads allowed in a scaling thread pool. type: @@ -42206,6 +43091,35 @@ components: - REINITIALIZED - REPLICA_ADDED - REROUTE_CANCELLED + cluster.decommission_awareness:DecommissionStatusResponse: + oneOf: + - $ref: '#/components/schemas/cluster.decommission_awareness:ZoneDecommissionStatusResponse' + cluster.decommission_awareness:ZoneDecommissionStatusResponse: + type: object + additionalProperties: + type: string + enum: + - DRAINING + - FAILED + - INIT + - IN_PROGRESS + - SUCCESSFUL + cluster.health:AwarenessAttributeStats: + type: object + x-version-added: '2.5' + properties: + active_shards: + type: number + initializing_shards: + type: number + relocating_shards: + type: number + unassigned_shards: + type: number + data_nodes: + type: number + weight: + type: number cluster.health:HealthResponseBody: type: object properties: @@ -42217,11 +43131,25 @@ components: type: number active_shards_percent_as_number: $ref: '#/components/schemas/_common:Percentage' + awareness_attributes: + description: Cluster health information for each awareness attribute. + type: object + x-version-added: '2.5' + additionalProperties: + $ref: '#/components/schemas/cluster.health:AwarenessAttributeStats' cluster_name: $ref: '#/components/schemas/_common:Name' delayed_unassigned_shards: description: The number of shards whose allocation has been delayed by the timeout settings. type: number + discovered_master: + description: True if the master node has been discovered. + type: boolean + x-version-deprecated: '2.0' + discovered_cluster_manager: + description: True if the cluster manager node has been discovered. + type: boolean + x-version-added: '2.0' indices: type: object additionalProperties: @@ -42251,7 +43179,7 @@ components: task_max_waiting_in_queue_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' timed_out: - description: If false the response returned within the period of time that is specified by the timeout parameter (30s by default) + description: If false the response returned within the period of time that is specified by the timeout parameter (30s by default). type: boolean unassigned_shards: description: The number of shards that are not allocated. @@ -42629,6 +43557,10 @@ components: total_in_bytes: description: Total size, in bytes, of all file stores across all selected nodes. type: number + cache_reserved_in_bytes: + description: Total size, in bytes, of all cache reserved across all selected nodes. + type: number + x-version-added: '2.7' required: - available_in_bytes - free_in_bytes @@ -42811,10 +43743,16 @@ components: type: number master: type: number + cluster_manager: + type: number + x-version-added: '2.0' ml: type: number remote_cluster_client: type: number + search: + type: number + x-version-added: '2.4' total: type: number transform: @@ -42824,17 +43762,10 @@ components: required: - coordinating_only - data - - data_cold - - data_content - - data_hot - - data_warm - ingest - master - - ml - remote_cluster_client - total - - transform - - voting_only cluster.stats:ClusterNodes: type: object properties: @@ -42880,7 +43811,6 @@ components: - count - discovery_types - fs - - indexing_pressure - ingest - jvm - network_types @@ -43162,7 +44092,6 @@ components: type: string required: - count - - flavor - type cluster.stats:OperatingSystemMemoryInfo: type: object @@ -43277,6 +44206,25 @@ components: - nodes - status - timestamp + cluster.weighted_routing:Weights: + allOf: + - $ref: '#/components/schemas/cluster.weighted_routing:WeightsBase' + - type: object + properties: + weights: + type: object + cluster.weighted_routing:WeightsBase: + type: object + properties: + _version: + $ref: '#/components/schemas/_common:VersionNumber' + cluster.weighted_routing:WeightsResponse: + allOf: + - $ref: '#/components/schemas/cluster.weighted_routing:Weights' + - type: object + properties: + discovered_cluster_manager: + type: boolean dangling_indices.list_dangling_indices:DanglingIndex: type: object properties: @@ -46244,7 +47192,7 @@ components: type: string description: The model group name. latest_version: - type: number + type: integer description: The latest version. description: type: string @@ -51003,7 +51951,8 @@ components: additionalProperties: type: string id: - type: number + type: integer + format: int64 node: $ref: '#/components/schemas/_common:NodeId' running_time: diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java index fffd8a017f..fc994cc1d0 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java @@ -428,6 +428,7 @@ private Type mapTypeInner(OpenApiSchema schema) { case Boolean: return Types.Primitive.Boolean; case Integer: + return mapInteger(schema); case Number: return mapNumber(schema); } @@ -444,7 +445,9 @@ private Type mapOneOf(List oneOf) { if (types.size() == 2 && types.contains(OpenApiSchemaType.String) - && (types.contains(OpenApiSchemaType.Boolean) || types.contains(OpenApiSchemaType.Number))) { + && (types.contains(OpenApiSchemaType.Boolean) + || types.contains(OpenApiSchemaType.Integer) + || types.contains(OpenApiSchemaType.Number))) { return Types.Java.Lang.String; } @@ -469,24 +472,36 @@ private Type mapArray(OpenApiSchema schema) { return Types.Java.Util.List(items); } - private Type mapNumber(OpenApiSchema schema) { + private Type mapInteger(OpenApiSchema schema) { var format = schema.getFormat().orElse(OpenApiSchemaFormat.Int32); switch (format) { case Int32: return Types.Primitive.Int; case Int64: return Types.Primitive.Long; + default: + throw new UnsupportedOperationException( + "Can not get type name for integer [" + schema.getPointer() + "] with format: " + format + ); + } + } + + private Type mapNumber(OpenApiSchema schema) { + var format = schema.getFormat().orElse(OpenApiSchemaFormat.Float); + switch (format) { case Float: return Types.Primitive.Float; case Double: return Types.Primitive.Double; default: - throw new UnsupportedOperationException("Can not get type name for integer/number with format: " + format); + throw new UnsupportedOperationException( + "Can not get type name for number [" + schema.getPointer() + "] with format: " + format + ); } } private boolean shouldKeepRef(OpenApiSchema schema) { - if (schema.isNumber() || schema.isArray()) { + if (schema.isInteger() || schema.isNumber() || schema.isArray()) { return false; } if (schema.isString() && schema.getEnums().isEmpty()) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java index 88f5d28779..d4df9b3c07 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java @@ -183,6 +183,10 @@ public boolean isBoolean() { return is(OpenApiSchemaType.Boolean); } + public boolean isInteger() { + return is(OpenApiSchemaType.Integer); + } + public boolean isNumber() { return is(OpenApiSchemaType.Number); } From 8ef64dbf320974f3ae9b86e2f151df400939ceab Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 13 Aug 2024 16:07:11 +1200 Subject: [PATCH 02/11] Add failing tests Signed-off-by: Thomas Farr --- .../opensearch/tasks/ListResponseTest.java | 215 ++++++++++++++++++ .../integTest/AbstractTasksClientIT.java | 37 +++ .../OpenSearchJavaClientTestCase.java | 8 +- .../integTest/httpclient5/TasksClientIT.java | 13 ++ .../integTest/restclient/TasksClientIT.java | 24 ++ 5 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 java-client/src/test/java/org/opensearch/client/opensearch/tasks/ListResponseTest.java create mode 100644 java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractTasksClientIT.java create mode 100644 java-client/src/test/java11/org/opensearch/client/opensearch/integTest/httpclient5/TasksClientIT.java create mode 100644 java-client/src/test/java11/org/opensearch/client/opensearch/integTest/restclient/TasksClientIT.java diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/tasks/ListResponseTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/tasks/ListResponseTest.java new file mode 100644 index 0000000000..2328335cf3 --- /dev/null +++ b/java-client/src/test/java/org/opensearch/client/opensearch/tasks/ListResponseTest.java @@ -0,0 +1,215 @@ +/* + * 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. + */ + +package org.opensearch.client.opensearch.tasks; + +import java.util.List; +import java.util.Map; +import org.junit.Test; +import org.opensearch.client.opensearch.model.ModelTestCase; + +public class ListResponseTest extends ModelTestCase { + @Test + public void canDeserializeGroupedByNodes() { + final String json = "{\n" + + " \"nodes\": {\n" + + " \"y2hDJUdMTWa6sNA_0vdF6Q\": {\n" + + " \"name\": \"opensearch-node1\",\n" + + " \"transport_address\": \"172.17.0.4:9300\",\n" + + " \"host\": \"172.17.0.4\",\n" + + " \"ip\": \"172.17.0.4:9300\",\n" + + " \"roles\": [\n" + + " \"cluster_manager\",\n" + + " \"data\",\n" + + " \"ingest\",\n" + + " \"remote_cluster_client\"\n" + + " ],\n" + + " \"attributes\": {\n" + + " \"shard_indexing_pressure_enabled\": \"true\"\n" + + " },\n" + + " \"tasks\": {\n" + + " \"y2hDJUdMTWa6sNA_0vdF6Q:3970\": {\n" + + " \"node\": \"y2hDJUdMTWa6sNA_0vdF6Q\",\n" + + " \"id\": 3970,\n" + + " \"type\": \"transport\",\n" + + " \"action\": \"cluster:monitor/tasks/lists\",\n" + + " \"start_time_in_millis\": 1722997372508,\n" + + " \"running_time_in_nanos\": 2141574,\n" + + " \"cancellable\": false,\n" + + " \"headers\": {\n" + + " \"X-Opaque-Id\": \"7ef238e7-e5fb-4779-81f5-9b7bfcc46bdd\"\n" + + " }\n" + + " },\n" + + " \"y2hDJUdMTWa6sNA_0vdF6Q:3971\": {\n" + + " \"node\": \"y2hDJUdMTWa6sNA_0vdF6Q\",\n" + + " \"id\": 3971,\n" + + " \"type\": \"direct\",\n" + + " \"action\": \"cluster:monitor/tasks/lists[n]\",\n" + + " \"start_time_in_millis\": 1722997372510,\n" + + " \"running_time_in_nanos\": 868850,\n" + + " \"cancellable\": false,\n" + + " \"parent_task_id\": \"y2hDJUdMTWa6sNA_0vdF6Q:3970\",\n" + + " \"headers\": {\n" + + " \"X-Opaque-Id\": \"7ef238e7-e5fb-4779-81f5-9b7bfcc46bdd\"\n" + + " }\n" + + " }\n" + + " }\n" + + " },\n" + + " \"upjixfEITyuPot3qTn9H_Q\": {\n" + + " \"name\": \"opensearch-node2\",\n" + + " \"transport_address\": \"172.17.0.3:9300\",\n" + + " \"host\": \"172.17.0.3\",\n" + + " \"ip\": \"172.17.0.3:9300\",\n" + + " \"roles\": [\n" + + " \"cluster_manager\",\n" + + " \"data\",\n" + + " \"ingest\",\n" + + " \"remote_cluster_client\"\n" + + " ],\n" + + " \"attributes\": {\n" + + " \"shard_indexing_pressure_enabled\": \"true\"\n" + + " },\n" + + " \"tasks\": {\n" + + " \"upjixfEITyuPot3qTn9H_Q:5061\": {\n" + + " \"node\": \"upjixfEITyuPot3qTn9H_Q\",\n" + + " \"id\": 5061,\n" + + " \"type\": \"transport\",\n" + + " \"action\": \"cluster:monitor/tasks/lists[n]\",\n" + + " \"start_time_in_millis\": 1722997372510,\n" + + " \"running_time_in_nanos\": 886766,\n" + + " \"cancellable\": false,\n" + + " \"parent_task_id\": \"y2hDJUdMTWa6sNA_0vdF6Q:3970\",\n" + + " \"headers\": {\n" + + " \"X-Opaque-Id\": \"7ef238e7-e5fb-4779-81f5-9b7bfcc46bdd\"\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + + final ListResponse response = fromJson(json, ListResponse._DESERIALIZER); + assertTrue(response.tasks().isEmpty()); + + final Map nodes = response.nodes(); + assertNotNull(nodes); + assertEquals(2, nodes.size()); + assertEquals("opensearch-node2", nodes.get("upjixfEITyuPot3qTn9H_Q").name()); + } + + @Test + public void canDeserializeGroupedByParents() { + final String json = "{\n" + + " \"tasks\": {\n" + + " \"y2hDJUdMTWa6sNA_0vdF6Q:5306\": {\n" + + " \"node\": \"y2hDJUdMTWa6sNA_0vdF6Q\",\n" + + " \"id\": 5306,\n" + + " \"type\": \"transport\",\n" + + " \"action\": \"cluster:monitor/tasks/lists\",\n" + + " \"start_time_in_millis\": 1722997879217,\n" + + " \"running_time_in_nanos\": 1572170,\n" + + " \"cancellable\": false,\n" + + " \"headers\": {\n" + + " \"X-Opaque-Id\": \"6033796b-4901-44f0-aae9-37c46d7d36ea\"\n" + + " },\n" + + " \"children\": [\n" + + " {\n" + + " \"node\": \"y2hDJUdMTWa6sNA_0vdF6Q\",\n" + + " \"id\": 5307,\n" + + " \"type\": \"direct\",\n" + + " \"action\": \"cluster:monitor/tasks/lists[n]\",\n" + + " \"start_time_in_millis\": 1722997879218,\n" + + " \"running_time_in_nanos\": 393734,\n" + + " \"cancellable\": false,\n" + + " \"parent_task_id\": \"y2hDJUdMTWa6sNA_0vdF6Q:5306\",\n" + + " \"headers\": {\n" + + " \"X-Opaque-Id\": \"6033796b-4901-44f0-aae9-37c46d7d36ea\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"node\": \"upjixfEITyuPot3qTn9H_Q\",\n" + + " \"id\": 6646,\n" + + " \"type\": \"transport\",\n" + + " \"action\": \"cluster:monitor/tasks/lists[n]\",\n" + + " \"start_time_in_millis\": 1722997879218,\n" + + " \"running_time_in_nanos\": 356705,\n" + + " \"cancellable\": false,\n" + + " \"parent_task_id\": \"y2hDJUdMTWa6sNA_0vdF6Q:5306\",\n" + + " \"headers\": {\n" + + " \"X-Opaque-Id\": \"6033796b-4901-44f0-aae9-37c46d7d36ea\"\n" + + " }\n" + + " }\n" + + " ]\n" + + " }\n" + + " }\n" + + "}"; + + final ListResponse response = fromJson(json, ListResponse._DESERIALIZER); + assertTrue(response.nodes().isEmpty()); + + final Map tasks = response.tasks(); + assertNotNull(tasks); + assertEquals(1, tasks.size()); + + final Info task = tasks.get("y2hDJUdMTWa6sNA_0vdF6Q:5306"); + assertNotNull(task); + + final List children = task.children(); + assertEquals(2, children.size()); + + assertEquals("cluster:monitor/tasks/lists[n]", children.get(0).action()); + } + + @Test + public void canDeserializeGroupedByNone() { + final String json = "{\n" + + " \"tasks\": [\n" + + " {\n" + + " \"node\": \"y2hDJUdMTWa6sNA_0vdF6Q\",\n" + + " \"id\": 5961,\n" + + " \"type\": \"transport\",\n" + + " \"action\": \"cluster:monitor/tasks/lists\",\n" + + " \"start_time_in_millis\": 1722998118297,\n" + + " \"running_time_in_nanos\": 1472050,\n" + + " \"cancellable\": false,\n" + + " \"headers\": {\n" + + " \"X-Opaque-Id\": \"ccfdeab1-5807-4f9d-8258-111ea6642d9b\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"node\": \"y2hDJUdMTWa6sNA_0vdF6Q\",\n" + + " \"id\": 5962,\n" + + " \"type\": \"direct\",\n" + + " \"action\": \"cluster:monitor/tasks/lists[n]\",\n" + + " \"start_time_in_millis\": 1722998118298,\n" + + " \"running_time_in_nanos\": 95393,\n" + + " \"cancellable\": false,\n" + + " \"parent_task_id\": \"y2hDJUdMTWa6sNA_0vdF6Q:5961\",\n" + + " \"headers\": {\n" + + " \"X-Opaque-Id\": \"ccfdeab1-5807-4f9d-8258-111ea6642d9b\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"node\": \"upjixfEITyuPot3qTn9H_Q\",\n" + + " \"id\": 7356,\n" + + " \"type\": \"transport\",\n" + + " \"action\": \"cluster:monitor/tasks/lists[n]\",\n" + + " \"start_time_in_millis\": 1722998118299,\n" + + " \"running_time_in_nanos\": 885987,\n" + + " \"cancellable\": false,\n" + + " \"parent_task_id\": \"y2hDJUdMTWa6sNA_0vdF6Q:5961\",\n" + + " \"headers\": {\n" + + " \"X-Opaque-Id\": \"ccfdeab1-5807-4f9d-8258-111ea6642d9b\"\n" + + " }\n" + + " }\n" + + " ]\n" + + "}"; + + final ListResponse response = fromJson(json, ListResponse._DESERIALIZER); + } +} diff --git a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractTasksClientIT.java b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractTasksClientIT.java new file mode 100644 index 0000000000..2018c2202c --- /dev/null +++ b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractTasksClientIT.java @@ -0,0 +1,37 @@ +/* + * 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. + */ + +package org.opensearch.client.opensearch.integTest; + +import java.io.IOException; +import org.junit.Test; +import org.opensearch.client.opensearch.tasks.GroupBy; +import org.opensearch.client.opensearch.tasks.ListResponse; + +public abstract class AbstractTasksClientIT extends OpenSearchJavaClientTestCase { + @Test + public void list_groupedByNodes() throws IOException { + final ListResponse response = javaClient().tasks().list(l -> l.groupBy(GroupBy.Nodes)); + assertFalse(response.nodes().isEmpty()); + assertTrue(response.tasks().isEmpty()); + } + + @Test + public void list_groupedByParents() throws IOException { + final ListResponse response = javaClient().tasks().list(l -> l.groupBy(GroupBy.Parents)); + assertTrue(response.nodes().isEmpty()); + assertFalse(response.tasks().isEmpty()); + } + + @Test + public void list_groupedByNone() throws IOException { + final ListResponse response = javaClient().tasks().list(l -> l.groupBy(GroupBy.None)); + assertTrue(response.nodes().isEmpty()); + assertFalse(response.tasks().isEmpty()); + } +} diff --git a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/OpenSearchJavaClientTestCase.java b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/OpenSearchJavaClientTestCase.java index d8a3741cf1..e4825420a8 100644 --- a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/OpenSearchJavaClientTestCase.java +++ b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/OpenSearchJavaClientTestCase.java @@ -46,7 +46,13 @@ import org.opensearch.test.rest.OpenSearchRestTestCase; public abstract class OpenSearchJavaClientTestCase extends OpenSearchRestTestCase implements OpenSearchTransportSupport { - private static final List systemIndices = List.of(".opensearch-observability", ".opendistro_security", ".plugins-ml-config"); + private static final List systemIndices = List.of( + ".opensearch-observability", + ".opendistro_security", + ".plugins-ml-config", + ".plugins-ml-model-group", + ".ql-datasources" + ); private static OpenSearchClient javaClient; private static OpenSearchClient adminJavaClient; diff --git a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/httpclient5/TasksClientIT.java b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/httpclient5/TasksClientIT.java new file mode 100644 index 0000000000..b08857e758 --- /dev/null +++ b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/httpclient5/TasksClientIT.java @@ -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. + */ + +package org.opensearch.client.opensearch.integTest.httpclient5; + +import org.opensearch.client.opensearch.integTest.AbstractTasksClientIT; + +public class TasksClientIT extends AbstractTasksClientIT implements HttpClient5TransportSupport {} diff --git a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/restclient/TasksClientIT.java b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/restclient/TasksClientIT.java new file mode 100644 index 0000000000..02dc989607 --- /dev/null +++ b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/restclient/TasksClientIT.java @@ -0,0 +1,24 @@ +/* + * 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. + */ + +package org.opensearch.client.opensearch.integTest.restclient; + +import java.io.IOException; +import org.apache.hc.core5.http.HttpHost; +import org.opensearch.client.json.jackson.JacksonJsonpMapper; +import org.opensearch.client.opensearch.integTest.AbstractTasksClientIT; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.rest_client.RestClientTransport; +import org.opensearch.common.settings.Settings; + +public class TasksClientIT extends AbstractTasksClientIT { + @Override + public OpenSearchTransport buildTransport(Settings settings, HttpHost[] hosts) throws IOException { + return new RestClientTransport(buildClient(settings, hosts), new JacksonJsonpMapper()); + } +} From 9b2e379a58910f486570d6f1a1be24b015f498f5 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 6 Sep 2024 14:06:44 +1200 Subject: [PATCH 03/11] Begin re-generating `tasks.ListRequest` and `TaskExecutingNode` renaming `State` to `TaskInfo` Signed-off-by: Thomas Farr --- UPGRADING.md | 7 +- .../opensearch/OpenSearchAsyncClientBase.java | 5 + .../opensearch/OpenSearchClientBase.java | 5 + .../client/opensearch/_types/BaseNode.java | 75 +- .../client/opensearch/_types/NodeRole.java | 26 +- .../client/opensearch/tasks/GroupBy.java | 12 +- .../client/opensearch/tasks/ListRequest.java | 131 +-- .../tasks/OpenSearchTasksAsyncClientBase.java | 94 ++ .../tasks/OpenSearchTasksClientBase.java | 90 ++ .../opensearch/tasks/TaskExecutingNode.java | 74 +- .../client/opensearch/tasks/TaskInfo.java} | 171 +-- .../opensearch/OpenSearchAsyncClient.java | 5 - .../client/opensearch/OpenSearchClient.java | 5 - .../tasks/OpenSearchTasksAsyncClient.java | 46 +- .../tasks/OpenSearchTasksClient.java | 45 +- java-codegen/opensearch-openapi.yaml | 1039 ++++++++++------- .../client/codegen/CodeGenerator.java | 3 +- .../client/codegen/model/Namespace.java | 5 +- 18 files changed, 1105 insertions(+), 733 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/BaseNode.java (83%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/NodeRole.java (86%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/tasks/GroupBy.java (84%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/tasks/ListRequest.java (74%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java (73%) rename java-client/src/{main/java/org/opensearch/client/opensearch/tasks/State.java => generated/java/org/opensearch/client/opensearch/tasks/TaskInfo.java} (74%) diff --git a/UPGRADING.md b/UPGRADING.md index 194fd82ae4..dfa60f870b 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -27,4 +27,9 @@ After: ### ShardStatistics properties types - The type of the `total`, `successful` and `failed` fields has been corrected from `Number` to `int`. -- The type of the `skipped` field has been corrected from `Number` to `Integer`. \ No newline at end of file +- The type of the `skipped` field has been corrected from `Number` to `Integer`. + +### tasks.State class renamed to tasks.TaskInfo +- The `tasks.State` class has been renamed to `tasks.TaskInfo`, this affects: + - `TaskExecutingNode`'s `tasks` field. +- The `headers` field is now a `Map` instead of a `Map>`. \ No newline at end of file diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java index bbcfd5d125..cc9296ed41 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java @@ -46,6 +46,7 @@ import org.opensearch.client.opensearch.core.InfoResponse; import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesAsyncClient; import org.opensearch.client.opensearch.ml.OpenSearchMlAsyncClient; +import org.opensearch.client.opensearch.tasks.OpenSearchTasksAsyncClient; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; @@ -68,6 +69,10 @@ public OpenSearchMlAsyncClient ml() { return new OpenSearchMlAsyncClient(this.transport, this.transportOptions); } + public OpenSearchTasksAsyncClient tasks() { + return new OpenSearchTasksAsyncClient(this.transport, this.transportOptions); + } + // ----- Endpoint: info /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java index c6f6b4f877..7e09f00916 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java @@ -45,6 +45,7 @@ import org.opensearch.client.opensearch.core.InfoResponse; import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesClient; import org.opensearch.client.opensearch.ml.OpenSearchMlClient; +import org.opensearch.client.opensearch.tasks.OpenSearchTasksClient; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; @@ -67,6 +68,10 @@ public OpenSearchMlClient ml() { return new OpenSearchMlClient(this.transport, this.transportOptions); } + public OpenSearchTasksClient tasks() { + return new OpenSearchTasksClient(this.transport, this.transportOptions); + } + // ----- Endpoint: info /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/BaseNode.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BaseNode.java similarity index 83% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/BaseNode.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/BaseNode.java index 4494087382..30550ebcf4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/BaseNode.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BaseNode.java @@ -30,11 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; import jakarta.json.stream.JsonGenerator; import java.util.List; import java.util.Map; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -43,32 +48,35 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: _spec_utils.BaseNode +// typedef: _types.BaseNode +@Generated("org.opensearch.client.codegen.CodeGenerator") public abstract class BaseNode implements PlainJsonSerializable { + private final Map attributes; + @Nullable private final String host; + @Nullable private final String ip; private final String name; private final List roles; + @Nullable private final String transportAddress; // --------------------------------------------------------------------------------------------- protected BaseNode(AbstractBuilder builder) { - this.attributes = ApiTypeHelper.unmodifiable(builder.attributes); this.host = builder.host; this.ip = builder.ip; - this.name = builder.name; + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.roles = ApiTypeHelper.unmodifiable(builder.roles); this.transportAddress = builder.transportAddress; - } /** @@ -81,6 +89,7 @@ public final Map attributes() { /** * API name: {@code host} */ + @Nullable public final String host() { return this.host; } @@ -88,12 +97,13 @@ public final String host() { /** * API name: {@code ip} */ + @Nullable public final String ip() { return this.ip; } /** - * API name: {@code name} + * Required - API name: {@code name} */ public final String name() { return this.name; @@ -109,6 +119,7 @@ public final List roles() { /** * API name: {@code transport_address} */ + @Nullable public final String transportAddress() { return this.transportAddress; } @@ -116,6 +127,7 @@ public final String transportAddress() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -123,23 +135,25 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.attributes)) { generator.writeKey("attributes"); generator.writeStartObject(); for (Map.Entry item0 : this.attributes.entrySet()) { generator.writeKey(item0.getKey()); generator.write(item0.getValue()); - } generator.writeEnd(); + } + if (this.host != null) { + generator.writeKey("host"); + generator.write(this.host); } - generator.writeKey("host"); - generator.write(this.host); - generator.writeKey("ip"); - generator.write(this.ip); + if (this.ip != null) { + generator.writeKey("ip"); + generator.write(this.ip); + } generator.writeKey("name"); generator.write(this.name); @@ -151,36 +165,35 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { item0.serialize(generator, mapper); } generator.writeEnd(); - } - generator.writeKey("transport_address"); - generator.write(this.transportAddress); + if (this.transportAddress != null) { + generator.writeKey("transport_address"); + generator.write(this.transportAddress); + } } + // --------------------------------------------------------------------------------------------- + protected abstract static class AbstractBuilder> extends ObjectBuilderBase { @Nullable private Map attributes; - @Nullable private String host; - @Nullable private String ip; - - @Nullable private String name; - @Nullable private List roles; - @Nullable private String transportAddress; /** * API name: {@code attributes} + * *

- * Adds all entries of map to attributes. + * Adds all elements of map to attributes. + *

*/ public final BuilderT attributes(Map map) { this.attributes = _mapPutAll(this.attributes, map); @@ -189,8 +202,10 @@ public final BuilderT attributes(Map map) { /** * API name: {@code attributes} + * *

* Adds an entry to attributes. + *

*/ public final BuilderT attributes(String key, String value) { this.attributes = _mapPut(this.attributes, key, value); @@ -200,7 +215,7 @@ public final BuilderT attributes(String key, String value) { /** * API name: {@code host} */ - public final BuilderT host(String value) { + public final BuilderT host(@Nullable String value) { this.host = value; return self(); } @@ -208,13 +223,13 @@ public final BuilderT host(String value) { /** * API name: {@code ip} */ - public final BuilderT ip(String value) { + public final BuilderT ip(@Nullable String value) { this.ip = value; return self(); } /** - * API name: {@code name} + * Required - API name: {@code name} */ public final BuilderT name(String value) { this.name = value; @@ -223,8 +238,10 @@ public final BuilderT name(String value) { /** * API name: {@code roles} + * *

* Adds all elements of list to roles. + *

*/ public final BuilderT roles(List list) { this.roles = _listAddAll(this.roles, list); @@ -233,8 +250,10 @@ public final BuilderT roles(List list) { /** * API name: {@code roles} + * *

* Adds one or more values to roles. + *

*/ public final BuilderT roles(NodeRole value, NodeRole... values) { this.roles = _listAdd(this.roles, value, values); @@ -244,25 +263,21 @@ public final BuilderT roles(NodeRole value, NodeRole... values) { /** * API name: {@code transport_address} */ - public final BuilderT transportAddress(String value) { + public final BuilderT transportAddress(@Nullable String value) { this.transportAddress = value; return self(); } protected abstract BuilderT self(); - } - // --------------------------------------------------------------------------------------------- - protected static > void setupBaseNodeDeserializer(ObjectDeserializer op) { + protected static > void setupBaseNodeDeserializer(ObjectDeserializer op) { op.add(AbstractBuilder::attributes, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "attributes"); op.add(AbstractBuilder::host, JsonpDeserializer.stringDeserializer(), "host"); op.add(AbstractBuilder::ip, JsonpDeserializer.stringDeserializer(), "ip"); op.add(AbstractBuilder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(AbstractBuilder::roles, JsonpDeserializer.arrayDeserializer(NodeRole._DESERIALIZER), "roles"); op.add(AbstractBuilder::transportAddress, JsonpDeserializer.stringDeserializer(), "transport_address"); - } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeRole.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeRole.java similarity index 86% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeRole.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeRole.java index 530603353f..d948d93a3a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeRole.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeRole.java @@ -30,18 +30,27 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: _types.NodeRole + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum NodeRole implements JsonEnum { - @Deprecated - Master("master"), + Client("client"), ClusterManager("cluster_manager"), + CoordinatingOnly("coordinating_only"), + Data("data"), DataCold("data_cold"), @@ -54,21 +63,18 @@ public enum NodeRole implements JsonEnum { DataWarm("data_warm"), - Client("client"), - Ingest("ingest"), - Ml("ml"), - - VotingOnly("voting_only"), + @Deprecated + Master("master"), - Transform("transform"), + Ml("ml"), RemoteClusterClient("remote_cluster_client"), - CoordinatingOnly("coordinating_only"), + Transform("transform"), - ; + VotingOnly("voting_only"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/GroupBy.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/GroupBy.java similarity index 84% rename from java-client/src/main/java/org/opensearch/client/opensearch/tasks/GroupBy.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/GroupBy.java index 97e40d2b95..a592c3274a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/GroupBy.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/GroupBy.java @@ -30,20 +30,26 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.tasks; +import javax.annotation.Generated; import org.opensearch.client.json.JsonEnum; import org.opensearch.client.json.JsonpDeserializable; +// typedef: tasks.GroupBy + @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public enum GroupBy implements JsonEnum { Nodes("nodes"), - Parents("parents"), - None("none"), - ; + Parents("parents"); private final String jsonValue; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/ListRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/ListRequest.java similarity index 74% rename from java-client/src/main/java/org/opensearch/client/opensearch/tasks/ListRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/ListRequest.java index 19a18cebd9..94b1650945 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/ListRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/ListRequest.java @@ -30,13 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.tasks; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; -import java.util.stream.Collectors; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; @@ -51,10 +55,10 @@ /** * Returns a list of tasks. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class ListRequest extends RequestBase { + private final List actions; @Nullable @@ -77,7 +81,6 @@ public class ListRequest extends RequestBase { // --------------------------------------------------------------------------------------------- private ListRequest(Builder builder) { - this.actions = ApiTypeHelper.unmodifiable(builder.actions); this.detailed = builder.detailed; this.groupBy = builder.groupBy; @@ -85,27 +88,27 @@ private ListRequest(Builder builder) { this.parentTaskId = builder.parentTaskId; this.timeout = builder.timeout; this.waitForCompletion = builder.waitForCompletion; - } - public static ListRequest of(Function> fn) { + public static ListRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * A comma-separated list of actions that should be returned. Leave empty to - * return all. + * Comma-separated list or wildcard expression of actions used to limit the request. *

* API name: {@code actions} + *

*/ public final List actions() { return this.actions; } /** - * Return detailed task information (default: false) + * If `true`, the response includes detailed information about shard recoveries. *

* API name: {@code detailed} + *

*/ @Nullable public final Boolean detailed() { @@ -113,9 +116,10 @@ public final Boolean detailed() { } /** - * Group tasks by nodes or parent/child relationships + * Key used to group tasks in the response. *

* API name: {@code group_by} + *

*/ @Nullable public final GroupBy groupBy() { @@ -123,21 +127,21 @@ public final GroupBy groupBy() { } /** - * A comma-separated list of node IDs or names to limit the returned - * information; use _local to return information from the node - * you're connecting to, leave empty to get information from all nodes + * Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're + * connecting to, leave empty to get information from all nodes. *

* API name: {@code nodes} + *

*/ public final List nodes() { return this.nodes; } /** - * Return tasks with specified parent task id (node_id:task_number). Set to -1 - * to return all. + * Parent task ID used to limit returned information. To return all tasks, omit this parameter or use a value of `-1`. *

* API name: {@code parent_task_id} + *

*/ @Nullable public final String parentTaskId() { @@ -145,9 +149,10 @@ public final String parentTaskId() { } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ @Nullable public final Time timeout() { @@ -155,9 +160,10 @@ public final Time timeout() { } /** - * Wait for the matching tasks to complete (default: false) + * If `true`, the request blocks until the operation is complete. *

* API name: {@code wait_for_completion} + *

*/ @Nullable public final Boolean waitForCompletion() { @@ -169,36 +175,31 @@ public final Boolean waitForCompletion() { /** * Builder for {@link ListRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private List actions; - @Nullable private Boolean detailed; - @Nullable private GroupBy groupBy; - @Nullable private List nodes; - @Nullable private String parentTaskId; - @Nullable private Time timeout; - @Nullable private Boolean waitForCompletion; /** - * A comma-separated list of actions that should be returned. Leave empty to - * return all. + * Comma-separated list or wildcard expression of actions used to limit the request. *

* API name: {@code actions} + *

+ * *

* Adds all elements of list to actions. + *

*/ public final Builder actions(List list) { this.actions = _listAddAll(this.actions, list); @@ -206,12 +207,14 @@ public final Builder actions(List list) { } /** - * A comma-separated list of actions that should be returned. Leave empty to - * return all. + * Comma-separated list or wildcard expression of actions used to limit the request. *

* API name: {@code actions} + *

+ * *

* Adds one or more values to actions. + *

*/ public final Builder actions(String value, String... values) { this.actions = _listAdd(this.actions, value, values); @@ -219,9 +222,10 @@ public final Builder actions(String value, String... values) { } /** - * Return detailed task information (default: false) + * If `true`, the response includes detailed information about shard recoveries. *

* API name: {@code detailed} + *

*/ public final Builder detailed(@Nullable Boolean value) { this.detailed = value; @@ -229,9 +233,10 @@ public final Builder detailed(@Nullable Boolean value) { } /** - * Group tasks by nodes or parent/child relationships + * Key used to group tasks in the response. *

* API name: {@code group_by} + *

*/ public final Builder groupBy(@Nullable GroupBy value) { this.groupBy = value; @@ -239,13 +244,15 @@ public final Builder groupBy(@Nullable GroupBy value) { } /** - * A comma-separated list of node IDs or names to limit the returned - * information; use _local to return information from the node - * you're connecting to, leave empty to get information from all nodes + * Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node + * you're connecting to, leave empty to get information from all nodes. *

* API name: {@code nodes} + *

+ * *

* Adds all elements of list to nodes. + *

*/ public final Builder nodes(List list) { this.nodes = _listAddAll(this.nodes, list); @@ -253,13 +260,15 @@ public final Builder nodes(List list) { } /** - * A comma-separated list of node IDs or names to limit the returned - * information; use _local to return information from the node - * you're connecting to, leave empty to get information from all nodes + * Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node + * you're connecting to, leave empty to get information from all nodes. *

* API name: {@code nodes} + *

+ * *

* Adds one or more values to nodes. + *

*/ public final Builder nodes(String value, String... values) { this.nodes = _listAdd(this.nodes, value, values); @@ -267,10 +276,10 @@ public final Builder nodes(String value, String... values) { } /** - * Return tasks with specified parent task id (node_id:task_number). Set to -1 - * to return all. + * Parent task ID used to limit returned information. To return all tasks, omit this parameter or use a value of `-1`. *

* API name: {@code parent_task_id} + *

*/ public final Builder parentTaskId(@Nullable String value) { this.parentTaskId = value; @@ -278,9 +287,10 @@ public final Builder parentTaskId(@Nullable String value) { } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ public final Builder timeout(@Nullable Time value) { this.timeout = value; @@ -288,18 +298,20 @@ public final Builder timeout(@Nullable Time value) { } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ public final Builder timeout(Function> fn) { - return this.timeout(fn.apply(new Time.Builder()).build()); + return timeout(fn.apply(new Time.Builder()).build()); } /** - * Wait for the matching tasks to complete (default: false) + * If `true`, the request blocks until the operation is complete. *

* API name: {@code wait_for_completion} + *

*/ public final Builder waitForCompletion(@Nullable Boolean value) { this.waitForCompletion = value; @@ -309,8 +321,7 @@ public final Builder waitForCompletion(@Nullable Boolean value) { /** * Builds a {@link ListRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public ListRequest build() { _checkSingleUse(); @@ -325,27 +336,15 @@ public ListRequest build() { * Endpoint "{@code tasks.list}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // Request path - request -> { - return "/_tasks"; - - }, - + request -> "/_tasks", // Request parameters request -> { Map params = new HashMap<>(); - if (ApiTypeHelper.isDefined(request.nodes)) { - params.put("nodes", request.nodes.stream().map(v -> v).collect(Collectors.joining(","))); - } - if (request.parentTaskId != null) { - params.put("parent_task_id", request.parentTaskId); + if (ApiTypeHelper.isDefined(request.actions)) { + params.put("actions", String.join(",", request.actions)); } if (request.detailed != null) { params.put("detailed", String.valueOf(request.detailed)); @@ -353,17 +352,19 @@ public ListRequest build() { if (request.groupBy != null) { params.put("group_by", request.groupBy.jsonValue()); } - if (ApiTypeHelper.isDefined(request.actions)) { - params.put("actions", request.actions.stream().map(v -> v).collect(Collectors.joining(","))); + if (ApiTypeHelper.isDefined(request.nodes)) { + params.put("nodes", String.join(",", request.nodes)); } - if (request.waitForCompletion != null) { - params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); + if (request.parentTaskId != null) { + params.put("parent_task_id", request.parentTaskId); } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } + if (request.waitForCompletion != null) { + params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); + } return params; - }, SimpleEndpoint.emptyMap(), false, diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java new file mode 100644 index 0000000000..143b4335e1 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java @@ -0,0 +1,94 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.tasks; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.util.ObjectBuilder; + +/** + * Client for the tasks namespace. + */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public abstract class OpenSearchTasksAsyncClientBase> extends ApiClient< + OpenSearchTransport, + Self> { + public OpenSearchTasksAsyncClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + // ----- Endpoint: tasks.list + + /** + * Returns a list of tasks. + */ + public CompletableFuture list(ListRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ListRequest, + ListResponse, + ErrorResponse>) ListRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns a list of tasks. + * + * @param fn a function that initializes a builder to create the {@link ListRequest} + */ + public final CompletableFuture list(Function> fn) throws IOException, + OpenSearchException { + return list(fn.apply(new ListRequest.Builder()).build()); + } + + /** + * Returns a list of tasks. + */ + public CompletableFuture list() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(new ListRequest.Builder().build(), ListRequest._ENDPOINT, this.transportOptions); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java new file mode 100644 index 0000000000..06bafd578c --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java @@ -0,0 +1,90 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.tasks; + +import java.io.IOException; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.ApiClient; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.TransportOptions; +import org.opensearch.client.util.ObjectBuilder; + +/** + * Client for the tasks namespace. + */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public abstract class OpenSearchTasksClientBase> extends ApiClient { + public OpenSearchTasksClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + // ----- Endpoint: tasks.list + + /** + * Returns a list of tasks. + */ + public ListResponse list(ListRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ListRequest, + ListResponse, + ErrorResponse>) ListRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns a list of tasks. + * + * @param fn a function that initializes a builder to create the {@link ListRequest} + */ + public final ListResponse list(Function> fn) throws IOException, OpenSearchException { + return list(fn.apply(new ListRequest.Builder()).build()); + } + + /** + * Returns a list of tasks. + */ + public ListResponse list() throws IOException, OpenSearchException { + return this.transport.performRequest(new ListRequest.Builder().build(), ListRequest._ENDPOINT, this.transportOptions); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java similarity index 73% rename from java-client/src/main/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java index 3decbb9016..c12a673473 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java @@ -30,11 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.tasks; import jakarta.json.stream.JsonGenerator; import java.util.Map; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -44,47 +49,41 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; -// typedef: tasks._types.TaskExecutingNode +// typedef: tasks.TaskExecutingNode @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class TaskExecutingNode extends BaseNode { - private final Map tasks; + + private final Map tasks; // --------------------------------------------------------------------------------------------- private TaskExecutingNode(Builder builder) { super(builder); - this.tasks = ApiTypeHelper.unmodifiableRequired(builder.tasks, this, "tasks"); - } - public static TaskExecutingNode of(Function> fn) { + public static TaskExecutingNode of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code tasks} */ - public final Map tasks() { + public final Map tasks() { return this.tasks; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - super.serializeInternal(generator, mapper); - if (ApiTypeHelper.isDefined(this.tasks)) { - generator.writeKey("tasks"); - generator.writeStartObject(); - for (Map.Entry item0 : this.tasks.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - + generator.writeKey("tasks"); + generator.writeStartObject(); + for (Map.Entry item0 : this.tasks.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); } - + generator.writeEnd(); } // --------------------------------------------------------------------------------------------- @@ -92,49 +91,53 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link TaskExecutingNode}. */ - public static class Builder extends BaseNode.AbstractBuilder implements ObjectBuilder { - private Map tasks; + @Override + protected Builder self() { + return this; + } + + private Map tasks; /** * Required - API name: {@code tasks} + * *

- * Adds all entries of map to tasks. + * Adds all elements of map to tasks. + *

*/ - public final Builder tasks(Map map) { + public final Builder tasks(Map map) { this.tasks = _mapPutAll(this.tasks, map); return this; } /** * Required - API name: {@code tasks} + * *

* Adds an entry to tasks. + *

*/ - public final Builder tasks(String key, State value) { + public final Builder tasks(String key, TaskInfo value) { this.tasks = _mapPut(this.tasks, key, value); return this; } /** * Required - API name: {@code tasks} + * *

- * Adds an entry to tasks using a builder lambda. + * Adds a value to tasks using a builder lambda. + *

*/ - public final Builder tasks(String key, Function> fn) { - return tasks(key, fn.apply(new State.Builder()).build()); - } - - @Override - protected Builder self() { - return this; + public final Builder tasks(String key, Function> fn) { + return tasks(key, fn.apply(new TaskInfo.Builder()).build()); } /** * Builds a {@link TaskExecutingNode}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public TaskExecutingNode build() { _checkSingleUse(); @@ -142,7 +145,6 @@ public TaskExecutingNode build() { return new TaskExecutingNode(this); } } - // --------------------------------------------------------------------------------------------- /** @@ -155,8 +157,6 @@ public TaskExecutingNode build() { protected static void setupTaskExecutingNodeDeserializer(ObjectDeserializer op) { BaseNode.setupBaseNodeDeserializer(op); - op.add(Builder::tasks, JsonpDeserializer.stringMapDeserializer(State._DESERIALIZER), "tasks"); - + op.add(Builder::tasks, JsonpDeserializer.stringMapDeserializer(TaskInfo._DESERIALIZER), "tasks"); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/State.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfo.java similarity index 74% rename from java-client/src/main/java/org/opensearch/client/opensearch/tasks/State.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfo.java index 38a227a0c5..0523dc653f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/State.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfo.java @@ -30,12 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.tasks; import jakarta.json.stream.JsonGenerator; -import java.util.List; import java.util.Map; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -43,22 +47,28 @@ import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.Time; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: tasks._types.State +// typedef: tasks.TaskInfo @JsonpDeserializable -public class State implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class TaskInfo implements PlainJsonSerializable { + private final String action; private final boolean cancellable; + @Nullable + private final Boolean cancelled; + @Nullable private final String description; - private final Map> headers; + private final Map headers; private final long id; @@ -67,6 +77,9 @@ public class State implements PlainJsonSerializable { @Nullable private final String parentTaskId; + @Nullable + private final Time runningTime; + private final long runningTimeInNanos; private final long startTimeInMillis; @@ -78,23 +91,23 @@ public class State implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- - private State(Builder builder) { - + private TaskInfo(Builder builder) { this.action = ApiTypeHelper.requireNonNull(builder.action, this, "action"); this.cancellable = ApiTypeHelper.requireNonNull(builder.cancellable, this, "cancellable"); + this.cancelled = builder.cancelled; this.description = builder.description; this.headers = ApiTypeHelper.unmodifiableRequired(builder.headers, this, "headers"); this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); this.node = ApiTypeHelper.requireNonNull(builder.node, this, "node"); this.parentTaskId = builder.parentTaskId; + this.runningTime = builder.runningTime; this.runningTimeInNanos = ApiTypeHelper.requireNonNull(builder.runningTimeInNanos, this, "runningTimeInNanos"); this.startTimeInMillis = ApiTypeHelper.requireNonNull(builder.startTimeInMillis, this, "startTimeInMillis"); this.status = builder.status; this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - } - public static State of(Function> fn) { + public static TaskInfo of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -112,6 +125,14 @@ public final boolean cancellable() { return this.cancellable; } + /** + * API name: {@code cancelled} + */ + @Nullable + public final Boolean cancelled() { + return this.cancelled; + } + /** * API name: {@code description} */ @@ -123,7 +144,7 @@ public final String description() { /** * Required - API name: {@code headers} */ - public final Map> headers() { + public final Map headers() { return this.headers; } @@ -149,6 +170,14 @@ public final String parentTaskId() { return this.parentTaskId; } + /** + * API name: {@code running_time} + */ + @Nullable + public final Time runningTime() { + return this.runningTime; + } + /** * Required - API name: {@code running_time_in_nanos} */ @@ -181,6 +210,7 @@ public final String type() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -188,36 +218,30 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("action"); generator.write(this.action); generator.writeKey("cancellable"); generator.write(this.cancellable); + if (this.cancelled != null) { + generator.writeKey("cancelled"); + generator.write(this.cancelled); + } + if (this.description != null) { generator.writeKey("description"); generator.write(this.description); - } - if (ApiTypeHelper.isDefined(this.headers)) { - generator.writeKey("headers"); - generator.writeStartObject(); - for (Map.Entry> item0 : this.headers.entrySet()) { - generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (String item1 : item0.getValue()) { - generator.write(item1); - - } - } - generator.writeEnd(); - - } - generator.writeEnd(); + generator.writeKey("headers"); + generator.writeStartObject(); + for (Map.Entry item0 : this.headers.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); } + generator.writeEnd(); + generator.writeKey("id"); generator.write(this.id); @@ -227,8 +251,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (this.parentTaskId != null) { generator.writeKey("parent_task_id"); generator.write(this.parentTaskId); + } + if (this.runningTime != null) { + generator.writeKey("running_time"); + this.runningTime.serialize(generator, mapper); } + generator.writeKey("running_time_in_nanos"); generator.write(this.runningTimeInNanos); @@ -238,43 +267,35 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (this.status != null) { generator.writeKey("status"); this.status.serialize(generator, mapper); - } + generator.writeKey("type"); generator.write(this.type); - } // --------------------------------------------------------------------------------------------- /** - * Builder for {@link State}. + * Builder for {@link TaskInfo}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private String action; - private Boolean cancellable; - + @Nullable + private Boolean cancelled; @Nullable private String description; - - private Map> headers; - + private Map headers; private Long id; - private String node; - @Nullable private String parentTaskId; - + @Nullable + private Time runningTime; private Long runningTimeInNanos; - private Long startTimeInMillis; - @Nullable private Status status; - private String type; /** @@ -293,6 +314,14 @@ public final Builder cancellable(boolean value) { return this; } + /** + * API name: {@code cancelled} + */ + public final Builder cancelled(@Nullable Boolean value) { + this.cancelled = value; + return this; + } + /** * API name: {@code description} */ @@ -303,20 +332,24 @@ public final Builder description(@Nullable String value) { /** * Required - API name: {@code headers} + * *

- * Adds all entries of map to headers. + * Adds all elements of map to headers. + *

*/ - public final Builder headers(Map> map) { + public final Builder headers(Map map) { this.headers = _mapPutAll(this.headers, map); return this; } /** * Required - API name: {@code headers} + * *

* Adds an entry to headers. + *

*/ - public final Builder headers(String key, List value) { + public final Builder headers(String key, String value) { this.headers = _mapPut(this.headers, key, value); return this; } @@ -345,6 +378,21 @@ public final Builder parentTaskId(@Nullable String value) { return this; } + /** + * API name: {@code running_time} + */ + public final Builder runningTime(@Nullable Time value) { + this.runningTime = value; + return this; + } + + /** + * API name: {@code running_time} + */ + public final Builder runningTime(Function> fn) { + return runningTime(fn.apply(new Time.Builder()).build()); + } + /** * Required - API name: {@code running_time_in_nanos} */ @@ -373,7 +421,7 @@ public final Builder status(@Nullable Status value) { * API name: {@code status} */ public final Builder status(Function> fn) { - return this.status(fn.apply(new Status.Builder()).build()); + return status(fn.apply(new Status.Builder()).build()); } /** @@ -385,46 +433,39 @@ public final Builder type(String value) { } /** - * Builds a {@link State}. + * Builds a {@link TaskInfo}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ - public State build() { + public TaskInfo build() { _checkSingleUse(); - return new State(this); + return new TaskInfo(this); } } - // --------------------------------------------------------------------------------------------- /** - * Json deserializer for {@link State} + * Json deserializer for {@link TaskInfo} */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( Builder::new, - State::setupStateDeserializer + TaskInfo::setupTaskInfoDeserializer ); - protected static void setupStateDeserializer(ObjectDeserializer op) { - + protected static void setupTaskInfoDeserializer(ObjectDeserializer op) { op.add(Builder::action, JsonpDeserializer.stringDeserializer(), "action"); op.add(Builder::cancellable, JsonpDeserializer.booleanDeserializer(), "cancellable"); + op.add(Builder::cancelled, JsonpDeserializer.booleanDeserializer(), "cancelled"); op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description"); - op.add( - Builder::headers, - JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer())), - "headers" - ); + op.add(Builder::headers, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "headers"); op.add(Builder::id, JsonpDeserializer.longDeserializer(), "id"); op.add(Builder::node, JsonpDeserializer.stringDeserializer(), "node"); op.add(Builder::parentTaskId, JsonpDeserializer.stringDeserializer(), "parent_task_id"); + op.add(Builder::runningTime, Time._DESERIALIZER, "running_time"); op.add(Builder::runningTimeInNanos, JsonpDeserializer.longDeserializer(), "running_time_in_nanos"); op.add(Builder::startTimeInMillis, JsonpDeserializer.longDeserializer(), "start_time_in_millis"); op.add(Builder::status, Status._DESERIALIZER, "status"); op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java index d3bac0d575..a0aca846f8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java @@ -125,7 +125,6 @@ import org.opensearch.client.opensearch.nodes.OpenSearchNodesAsyncClient; import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownAsyncClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotAsyncClient; -import org.opensearch.client.opensearch.tasks.OpenSearchTasksAsyncClient; import org.opensearch.client.transport.JsonEndpoint; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; @@ -184,10 +183,6 @@ public OpenSearchSnapshotAsyncClient snapshot() { return new OpenSearchSnapshotAsyncClient(this.transport, this.transportOptions); } - public OpenSearchTasksAsyncClient tasks() { - return new OpenSearchTasksAsyncClient(this.transport, this.transportOptions); - } - // ----- Endpoint: bulk /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java index 56653330c1..4327951b80 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java @@ -125,7 +125,6 @@ import org.opensearch.client.opensearch.nodes.OpenSearchNodesClient; import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotClient; -import org.opensearch.client.opensearch.tasks.OpenSearchTasksClient; import org.opensearch.client.transport.JsonEndpoint; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; @@ -187,10 +186,6 @@ public OpenSearchSnapshotClient snapshot() { return new OpenSearchSnapshotClient(this.transport, this.transportOptions); } - public OpenSearchTasksClient tasks() { - return new OpenSearchTasksClient(this.transport, this.transportOptions); - } - // ----- Endpoint: bulk /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java index a37ffb494f..d83bb1f53d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java @@ -36,7 +36,6 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Function; import javax.annotation.Nullable; -import org.opensearch.client.ApiClient; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.transport.JsonEndpoint; @@ -47,7 +46,7 @@ /** * Client for the tasks namespace. */ -public class OpenSearchTasksAsyncClient extends ApiClient { +public class OpenSearchTasksAsyncClient extends OpenSearchTasksAsyncClientBase { public OpenSearchTasksAsyncClient(OpenSearchTransport transport) { super(transport, null); @@ -135,47 +134,4 @@ public final CompletableFuture get(Function list(ListRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ListRequest, - ListResponse, - ErrorResponse>) ListRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns a list of tasks. - * - * @param fn - * a function that initializes a builder to create the - * {@link ListRequest} - * - */ - - public final CompletableFuture list(Function> fn) throws IOException, - OpenSearchException { - return list(fn.apply(new ListRequest.Builder()).build()); - } - - /** - * Returns a list of tasks. - * - * - */ - - public CompletableFuture list() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new ListRequest.Builder().build(), ListRequest._ENDPOINT, this.transportOptions); - } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java index 163c83465b..607ba4a6ca 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java @@ -35,7 +35,6 @@ import java.io.IOException; import java.util.function.Function; import javax.annotation.Nullable; -import org.opensearch.client.ApiClient; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.transport.JsonEndpoint; @@ -46,7 +45,7 @@ /** * Client for the tasks namespace. */ -public class OpenSearchTasksClient extends ApiClient { +public class OpenSearchTasksClient extends OpenSearchTasksClientBase { public OpenSearchTasksClient(OpenSearchTransport transport) { super(transport, null); @@ -134,46 +133,4 @@ public final GetTasksResponse get(Function endpoint = (JsonEndpoint< - ListRequest, - ListResponse, - ErrorResponse>) ListRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns a list of tasks. - * - * @param fn - * a function that initializes a builder to create the - * {@link ListRequest} - * - */ - - public final ListResponse list(Function> fn) throws IOException, OpenSearchException { - return list(fn.apply(new ListRequest.Builder()).build()); - } - - /** - * Returns a list of tasks. - * - * - */ - - public ListResponse list() throws IOException, OpenSearchException { - return this.transport.performRequest(new ListRequest.Builder().build(), ListRequest._ENDPOINT, this.transportOptions); - } - } diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index 90a04f5f5f..97f65afef4 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -13272,7 +13272,7 @@ components: in: query description: The unit in which to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' cat.all_pit_segments::query.format: name: format in: query @@ -13331,7 +13331,7 @@ components: name: bytes description: The unit used to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' style: form cat.allocation::query.cluster_manager_timeout: name: cluster_manager_timeout @@ -13541,7 +13541,7 @@ components: name: bytes description: The unit used to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' style: form cat.fielddata::query.fields: in: query @@ -13670,7 +13670,7 @@ components: name: bytes description: The unit used to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' style: form cat.indices::query.cluster_manager_timeout: name: cluster_manager_timeout @@ -13921,7 +13921,7 @@ components: name: bytes description: The unit used to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' style: form cat.nodes::query.cluster_manager_timeout: name: cluster_manager_timeout @@ -14091,7 +14091,7 @@ components: in: query description: The unit in which to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' cat.pit_segments::query.format: name: format in: query @@ -14229,7 +14229,7 @@ components: name: bytes description: The unit used to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' style: form cat.recovery::query.detailed: in: query @@ -14400,7 +14400,7 @@ components: in: query description: The unit in which to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' cat.segment_replication::query.completed_only: name: completed_only in: query @@ -14532,7 +14532,7 @@ components: name: bytes description: The unit used to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' style: form cat.segments::query.cluster_manager_timeout: name: cluster_manager_timeout @@ -14611,7 +14611,7 @@ components: name: bytes description: The unit used to display byte values. schema: - $ref: '#/components/schemas/_common:Bytes' + $ref: '#/components/schemas/_common:StorageType' style: form cat.shards::query.cluster_manager_timeout: name: cluster_manager_timeout @@ -25669,42 +25669,12 @@ components: content: application/json: schema: - type: object - properties: - batches: - type: number - deleted: - type: number - failures: - type: array - items: - $ref: '#/components/schemas/_common:BulkIndexByScrollFailure' - noops: - type: number - requests_per_second: - type: number - retries: - $ref: '#/components/schemas/_common:Retries' - slice_id: - type: number - task: - $ref: '#/components/schemas/_common:TaskId' - throttled: - $ref: '#/components/schemas/_common:Duration' - throttled_millis: - $ref: '#/components/schemas/_common:DurationValueUnitMillis' - throttled_until: - $ref: '#/components/schemas/_common:Duration' - throttled_until_millis: - $ref: '#/components/schemas/_common:DurationValueUnitMillis' - timed_out: - type: boolean - took: - $ref: '#/components/schemas/_common:DurationValueUnitMillis' - total: - type: number - version_conflicts: - type: number + anyOf: + - $ref: '#/components/schemas/_common:BulkByScrollResponseBase' + - type: object + properties: + task: + $ref: '#/components/schemas/_common:TaskId' delete_pit@200: content: application/json: @@ -25952,10 +25922,10 @@ components: items: $ref: '#/components/schemas/indices.data_streams_stats:DataStreamsStatsItem' total_store_sizes: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' total_store_size_bytes: description: Total size, in bytes, of all shards for the selected data streams. - type: number + $ref: '#/components/schemas/_common:Bytes' required: - _shards - backing_indices @@ -26796,42 +26766,12 @@ components: content: application/json: schema: - type: object - properties: - batches: - type: number - created: - type: number - deleted: - type: number - failures: - type: array - items: - $ref: '#/components/schemas/_common:BulkIndexByScrollFailure' - noops: - type: number - retries: - $ref: '#/components/schemas/_common:Retries' - requests_per_second: - type: number - slice_id: - type: number - task: - $ref: '#/components/schemas/_common:TaskId' - throttled_millis: - $ref: '#/components/schemas/_common:EpochTimeUnitMillis' - throttled_until_millis: - $ref: '#/components/schemas/_common:EpochTimeUnitMillis' - timed_out: - type: boolean - took: - $ref: '#/components/schemas/_common:DurationValueUnitMillis' - total: - type: number - updated: - type: number - version_conflicts: - type: number + anyOf: + - $ref: '#/components/schemas/_common:BulkByScrollResponseBase' + - type: object + properties: + task: + $ref: '#/components/schemas/_common:TaskId' remote_store.restore@200: content: application/json: @@ -27796,7 +27736,7 @@ components: task: $ref: '#/components/schemas/tasks._common:TaskInfo' response: - type: object + $ref: '#/components/schemas/tasks._common:TaskResponse' error: $ref: '#/components/schemas/_common:ErrorCause' required: @@ -27885,42 +27825,12 @@ components: content: application/json: schema: - type: object - properties: - batches: - type: number - failures: - type: array - items: - $ref: '#/components/schemas/_common:BulkIndexByScrollFailure' - noops: - type: number - deleted: - type: number - requests_per_second: - type: number - retries: - $ref: '#/components/schemas/_common:Retries' - task: - $ref: '#/components/schemas/_common:TaskId' - timed_out: - type: boolean - took: - $ref: '#/components/schemas/_common:DurationValueUnitMillis' - total: - type: number - updated: - type: number - version_conflicts: - type: number - throttled: - $ref: '#/components/schemas/_common:Duration' - throttled_millis: - $ref: '#/components/schemas/_common:DurationValueUnitMillis' - throttled_until: - $ref: '#/components/schemas/_common:Duration' - throttled_until_millis: - $ref: '#/components/schemas/_common:DurationValueUnitMillis' + anyOf: + - $ref: '#/components/schemas/_common:BulkByScrollResponseBase' + - type: object + properties: + task: + $ref: '#/components/schemas/_common:TaskId' update@200: content: application/json: @@ -27960,12 +27870,100 @@ components: transport_address: $ref: '#/components/schemas/_common:TransportAddress' required: - - attributes - - host - - ip - name - - transport_address - _common:BulkIndexByScrollFailure: + _common:BulkByScrollFailure: + anyOf: + - $ref: '#/components/schemas/_common:BulkItemResponseFailure' + - $ref: '#/components/schemas/_common:ScrollableHitSourceSearchFailure' + _common:BulkByScrollResponseBase: + allOf: + - $ref: '#/components/schemas/_common:BulkByScrollTaskStatus' + - type: object + properties: + took: + type: integer + format: int64 + timed_out: + type: boolean + failures: + type: array + items: + $ref: '#/components/schemas/_common:BulkByScrollFailure' + required: + - failures + - timed_out + - took + _common:BulkByScrollTaskStatus: + type: object + properties: + slice_id: + type: integer + format: int32 + total: + description: The number of documents that were successfully processed. + type: integer + format: int64 + updated: + description: The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex updating it. + type: integer + format: int64 + created: + description: The number of documents that were successfully created. + type: integer + format: int64 + deleted: + description: The number of documents that were successfully deleted. + type: integer + format: int64 + batches: + description: The number of scroll responses pulled back by the reindex. + type: integer + format: int32 + version_conflicts: + description: The number of version conflicts that reindex hits. + type: integer + format: int64 + noops: + description: The number of documents that were ignored. + type: integer + format: int64 + retries: + $ref: '#/components/schemas/_common:Retries' + throttled_millis: + $ref: '#/components/schemas/_common:DurationValueUnitMillis' + throttled: + $ref: '#/components/schemas/_common:Duration' + requests_per_second: + description: The number of requests per second effectively executed during the reindex. + type: number + format: float + canceled: + type: string + throttled_until_millis: + $ref: '#/components/schemas/_common:DurationValueUnitMillis' + throttled_until: + $ref: '#/components/schemas/_common:Duration' + slices: + type: array + items: + $ref: '#/components/schemas/_common:BulkByScrollTaskStatusOrException' + required: + - batches + - deleted + - noops + - requests_per_second + - retries + - throttled_millis + - throttled_until_millis + - total + - version_conflicts + _common:BulkByScrollTaskStatusOrException: + oneOf: + - title: status + $ref: '#/components/schemas/_common:BulkByScrollTaskStatus' + - title: exception + $ref: '#/components/schemas/_common:ErrorCause' + _common:BulkItemResponseFailure: type: object properties: cause: @@ -27975,35 +27973,16 @@ components: index: $ref: '#/components/schemas/_common:IndexName' status: - type: number - type: - type: string + type: integer + format: int32 required: - cause - - id - index - status - - type _common:byte: type: number _common:Bytes: - type: string - enum: - - b - - g - - gb - - k - - kb - - m - - mb - - p - - pb - - t - - tb - _common:ByteSize: - oneOf: - - type: number - - type: string + type: integer _common:ClusterDetails: type: object properties: @@ -28064,9 +28043,9 @@ components: properties: size_in_bytes: description: Total amount, in bytes, of memory used for completion across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' fields: type: object additionalProperties: @@ -28263,9 +28242,9 @@ components: evictions: type: number memory_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' memory_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' fields: type: object additionalProperties: @@ -28276,9 +28255,9 @@ components: type: object properties: memory_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' memory_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' required: - memory_size_in_bytes _common:Fields: @@ -28291,9 +28270,9 @@ components: type: object properties: size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' required: - size_in_bytes _common:FieldValue: @@ -28417,7 +28396,7 @@ components: properties: total: type: number - time: + getTime: $ref: '#/components/schemas/_common:Duration' time_in_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' @@ -28672,21 +28651,21 @@ components: current_docs: type: number current_size: - type: string + $ref: '#/components/schemas/_common:StorageSize' current_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' total: type: number total_auto_throttle: - type: string + $ref: '#/components/schemas/_common:StorageSize' total_auto_throttle_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' total_docs: type: number total_size: - type: string + $ref: '#/components/schemas/_common:StorageSize' total_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' total_stopped_time: $ref: '#/components/schemas/_common:Duration' total_stopped_time_in_millis: @@ -28802,6 +28781,8 @@ components: - remote_cluster_client - transform - voting_only + x-deprecated-enums: + - master _common:NodeRoles: description: Node roles. type: array @@ -29001,10 +28982,10 @@ components: description: Total count of query cache hits across all shards assigned to selected nodes. type: number memory_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' memory_size_in_bytes: description: Total amount, in bytes, of memory used for the query cache across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' miss_count: description: Total count of query cache misses across all shards assigned to selected nodes. type: number @@ -29058,6 +29039,8 @@ components: properties: external_total: type: number + external_total_time: + $ref: '#/components/schemas/_common:Duration' external_total_time_in_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' listeners: @@ -29090,6 +29073,9 @@ components: total_download_size: description: The total amount of data download from the remote segment store. $ref: '#/components/schemas/_common:RemoteStoreUploadDownloadStats' + total_time_spent: + description: The total duration, spent on downloads from the remote segment store. + $ref: '#/components/schemas/_common:Duration' total_time_spent_in_millis: description: The total duration, in milliseconds, spent on downloads from the remote segment store. $ref: '#/components/schemas/_common:DurationValueUnitMillis' @@ -29129,15 +29115,24 @@ components: type: object description: The total amount of data uploaded to the remote translog store. properties: + failed: + description: The number of bytes that failed to upload to the remote translog store. + $ref: '#/components/schemas/_common:StorageSize' failed_bytes: description: The number of bytes that failed to upload to the remote translog store. - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' + started: + description: The number of bytes successfully uploaded to the remote translog store. + $ref: '#/components/schemas/_common:StorageSize' started_bytes: description: The number of bytes successfully uploaded to the remote translog store. - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' + succeeded: + description: The number of bytes successfully uploaded to the remote translog store. + $ref: '#/components/schemas/_common:StorageSize' succeeded_bytes: description: The number of bytes successfully uploaded to the remote translog store. - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' required: - failed_bytes - started_bytes @@ -29163,15 +29158,24 @@ components: type: object description: The amount of data, in bytes, uploaded or downloaded to/from the remote segment store. properties: + failed: + description: The number of bytes that failed to upload/upload to/from the remote segment store. + $ref: '#/components/schemas/_common:StorageSize' failed_bytes: description: The number of bytes that failed to upload/upload to/from the remote segment store. - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' + started: + description: The number of bytes to upload/download to/from the remote segment store after the upload/download has started. + $ref: '#/components/schemas/_common:StorageSize' started_bytes: description: The number of bytes to upload/download to/from the remote segment store after the upload/download has started. - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' + succeeded: + description: The number of bytes successfully uploaded/downloaded to/from the remote segment store. + $ref: '#/components/schemas/_common:StorageSize' succeeded_bytes: description: The number of bytes successfully uploaded/downloaded to/from the remote segment store. - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' required: - failed_bytes - started_bytes @@ -29189,12 +29193,18 @@ components: type: object description: The amount of lag during upload between the remote segment store and the local store. properties: + max: + description: The maximum amount of lag, in bytes, during the upload refresh between the remote segment store and the local store. + $ref: '#/components/schemas/_common:StorageSize' max_bytes: description: The maximum amount of lag, in bytes, during the upload refresh between the remote segment store and the local store. - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' + total: + description: The total number of bytes that lagged during the upload refresh between the remote segment store and the local store. + $ref: '#/components/schemas/_common:StorageSize' total_bytes: description: The total number of bytes that lagged during the upload refresh between the remote segment store and the local store. - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' required: - max_bytes - total_bytes @@ -29202,6 +29212,9 @@ components: type: object description: Statistics related to uploads to the remote segment store. properties: + max_refresh_time_lag: + description: The maximum duration that the remote refresh is behind the local refresh. + $ref: '#/components/schemas/_common:Duration' max_refresh_time_lag_in_millis: description: The maximum duration, in milliseconds, that the remote refresh is behind the local refresh. $ref: '#/components/schemas/_common:DurationValueUnitMillis' @@ -29209,6 +29222,9 @@ components: $ref: '#/components/schemas/_common:RemoteStoreUploadPressureStats' refresh_size_lag: $ref: '#/components/schemas/_common:RemoteStoreUploadRefreshSizeLagStats' + total_time_spent: + description: The total amount of time, spent on uploads to the remote segment store. + $ref: '#/components/schemas/_common:Duration' total_time_spent_in_millis: description: The total amount of time, in milliseconds, spent on uploads to the remote segment store. $ref: '#/components/schemas/_common:DurationValueUnitMillis' @@ -29228,9 +29244,9 @@ components: hit_count: type: number memory_size: - type: string + $ref: '#/components/schemas/_common:StorageSize' memory_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' miss_count: type: number required: @@ -29241,6 +29257,8 @@ components: _common:RequestStats: type: object properties: + time: + $ref: '#/components/schemas/_common:Duration' time_in_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' current: @@ -29340,6 +29358,24 @@ components: - number - string - version + _common:ScrollableHitSourceSearchFailure: + type: object + properties: + index: + $ref: '#/components/schemas/_common:IndexName' + shard: + type: integer + format: int32 + node: + type: string + status: + type: integer + format: int32 + reason: + $ref: '#/components/schemas/_common:ErrorCause' + required: + - reason + - status _common:ScrollId: type: string _common:ScrollIds: @@ -29460,11 +29496,11 @@ components: type: object properties: max_bytes_behind: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' max_replication_lag: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' total_bytes_behind: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' required: - max_bytes_behind - max_replication_lag @@ -29476,10 +29512,10 @@ components: description: Total number of segments across all shards assigned to selected nodes. type: number doc_values_memory: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' doc_values_memory_in_bytes: description: Total amount, in bytes, of memory used for doc values across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' file_sizes: description: |- This object is not populated by the cluster stats API. @@ -29488,55 +29524,62 @@ components: additionalProperties: $ref: '#/components/schemas/indices.stats:ShardFileSizeInfo' fixed_bit_set: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' fixed_bit_set_memory_in_bytes: description: Total amount of memory, in bytes, used by fixed bit sets across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' index_writer_memory: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' index_writer_max_memory_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' index_writer_memory_in_bytes: description: Total amount, in bytes, of memory used by all index writers across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' max_unsafe_auto_id_timestamp: description: Unix timestamp, in milliseconds, of the most recently retried indexing request. type: number memory: - $ref: '#/components/schemas/_common:ByteSize' + description: Total amount, of memory used for segments across all shards assigned to selected nodes. + $ref: '#/components/schemas/_common:StorageSize' memory_in_bytes: description: Total amount, in bytes, of memory used for segments across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' norms_memory: - $ref: '#/components/schemas/_common:ByteSize' + description: Total amount of memory used for normalization factors across all shards assigned to selected nodes. + $ref: '#/components/schemas/_common:StorageSize' norms_memory_in_bytes: description: Total amount, in bytes, of memory used for normalization factors across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' points_memory: - $ref: '#/components/schemas/_common:ByteSize' + description: Total amount of memory used for points across all shards assigned to selected nodes. + $ref: '#/components/schemas/_common:StorageSize' points_memory_in_bytes: description: Total amount, in bytes, of memory used for points across all shards assigned to selected nodes. - type: number - stored_memory: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' + stored_fields_memory: + description: Total amount of memory used for stored fields across all shards assigned to selected nodes. + $ref: '#/components/schemas/_common:StorageSize' stored_fields_memory_in_bytes: description: Total amount, in bytes, of memory used for stored fields across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' + terms_memory: + description: Total amount of memory used for terms across all shards assigned to selected nodes. + $ref: '#/components/schemas/_common:StorageSize' terms_memory_in_bytes: description: Total amount, in bytes, of memory used for terms across all shards assigned to selected nodes. - type: number - terms_memory: - $ref: '#/components/schemas/_common:ByteSize' - term_vectory_memory: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' + term_vectors_memory: + description: Total amount of memory used for term vectors across all shards assigned to selected nodes. + $ref: '#/components/schemas/_common:StorageSize' term_vectors_memory_in_bytes: description: Total amount, in bytes, of memory used for term vectors across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' version_map_memory: - $ref: '#/components/schemas/_common:ByteSize' + description: Total amount of memory used by all version maps across all shards assigned to selected nodes. + $ref: '#/components/schemas/_common:StorageSize' version_map_memory_in_bytes: description: Total amount, in bytes, of memory used by all version maps across all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' remote_store: $ref: '#/components/schemas/_common:RemoteStoreStats' segment_replication: @@ -29663,6 +29706,23 @@ components: type: array items: $ref: '#/components/schemas/_common:FieldValue' + _common:StorageSize: + type: string + pattern: \d+(\.\d+)?(b|kb|k|mb|m|gb|g|tb|t|pb|p) + _common:StorageType: + type: string + enum: + - b + - g + - gb + - k + - kb + - m + - mb + - p + - pb + - t + - tb _common:StoredScript: type: object properties: @@ -29691,15 +29751,15 @@ components: type: object properties: size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' size_in_bytes: description: Total size, in bytes, of all shards assigned to selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' reserved: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' reserved_in_bytes: description: A prediction, in bytes, of how much larger the shard stores will eventually grow due to ongoing peer recoveries, restoring snapshots, and similar activities. - type: number + $ref: '#/components/schemas/_common:Bytes' required: - reserved_in_bytes - size_in_bytes @@ -29763,7 +29823,7 @@ components: type: object properties: task_id: - type: number + type: integer node_id: $ref: '#/components/schemas/_common:NodeId' status: @@ -29824,15 +29884,15 @@ components: remote_store: $ref: '#/components/schemas/_common:RemoteStoreTranslogStats' size: - type: string + $ref: '#/components/schemas/_common:StorageSize' size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' uncommitted_operations: type: number uncommitted_size: - type: string + $ref: '#/components/schemas/_common:StorageSize' uncommitted_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' required: - earliest_last_modified_age - operations @@ -40847,44 +40907,44 @@ components: description: |- Disk space used by the node's shards. Does not include disk space for the translog or unassigned shards. IMPORTANT: This metric double-counts disk space for hard-linked files, such as those created when shrinking, splitting, or cloning an index. - anyOf: - - $ref: '#/components/schemas/_common:ByteSize' - - type: 'null' + type: + - 'null' + - string disk.used: description: |- Total disk space in use. OpenSearch retrieves this metric from the node's operating system (OS). The metric includes disk space for: OpenSearch, including the translog and unassigned shards; the node's operating system; any other applications or files on the node. Unlike `disk.indices`, this metric does not double-count disk space for hard-linked files. - anyOf: - - $ref: '#/components/schemas/_common:ByteSize' - - type: 'null' + type: + - 'null' + - string disk.avail: description: |- Free disk space available to OpenSearch. OpenSearch retrieves this metric from the node's operating system. Disk-based shard allocation uses this metric to assign shards to nodes based on available disk space. - anyOf: - - $ref: '#/components/schemas/_common:ByteSize' - - type: 'null' + type: + - 'null' + - string disk.total: description: Total disk space for the node, including in-use and available space. - anyOf: - - $ref: '#/components/schemas/_common:ByteSize' - - type: 'null' + type: + - 'null' + - string disk.percent: description: Total percentage of disk space in use. Calculated as `disk.used / disk.total`. - anyOf: + oneOf: - $ref: '#/components/schemas/_common:Percentage' - type: 'null' host: description: Network host for the node. Set using the `network.host` setting. - anyOf: + oneOf: - $ref: '#/components/schemas/_common:Host' - type: 'null' ip: description: IP address and port for the node. - anyOf: + oneOf: - $ref: '#/components/schemas/_common:Ip' - type: 'null' node: @@ -41752,11 +41812,11 @@ components: description: The Java version. type: string disk.total: - $ref: '#/components/schemas/_common:ByteSize' + type: string disk.used: - $ref: '#/components/schemas/_common:ByteSize' + type: string disk.avail: - $ref: '#/components/schemas/_common:ByteSize' + type: string disk.used_percent: $ref: '#/components/schemas/_common:Percentage' heap.current: @@ -42183,9 +42243,9 @@ components: Also, OpenSearch creates extra deleted documents to internally track the recent history of operations on a shard. type: string size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' size.memory: - $ref: '#/components/schemas/_common:ByteSize' + type: string committed: description: |- If `true`, the segment is synced to disk. @@ -42897,7 +42957,7 @@ components: in_sync: type: boolean matching_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' matching_sync_id: type: boolean store_exception: @@ -42919,7 +42979,9 @@ components: shard_sizes: type: object additionalProperties: - type: number + oneOf: + - $ref: '#/components/schemas/_common:Bytes' + - $ref: '#/components/schemas/_common:StorageSize' shard_data_set_sizes: type: object additionalProperties: @@ -42974,12 +43036,18 @@ components: properties: path: type: string + total: + $ref: '#/components/schemas/_common:StorageSize' total_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' + used: + $ref: '#/components/schemas/_common:StorageSize' used_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' + free: + $ref: '#/components/schemas/_common:StorageSize' free_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' free_disk_percent: type: number used_disk_percent: @@ -43545,21 +43613,37 @@ components: cluster.stats:ClusterFileSystem: type: object properties: + available: + description: |- + Total number of bytes available to JVM in file stores across all selected nodes. + Depending on operating system or process-level restrictions, this number may be less than `nodes.fs.free_in_byes`. + This is the actual amount of free disk space the selected OpenSearch nodes can use. + $ref: '#/components/schemas/_common:StorageSize' available_in_bytes: description: |- Total number of bytes available to JVM in file stores across all selected nodes. Depending on operating system or process-level restrictions, this number may be less than `nodes.fs.free_in_byes`. This is the actual amount of free disk space the selected OpenSearch nodes can use. - type: number + $ref: '#/components/schemas/_common:Bytes' + free: + description: Total number of unallocated bytes in file stores across all selected nodes. + $ref: '#/components/schemas/_common:StorageSize' free_in_bytes: description: Total number of unallocated bytes in file stores across all selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' + total: + description: Total size, of all file stores across all selected nodes. + $ref: '#/components/schemas/_common:StorageSize' total_in_bytes: description: Total size, in bytes, of all file stores across all selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' + cache_reserved: + description: Total size, of all cache reserved across all selected nodes. + $ref: '#/components/schemas/_common:StorageSize' + x-version-added: '2.7' cache_reserved_in_bytes: description: Total size, in bytes, of all cache reserved across all selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' x-version-added: '2.7' required: - available_in_bytes @@ -43647,6 +43731,8 @@ components: cluster.stats:ClusterJvm: type: object properties: + max_uptime: + $ref: '#/components/schemas/_common:Duration' max_uptime_in_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' mem: @@ -43667,12 +43753,18 @@ components: cluster.stats:ClusterJvmMemory: type: object properties: + heap_max: + description: Maximum amount of memory available for use by the heap across all selected nodes. + $ref: '#/components/schemas/_common:StorageSize' heap_max_in_bytes: description: Maximum amount of memory, in bytes, available for use by the heap across all selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' + heap_used: + description: Memory currently in use by the heap across all selected nodes. + $ref: '#/components/schemas/_common:StorageSize' heap_used_in_bytes: description: Memory, in bytes, currently in use by the heap across all selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' required: - heap_max_in_bytes - heap_used_in_bytes @@ -44011,10 +44103,10 @@ components: description: Total number of fields in all non-system indices, accounting for mapping deduplication. type: number total_deduplicated_mapping_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' total_deduplicated_mapping_size_in_bytes: description: Total size of all mappings, in bytes, after deduplication and compression. - type: number + $ref: '#/components/schemas/_common:Bytes' required: - field_types cluster.stats:IndexingPressure: @@ -44030,7 +44122,7 @@ components: current: $ref: '#/components/schemas/cluster.stats:IndexingPressureMemorySummary' limit_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' total: $ref: '#/components/schemas/cluster.stats:IndexingPressureMemorySummary' required: @@ -44041,19 +44133,19 @@ components: type: object properties: all_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' combined_coordinating_and_primary_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' coordinating_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' coordinating_rejections: type: number primary_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' primary_rejections: type: number replica_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' replica_rejections: type: number required: @@ -44070,7 +44162,7 @@ components: primary_shard_count: type: number total_primary_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' version: $ref: '#/components/schemas/_common:VersionString' required: @@ -44098,19 +44190,28 @@ components: properties: adjusted_total_in_bytes: description: Total amount, in bytes, of memory across all selected nodes, but using the value specified using the `es.total_memory_bytes` system property instead of measured total memory for those nodes where that system property was set. - type: number + $ref: '#/components/schemas/_common:Bytes' + free: + description: Amount, in bytes, of free physical memory across all selected nodes. + $ref: '#/components/schemas/_common:StorageSize' free_in_bytes: description: Amount, in bytes, of free physical memory across all selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' free_percent: description: Percentage of free physical memory across all selected nodes. type: number + total: + description: Total amount of physical memory across all selected nodes. + $ref: '#/components/schemas/_common:StorageSize' total_in_bytes: description: Total amount, in bytes, of physical memory across all selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' + used: + description: Amount of physical memory in use across all selected nodes. + $ref: '#/components/schemas/_common:StorageSize' used_in_bytes: description: Amount, in bytes, of physical memory in use across all selected nodes. - type: number + $ref: '#/components/schemas/_common:Bytes' used_percent: description: Percentage of physical memory in use across all selected nodes. type: number @@ -44392,13 +44493,13 @@ components: max_docs: type: number min_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' max_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' min_primary_shard_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' max_primary_shard_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' min_primary_shard_docs: type: number max_primary_shard_docs: @@ -45232,7 +45333,7 @@ components: durability: $ref: '#/components/schemas/indices._common:TranslogDurability' flush_threshold_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' retention: $ref: '#/components/schemas/indices._common:TranslogRetention' indices._common:TranslogDurability: @@ -45244,7 +45345,7 @@ components: type: object properties: size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' age: $ref: '#/components/schemas/_common:Duration' indices.add_block:IndicesBlockOptions: @@ -45407,10 +45508,10 @@ components: maximum_timestamp: $ref: '#/components/schemas/_common:EpochTimeUnitMillis' store_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' store_size_bytes: description: Total size, in bytes, of all shards for the data stream's backing indices. - type: number + $ref: '#/components/schemas/_common:Bytes' required: - backing_indices - data_stream @@ -45490,21 +45591,21 @@ components: percent: $ref: '#/components/schemas/_common:Percentage' recovered: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' recovered_in_bytes: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' recovered_from_snapshot: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' recovered_from_snapshot_in_bytes: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' reused: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' reused_in_bytes: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' total: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' total_in_bytes: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' required: - percent - recovered_in_bytes @@ -45744,21 +45845,21 @@ components: max_docs: type: number max_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' max_size_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' min_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' min_size_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' max_primary_shard_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' max_primary_shard_size_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' min_primary_shard_size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' min_primary_shard_size_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' max_primary_shard_docs: type: number min_primary_shard_docs: @@ -45770,35 +45871,41 @@ components: type: object additionalProperties: oneOf: - - $ref: '#/components/schemas/indices.segments:ShardsSegment' - type: array items: $ref: '#/components/schemas/indices.segments:ShardsSegment' + - $ref: '#/components/schemas/indices.segments:ShardsSegment' required: - shards indices.segments:Segment: type: object properties: - attributes: - type: object - additionalProperties: - type: string + generation: + type: integer + num_docs: + type: integer + deleted_docs: + type: integer + size: + $ref: '#/components/schemas/_common:StorageSize' + size_in_bytes: + $ref: '#/components/schemas/_common:Bytes' + memory: + $ref: '#/components/schemas/_common:StorageSize' + memory_in_bytes: + $ref: '#/components/schemas/_common:Bytes' committed: type: boolean - compound: - type: boolean - deleted_docs: - type: number - generation: - type: number search: type: boolean - size_in_bytes: - type: number - num_docs: - type: number version: $ref: '#/components/schemas/_common:VersionString' + compound: + type: boolean + attributes: + type: object + additionalProperties: + type: string required: - attributes - committed @@ -46025,14 +46132,16 @@ components: properties: description: type: string + size: + $ref: '#/components/schemas/_common:StorageSize' size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' min_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' max_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' average_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' count: type: number required: @@ -47349,16 +47458,16 @@ components: properties: estimated_size: description: Estimated memory used for the operation. - type: string + $ref: '#/components/schemas/_common:StorageSize' estimated_size_in_bytes: description: Estimated memory used, in bytes, for the operation. - type: number + $ref: '#/components/schemas/_common:Bytes' limit_size: description: Memory limit for the circuit breaker. - type: string + $ref: '#/components/schemas/_common:StorageSize' limit_size_in_bytes: description: Memory limit, in bytes, for the circuit breaker. - type: number + $ref: '#/components/schemas/_common:Bytes' overhead: description: A constant that all estimates for the circuit breaker are multiplied with to calculate a final estimate. type: number @@ -47450,7 +47559,7 @@ components: type: number request_size_bytes: description: Cumulative size in bytes of all requests from this client. - type: number + $ref: '#/components/schemas/_common:Bytes' x_opaque_id: description: |- Value from the client's `x-opaque-id` HTTP header. @@ -47570,34 +47679,38 @@ components: properties: available: description: Total amount of disk space available to this Java virtual machine on this file store. - type: string + $ref: '#/components/schemas/_common:StorageSize' available_in_bytes: description: Total number of bytes available to this Java virtual machine on this file store. - type: number + $ref: '#/components/schemas/_common:Bytes' + cache_reserved: + x-version-added: '2.7' + description: Total number of cache bytes reserved available to this Java virtual machine on this file store. + $ref: '#/components/schemas/_common:StorageSize' cache_reserved_in_bytes: x-version-added: '2.7' description: Total number of cache bytes reserved available to this Java virtual machine on this file store. - type: number + $ref: '#/components/schemas/_common:Bytes' disk_queue: type: string disk_reads: type: number disk_read_size: - type: string + $ref: '#/components/schemas/_common:StorageSize' disk_read_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' disk_writes: type: number disk_write_size: - type: string + $ref: '#/components/schemas/_common:StorageSize' disk_write_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' free: description: Total amount of unallocated disk space in the file store. - type: string + $ref: '#/components/schemas/_common:StorageSize' free_in_bytes: description: Total number of unallocated bytes in the file store. - type: number + $ref: '#/components/schemas/_common:Bytes' mount: description: 'Mount point of the file store (for example: `/dev/sda2`).' type: string @@ -47606,10 +47719,10 @@ components: type: string total: description: Total size of the file store. - type: string + $ref: '#/components/schemas/_common:StorageSize' total_in_bytes: description: Total size of the file store in bytes. - type: number + $ref: '#/components/schemas/_common:Bytes' type: description: 'Type of the file store (ex: ext4).' type: string @@ -47671,29 +47784,33 @@ components: Total disk space available to this Java virtual machine on all file stores. Depending on OS or process level restrictions, this might appear less than `free`. This is the actual amount of free disk space the OpenSearch node can utilize. - type: string + $ref: '#/components/schemas/_common:StorageSize' available_in_bytes: description: |- Total number of bytes available to this Java virtual machine on all file stores. Depending on OS or process level restrictions, this might appear less than `free_in_bytes`. This is the actual amount of free disk space the OpenSearch node can utilize. - type: number + $ref: '#/components/schemas/_common:Bytes' free: description: Total unallocated disk space in all file stores. - type: string + $ref: '#/components/schemas/_common:StorageSize' free_in_bytes: description: Total number of unallocated bytes in all file stores. - type: number + $ref: '#/components/schemas/_common:Bytes' total: description: Total size of all file stores. - type: string + $ref: '#/components/schemas/_common:StorageSize' total_in_bytes: description: Total size of all file stores in bytes. - type: number + $ref: '#/components/schemas/_common:Bytes' + cache_reserved: + x-version-added: '2.7' + description: Total size of cache bytes reserved in all file stores. + $ref: '#/components/schemas/_common:StorageSize' cache_reserved_in_bytes: x-version-added: '2.7' description: Total size of cache bytes reserved in all file stores. - type: number + $ref: '#/components/schemas/_common:Bytes' nodes._common:GarbageCollector: type: object properties: @@ -47739,12 +47856,12 @@ components: type: object properties: limit: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' limit_in_bytes: description: |- Configured memory limit, in bytes, for the indexing requests. Replica requests have an automatic limit that is 1.5x this value. - type: number + $ref: '#/components/schemas/_common:Bytes' current: $ref: '#/components/schemas/nodes._common:PressureMemory' total: @@ -47778,6 +47895,8 @@ components: type: object additionalProperties: $ref: '#/components/schemas/nodes._common:KeyedProcessor' + time: + $ref: '#/components/schemas/_common:Duration' time_in_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' nodes._common:IoStatDevice: @@ -47863,24 +47982,39 @@ components: nodes._common:JvmMemoryStats: type: object properties: + heap_used: + description: Memory currently in use by the heap. + $ref: '#/components/schemas/_common:StorageSize' heap_used_in_bytes: description: Memory, in bytes, currently in use by the heap. - type: number + $ref: '#/components/schemas/_common:Bytes' heap_used_percent: description: Percentage of memory currently in use by the heap. type: number + heap_committed: + description: Amount of memory available for use by the heap. + $ref: '#/components/schemas/_common:StorageSize' heap_committed_in_bytes: description: Amount of memory, in bytes, available for use by the heap. - type: number + $ref: '#/components/schemas/_common:Bytes' + heap_max: + description: Maximum amount of memory available for use by the heap. + $ref: '#/components/schemas/_common:StorageSize' heap_max_in_bytes: description: Maximum amount of memory, in bytes, available for use by the heap. - type: number + $ref: '#/components/schemas/_common:Bytes' + non_heap_used: + description: Non-heap memory used. + $ref: '#/components/schemas/_common:StorageSize' non_heap_used_in_bytes: description: Non-heap memory used, in bytes. - type: number + $ref: '#/components/schemas/_common:Bytes' + non_heap_committed: + description: Amount of non-heap memory available. + $ref: '#/components/schemas/_common:StorageSize' non_heap_committed_in_bytes: description: Amount of non-heap memory available, in bytes. - type: number + $ref: '#/components/schemas/_common:Bytes' pools: description: Contains statistics about heap memory usage for the node. type: object @@ -47905,10 +48039,14 @@ components: nodes._common:LastGcStats: type: object properties: + used: + $ref: '#/components/schemas/_common:StorageSize' used_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' + max: + $ref: '#/components/schemas/_common:StorageSize' max_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' usage_percent: type: number nodes._common:MemoryStats: @@ -47918,28 +48056,37 @@ components: description: |- If the amount of physical memory has been overridden using the `es`.`total_memory_bytes` system property then this reports the overridden value in bytes. Otherwise it reports the same value as `total_in_bytes`. - type: number + $ref: '#/components/schemas/_common:Bytes' resident: - type: string + $ref: '#/components/schemas/_common:StorageSize' resident_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' share: - type: string + $ref: '#/components/schemas/_common:StorageSize' share_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' total_virtual: - type: string + $ref: '#/components/schemas/_common:StorageSize' total_virtual_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' + total: + description: Total amount of physical memory. + $ref: '#/components/schemas/_common:StorageSize' total_in_bytes: description: Total amount of physical memory in bytes. - type: number + $ref: '#/components/schemas/_common:Bytes' + free: + description: Amount of free physical memory. + $ref: '#/components/schemas/_common:StorageSize' free_in_bytes: description: Amount of free physical memory in bytes. - type: number + $ref: '#/components/schemas/_common:Bytes' + used: + description: Amount of used physical memory. + $ref: '#/components/schemas/_common:StorageSize' used_in_bytes: description: Amount of used physical memory in bytes. - type: number + $ref: '#/components/schemas/_common:Bytes' nodes._common:NodeBufferPool: type: object properties: @@ -47948,16 +48095,16 @@ components: type: number total_capacity: description: Total capacity of buffer pools. - type: string + $ref: '#/components/schemas/_common:StorageSize' total_capacity_in_bytes: description: Total capacity of buffer pools in bytes. - type: number + $ref: '#/components/schemas/_common:Bytes' used: description: Size of buffer pools. - type: string + $ref: '#/components/schemas/_common:StorageSize' used_in_bytes: description: Size of buffer pools in bytes. - type: number + $ref: '#/components/schemas/_common:Bytes' nodes._common:NodeReloadError: type: object properties: @@ -47992,18 +48139,30 @@ components: nodes._common:Pool: type: object properties: + used: + description: Memory used by the heap. + $ref: '#/components/schemas/_common:StorageSize' used_in_bytes: description: Memory, in bytes, used by the heap. - type: number + $ref: '#/components/schemas/_common:Bytes' + max: + description: Maximum amount of memory available for use by the heap. + $ref: '#/components/schemas/_common:StorageSize' max_in_bytes: description: Maximum amount of memory, in bytes, available for use by the heap. - type: number + $ref: '#/components/schemas/_common:Bytes' + peak_used: + description: Largest amount of memory historically used by the heap. + $ref: '#/components/schemas/_common:StorageSize' peak_used_in_bytes: description: Largest amount of memory, in bytes, historically used by the heap. - type: number + $ref: '#/components/schemas/_common:Bytes' + peak_max: + description: Largest amount of memory historically used by the heap. + $ref: '#/components/schemas/_common:StorageSize' peak_max_in_bytes: description: Largest amount of memory, in bytes, historically used by the heap. - type: number + $ref: '#/components/schemas/_common:Bytes' last_gc_stats: description: Most recent GC cycle stats for a particular memory pool. $ref: '#/components/schemas/nodes._common:LastGcStats' @@ -48011,32 +48170,32 @@ components: type: object properties: all: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' all_in_bytes: description: Memory consumed, in bytes, by indexing requests in the coordinating, primary, or replica stage. - type: number + $ref: '#/components/schemas/_common:Bytes' combined_coordinating_and_primary: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' combined_coordinating_and_primary_in_bytes: description: |- Memory consumed, in bytes, by indexing requests in the coordinating or primary stage. This value is not the sum of coordinating and primary as a node can reuse the coordinating memory if the primary stage is executed locally. - type: number + $ref: '#/components/schemas/_common:Bytes' coordinating: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' coordinating_in_bytes: description: Memory consumed, in bytes, by indexing requests in the coordinating stage. - type: number + $ref: '#/components/schemas/_common:Bytes' primary: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' primary_in_bytes: description: Memory consumed, in bytes, by indexing requests in the primary stage. - type: number + $ref: '#/components/schemas/_common:Bytes' replica: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' replica_in_bytes: description: Memory consumed, in bytes, by indexing requests in the replica stage. - type: number + $ref: '#/components/schemas/_common:Bytes' coordinating_rejections: description: Number of indexing requests rejected in the coordinating stage. type: number @@ -48156,13 +48315,13 @@ components: count: type: number uncompressed_size: - type: string + $ref: '#/components/schemas/_common:StorageSize' uncompressed_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' compressed_size: - type: string + $ref: '#/components/schemas/_common:StorageSize' compressed_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' nodes._common:ShardAdmissionControlStats: type: object properties: @@ -48177,8 +48336,10 @@ components: nodes._common:ShardCacheStats: type: object properties: + size: + $ref: '#/components/schemas/_common:StorageSize' size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' evictions: type: number hit_count: @@ -48267,8 +48428,12 @@ components: properties: cancellation_count: type: number + current_max: + $ref: '#/components/schemas/_common:Duration' current_max_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' + current_avg: + $ref: '#/components/schemas/_common:Duration' current_avg_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' nodes._common:ShardSearchBackpressureTaskResourceTrackerElapsedTimeTrackerStats: @@ -48276,8 +48441,12 @@ components: properties: cancellation_count: type: number + current_max: + $ref: '#/components/schemas/_common:Duration' current_max_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' + current_avg: + $ref: '#/components/schemas/_common:Duration' current_avg_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' nodes._common:ShardSearchBackpressureTaskResourceTrackerHeapUsageTrackerStats: @@ -48285,12 +48454,18 @@ components: properties: cancellation_count: type: number + current_max: + $ref: '#/components/schemas/_common:StorageSize' current_max_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' + current_avg: + $ref: '#/components/schemas/_common:StorageSize' current_avg_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' + rolling_avg: + $ref: '#/components/schemas/_common:StorageSize' rolling_avg_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' nodes._common:ShardSearchBackpressureTaskResourceTrackerStats: type: object properties: @@ -48324,6 +48499,8 @@ components: properties: count: type: number + time: + $ref: '#/components/schemas/_common:Duration' time_in_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' current: @@ -48470,6 +48647,11 @@ components: threads: description: Number of threads in the thread pool. type: number + total_wait_time: + description: | + The total amount of time that tasks spend waiting in the thread pool queue. + Currently, only `search`, `search_throttled`, and `index_searcher` thread pools support this metric. + $ref: '#/components/schemas/_common:Duration' total_wait_time_in_nanos: description: | The total amount of time that tasks spend waiting in the thread pool queue. @@ -48502,10 +48684,10 @@ components: type: number rx_size: description: Size of RX packets received by the node during internal cluster communication. - type: string + $ref: '#/components/schemas/_common:StorageSize' rx_size_in_bytes: description: Size, in bytes, of RX packets received by the node during internal cluster communication. - type: number + $ref: '#/components/schemas/_common:Bytes' server_open: description: Current number of inbound TCP connections used for internal communication between nodes. type: number @@ -48514,10 +48696,10 @@ components: type: number tx_size: description: Size of TX packets sent by the node during internal cluster communication. - type: string + $ref: '#/components/schemas/_common:StorageSize' tx_size_in_bytes: description: Size, in bytes, of TX packets sent by the node during internal cluster communication. - type: number + $ref: '#/components/schemas/_common:Bytes' total_outbound_connections: description: |- The cumulative number of outbound transport connections that this node has opened since it started. @@ -48619,7 +48801,7 @@ components: description: Total heap allowed to be used to hold recently indexed documents before they must be written to disk. This size is a shared pool across all shards on this node, and is controlled by Indexing Buffer settings. type: number total_indexing_buffer_in_bytes: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:Bytes' transport: $ref: '#/components/schemas/nodes.info:NodeInfoTransport' transport_address: @@ -48689,9 +48871,9 @@ components: items: type: string max_content_length: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' max_content_length_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' publish_address: type: string required: @@ -48732,25 +48914,25 @@ components: type: object properties: direct_max: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' direct_max_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' heap_init: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' heap_init_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' heap_max: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' heap_max_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' non_heap_init: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' non_heap_init_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' non_heap_max: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' non_heap_max_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' required: - direct_max_in_bytes - heap_init_in_bytes @@ -48761,9 +48943,9 @@ components: type: object properties: total: - type: string + $ref: '#/components/schemas/_common:StorageSize' total_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' required: - total - total_in_bytes @@ -48794,9 +48976,9 @@ components: type: object properties: cache_size: - type: string + $ref: '#/components/schemas/_common:StorageSize' cache_size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' cores_per_socket: type: number mhz: @@ -51416,7 +51598,7 @@ components: file_count: type: number size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' required: - file_count - size_in_bytes @@ -51426,9 +51608,9 @@ components: shard_count: type: number size: - $ref: '#/components/schemas/_common:ByteSize' + $ref: '#/components/schemas/_common:StorageSize' size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' max_segments_per_shard: type: number required: @@ -51532,7 +51714,7 @@ components: file_count: type: number size_in_bytes: - type: number + $ref: '#/components/schemas/_common:Bytes' required: - file_count - size_in_bytes @@ -51901,32 +52083,43 @@ components: - nodes - none - parents - tasks._common:NodeTasks: + tasks._common:PersistentTaskStatus: type: object properties: - name: - $ref: '#/components/schemas/_common:NodeId' - transport_address: - $ref: '#/components/schemas/_common:TransportAddress' - host: - $ref: '#/components/schemas/_common:Host' - ip: - $ref: '#/components/schemas/_common:Ip' - roles: - type: array - items: - type: string - attributes: - type: object - additionalProperties: - type: string - tasks: - type: object - additionalProperties: - $ref: '#/components/schemas/tasks._common:TaskInfo' + state: + type: string required: - - tasks - tasks._common:ParentTaskInfo: + - state + tasks._common:RawTaskStatus: + type: object + additionalProperties: + title: metadata + tasks._common:ReplicationTaskStatus: + type: object + properties: + phase: + type: string + required: + - phase + tasks._common:Status: + description: Task status information can vary wildly from task to task. + anyOf: + - $ref: '#/components/schemas/tasks._common:ReplicationTaskStatus' + - $ref: '#/components/schemas/_common:BulkByScrollTaskStatus' + - $ref: '#/components/schemas/tasks._common:PersistentTaskStatus' + - $ref: '#/components/schemas/tasks._common:RawTaskStatus' + tasks._common:TaskExecutingNode: + allOf: + - $ref: '#/components/schemas/_common:BaseNode' + - type: object + properties: + tasks: + type: object + additionalProperties: + $ref: '#/components/schemas/tasks._common:TaskInfo' + required: + - tasks + tasks._common:TaskGroup: allOf: - $ref: '#/components/schemas/tasks._common:TaskInfo' - type: object @@ -51934,7 +52127,7 @@ components: children: type: array items: - $ref: '#/components/schemas/tasks._common:TaskInfo' + $ref: '#/components/schemas/tasks._common:TaskGroup' tasks._common:TaskInfo: type: object properties: @@ -51962,8 +52155,7 @@ components: start_time_in_millis: $ref: '#/components/schemas/_common:EpochTimeUnitMillis' status: - description: Task status information can vary wildly from task to task. - type: object + $ref: '#/components/schemas/tasks._common:Status' type: type: string parent_task_id: @@ -51979,12 +52171,14 @@ components: - type tasks._common:TaskInfos: oneOf: - - type: array + - title: grouped_by_none + type: array items: $ref: '#/components/schemas/tasks._common:TaskInfo' - - type: object + - title: grouped_by_parents + type: object additionalProperties: - $ref: '#/components/schemas/tasks._common:ParentTaskInfo' + $ref: '#/components/schemas/tasks._common:TaskGroup' tasks._common:TaskListResponseBase: type: object properties: @@ -52000,9 +52194,12 @@ components: description: Task information grouped by node, if `group_by` was set to `node` (the default). type: object additionalProperties: - $ref: '#/components/schemas/tasks._common:NodeTasks' + $ref: '#/components/schemas/tasks._common:TaskExecutingNode' tasks: $ref: '#/components/schemas/tasks._common:TaskInfos' + tasks._common:TaskResponse: + anyOf: + - $ref: '#/components/schemas/_common:BulkByScrollResponseBase' transforms._common:ContinuousStats: type: object properties: diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java index 86c3b198fd..5434ea1e16 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java @@ -43,7 +43,8 @@ public class CodeGenerator { private static final OperationGroupMatcher OPERATION_MATCHER = or( and(namespace(""), named("info")), namespace("dangling_indices"), - and(namespace("ml"), not(named("search_models"))) // TODO: search_models is complex and ideally should re-use the search structures + and(namespace("ml"), not(named("search_models"))), // TODO: search_models is complex and ideally should re-use the search structures + and(namespace("tasks"), named("list")) ); public static void main(String[] args) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java index 68c6a4feb5..711b5ae861 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java @@ -13,6 +13,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -22,6 +23,8 @@ import org.opensearch.client.codegen.utils.Strings; public class Namespace { + private static final Set PARTIAL_NAMESPACES = Set.of("", "tasks"); + private final Namespace parent; private final String name; private final Map children = new TreeMap<>(); @@ -82,7 +85,7 @@ public void render(ShapeRenderingContext ctx) throws RenderException { if (operations.isEmpty()) return; - var asBaseClass = "".equals(name); + var asBaseClass = PARTIAL_NAMESPACES.contains(name); new Client(this, false, asBaseClass, operations).render(ctx); new Client(this, true, asBaseClass, operations).render(ctx); From 1a49b72f8f99eab6cf370ebbd9da8b762baefb48 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 6 Sep 2024 17:24:50 +1200 Subject: [PATCH 04/11] Simplify client request methods Signed-off-by: Thomas Farr --- .../OpenSearchDanglingIndicesAsyncClient.java | 18 +---- .../OpenSearchDanglingIndicesClient.java | 18 +---- .../ml/OpenSearchMlAsyncClient.java | 74 +++---------------- .../opensearch/ml/OpenSearchMlClient.java | 74 +++---------------- .../tasks/OpenSearchTasksAsyncClientBase.java | 14 +--- .../tasks/OpenSearchTasksClientBase.java | 14 +--- .../client/codegen/templates/Client.mustache | 9 +-- 7 files changed, 31 insertions(+), 190 deletions(-) diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java index dc7158198f..baa2fe8c98 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesAsyncClient.java @@ -42,9 +42,7 @@ import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.util.ObjectBuilder; @@ -74,13 +72,7 @@ public OpenSearchDanglingIndicesAsyncClient withTransportOptions(@Nullable Trans */ public CompletableFuture deleteDanglingIndex(DeleteDanglingIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteDanglingIndexRequest, - DeleteDanglingIndexResponse, - ErrorResponse>) DeleteDanglingIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, DeleteDanglingIndexRequest._ENDPOINT, this.transportOptions); } /** @@ -101,13 +93,7 @@ public final CompletableFuture deleteDanglingIndex( */ public CompletableFuture importDanglingIndex(ImportDanglingIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ImportDanglingIndexRequest, - ImportDanglingIndexResponse, - ErrorResponse>) ImportDanglingIndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, ImportDanglingIndexRequest._ENDPOINT, this.transportOptions); } /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java index c4ebd9da0e..da55534bb5 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/OpenSearchDanglingIndicesClient.java @@ -41,9 +41,7 @@ import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.util.ObjectBuilder; @@ -72,13 +70,7 @@ public OpenSearchDanglingIndicesClient withTransportOptions(@Nullable TransportO * Deletes the specified dangling index. */ public DeleteDanglingIndexResponse deleteDanglingIndex(DeleteDanglingIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteDanglingIndexRequest, - DeleteDanglingIndexResponse, - ErrorResponse>) DeleteDanglingIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, DeleteDanglingIndexRequest._ENDPOINT, this.transportOptions); } /** @@ -98,13 +90,7 @@ public final DeleteDanglingIndexResponse deleteDanglingIndex( * Imports the specified dangling index. */ public ImportDanglingIndexResponse importDanglingIndex(ImportDanglingIndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ImportDanglingIndexRequest, - ImportDanglingIndexResponse, - ErrorResponse>) ImportDanglingIndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, ImportDanglingIndexRequest._ENDPOINT, this.transportOptions); } /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/OpenSearchMlAsyncClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/OpenSearchMlAsyncClient.java index 8f2ab231ba..e4199fca36 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/OpenSearchMlAsyncClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/OpenSearchMlAsyncClient.java @@ -18,9 +18,7 @@ import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.util.ObjectBuilder; @@ -49,13 +47,7 @@ public OpenSearchMlAsyncClient withTransportOptions(@Nullable TransportOptions t * Deletes a model. */ public CompletableFuture deleteModel(DeleteModelRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteModelRequest, - DeleteModelResponse, - ErrorResponse>) DeleteModelRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, DeleteModelRequest._ENDPOINT, this.transportOptions); } /** @@ -76,13 +68,7 @@ public final CompletableFuture deleteModel( */ public CompletableFuture deleteModelGroup(DeleteModelGroupRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteModelGroupRequest, - DeleteModelGroupResponse, - ErrorResponse>) DeleteModelGroupRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, DeleteModelGroupRequest._ENDPOINT, this.transportOptions); } /** @@ -102,13 +88,7 @@ public final CompletableFuture deleteModelGroup( * Deletes a task. */ public CompletableFuture deleteTask(DeleteTaskRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteTaskRequest, - DeleteTaskResponse, - ErrorResponse>) DeleteTaskRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, DeleteTaskRequest._ENDPOINT, this.transportOptions); } /** @@ -127,13 +107,7 @@ public final CompletableFuture deleteTask(Function deployModel(DeployModelRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeployModelRequest, - DeployModelResponse, - ErrorResponse>) DeployModelRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, DeployModelRequest._ENDPOINT, this.transportOptions); } /** @@ -153,13 +127,7 @@ public final CompletableFuture deployModel( * Retrieves a model group. */ public CompletableFuture getModelGroup(GetModelGroupRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetModelGroupRequest, - GetModelGroupResponse, - ErrorResponse>) GetModelGroupRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, GetModelGroupRequest._ENDPOINT, this.transportOptions); } /** @@ -179,13 +147,7 @@ public final CompletableFuture getModelGroup( * Retrieves a task. */ public CompletableFuture getTask(GetTaskRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetTaskRequest, - GetTaskResponse, - ErrorResponse>) GetTaskRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, GetTaskRequest._ENDPOINT, this.transportOptions); } /** @@ -204,13 +166,7 @@ public final CompletableFuture getTask(Function registerModel(RegisterModelRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - RegisterModelRequest, - RegisterModelResponse, - ErrorResponse>) RegisterModelRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, RegisterModelRequest._ENDPOINT, this.transportOptions); } /** @@ -231,13 +187,7 @@ public final CompletableFuture registerModel( */ public CompletableFuture registerModelGroup(RegisterModelGroupRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - RegisterModelGroupRequest, - RegisterModelGroupResponse, - ErrorResponse>) RegisterModelGroupRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, RegisterModelGroupRequest._ENDPOINT, this.transportOptions); } /** @@ -257,13 +207,7 @@ public final CompletableFuture registerModelGroup( * Undeploys a model. */ public CompletableFuture undeployModel(UndeployModelRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - UndeployModelRequest, - UndeployModelResponse, - ErrorResponse>) UndeployModelRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, UndeployModelRequest._ENDPOINT, this.transportOptions); } /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/OpenSearchMlClient.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/OpenSearchMlClient.java index d3aba915be..7e6fa317c2 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/OpenSearchMlClient.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/OpenSearchMlClient.java @@ -17,9 +17,7 @@ import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.util.ObjectBuilder; @@ -48,13 +46,7 @@ public OpenSearchMlClient withTransportOptions(@Nullable TransportOptions transp * Deletes a model. */ public DeleteModelResponse deleteModel(DeleteModelRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteModelRequest, - DeleteModelResponse, - ErrorResponse>) DeleteModelRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, DeleteModelRequest._ENDPOINT, this.transportOptions); } /** @@ -73,13 +65,7 @@ public final DeleteModelResponse deleteModel(Function endpoint = (JsonEndpoint< - DeleteModelGroupRequest, - DeleteModelGroupResponse, - ErrorResponse>) DeleteModelGroupRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, DeleteModelGroupRequest._ENDPOINT, this.transportOptions); } /** @@ -99,13 +85,7 @@ public final DeleteModelGroupResponse deleteModelGroup( * Deletes a task. */ public DeleteTaskResponse deleteTask(DeleteTaskRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteTaskRequest, - DeleteTaskResponse, - ErrorResponse>) DeleteTaskRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, DeleteTaskRequest._ENDPOINT, this.transportOptions); } /** @@ -124,13 +104,7 @@ public final DeleteTaskResponse deleteTask(Function endpoint = (JsonEndpoint< - DeployModelRequest, - DeployModelResponse, - ErrorResponse>) DeployModelRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, DeployModelRequest._ENDPOINT, this.transportOptions); } /** @@ -149,13 +123,7 @@ public final DeployModelResponse deployModel(Function endpoint = (JsonEndpoint< - GetModelGroupRequest, - GetModelGroupResponse, - ErrorResponse>) GetModelGroupRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, GetModelGroupRequest._ENDPOINT, this.transportOptions); } /** @@ -174,13 +142,7 @@ public final GetModelGroupResponse getModelGroup(Function endpoint = (JsonEndpoint< - GetTaskRequest, - GetTaskResponse, - ErrorResponse>) GetTaskRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, GetTaskRequest._ENDPOINT, this.transportOptions); } /** @@ -199,13 +161,7 @@ public final GetTaskResponse getTask(Function endpoint = (JsonEndpoint< - RegisterModelRequest, - RegisterModelResponse, - ErrorResponse>) RegisterModelRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, RegisterModelRequest._ENDPOINT, this.transportOptions); } /** @@ -224,13 +180,7 @@ public final RegisterModelResponse registerModel(Function endpoint = (JsonEndpoint< - RegisterModelGroupRequest, - RegisterModelGroupResponse, - ErrorResponse>) RegisterModelGroupRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, RegisterModelGroupRequest._ENDPOINT, this.transportOptions); } /** @@ -250,13 +200,7 @@ public final RegisterModelGroupResponse registerModelGroup( * Undeploys a model. */ public UndeployModelResponse undeployModel(UndeployModelRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - UndeployModelRequest, - UndeployModelResponse, - ErrorResponse>) UndeployModelRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, UndeployModelRequest._ENDPOINT, this.transportOptions); } /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java index 143b4335e1..7fab24ba00 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java @@ -42,9 +42,7 @@ import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.util.ObjectBuilder; @@ -66,13 +64,7 @@ public OpenSearchTasksAsyncClientBase(OpenSearchTransport transport, @Nullable T * Returns a list of tasks. */ public CompletableFuture list(ListRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ListRequest, - ListResponse, - ErrorResponse>) ListRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + return this.transport.performRequestAsync(request, ListRequest._ENDPOINT, this.transportOptions); } /** @@ -88,7 +80,7 @@ public final CompletableFuture list(Function list() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new ListRequest.Builder().build(), ListRequest._ENDPOINT, this.transportOptions); + public final CompletableFuture list() throws IOException, OpenSearchException { + return list(new ListRequest.Builder().build()); } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java index 06bafd578c..5881ebe95f 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java @@ -41,9 +41,7 @@ import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.util.ObjectBuilder; @@ -63,13 +61,7 @@ public OpenSearchTasksClientBase(OpenSearchTransport transport, @Nullable Transp * Returns a list of tasks. */ public ListResponse list(ListRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ListRequest, - ListResponse, - ErrorResponse>) ListRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); + return this.transport.performRequest(request, ListRequest._ENDPOINT, this.transportOptions); } /** @@ -84,7 +76,7 @@ public final ListResponse list(Function{{/async}} {{#camelCase}}{{id}}{{/camelCase}}({{type}} request) throws {{TYPES.Java.Io.IOException}}, {{TYPES.Client.OpenSearch._Types.OpenSearchException}} { - @SuppressWarnings("unchecked") - {{jsonEndpointType}} endpoint = ({{jsonEndpointType}}) {{type.name}}._ENDPOINT; - - return this.transport.performRequest{{#async}}Async{{/async}}(request, endpoint, this.transportOptions); + return this.transport.performRequest{{#async}}Async{{/async}}(request, {{type.name}}._ENDPOINT, this.transportOptions); } /** @@ -62,9 +59,9 @@ /** * {{description}} */ - public {{#async}}{{TYPES.Java.Util.Concurrent.CompletableFuture}}<{{/async}}{{responseType}}{{#async}}>{{/async}} {{#camelCase}}{{id}}{{/camelCase}}() + public final {{#async}}{{TYPES.Java.Util.Concurrent.CompletableFuture}}<{{/async}}{{responseType}}{{#async}}>{{/async}} {{#camelCase}}{{id}}{{/camelCase}}() throws IOException, OpenSearchException { - return this.transport.performRequest{{#async}}Async{{/async}}(new {{type.builderType}}().build(), {{type.name}}._ENDPOINT, this.transportOptions); + return {{#camelCase}}{{id}}{{/camelCase}}(new {{type.builderType}}().build()); } {{/hasAnyRequiredFields}} {{/canBeSingleton}} From e03951b59f1d9f73e115c9cd8f8fd9ef3b027045 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 9 Sep 2024 15:07:30 +1200 Subject: [PATCH 05/11] Re-generate _types.Retries Signed-off-by: Thomas Farr --- .../client/opensearch/_types/Retries.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/_types/Retries.java (91%) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Retries.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Retries.java similarity index 91% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/Retries.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/Retries.java index 0b4984e238..34b168959b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Retries.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Retries.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types; import jakarta.json.stream.JsonGenerator; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -47,7 +52,9 @@ // typedef: _types.Retries @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class Retries implements PlainJsonSerializable { + private final long bulk; private final long search; @@ -55,13 +62,11 @@ public class Retries implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private Retries(Builder builder) { - this.bulk = ApiTypeHelper.requireNonNull(builder.bulk, this, "bulk"); this.search = ApiTypeHelper.requireNonNull(builder.search, this, "search"); - } - public static Retries of(Function> fn) { + public static Retries of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -82,6 +87,7 @@ public final long search() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -89,13 +95,11 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("bulk"); generator.write(this.bulk); generator.writeKey("search"); generator.write(this.search); - } // --------------------------------------------------------------------------------------------- @@ -103,10 +107,8 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link Retries}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Long bulk; - private Long search; /** @@ -128,8 +130,7 @@ public final Builder search(long value) { /** * Builds a {@link Retries}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public Retries build() { _checkSingleUse(); @@ -137,7 +138,6 @@ public Retries build() { return new Retries(this); } } - // --------------------------------------------------------------------------------------------- /** @@ -149,10 +149,7 @@ public Retries build() { ); protected static void setupRetriesDeserializer(ObjectDeserializer op) { - op.add(Builder::bulk, JsonpDeserializer.longDeserializer(), "bulk"); op.add(Builder::search, JsonpDeserializer.longDeserializer(), "search"); - } - } From cb45d9e32d85fcaae3ac47da19db85a61605a5b6 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 9 Sep 2024 15:09:28 +1200 Subject: [PATCH 06/11] Handle types that are used in both abstract and concrete contexts Signed-off-by: Thomas Farr --- .../_types/AcknowledgedResponseBase.java | 1 + .../client/opensearch/_types/BaseNode.java | 1 + .../client/opensearch/_types/ErrorCause.java | 1 + .../opensearch/_types/NodeStatistics.java | 1 + .../_types/OpenSearchVersionInfo.java | 1 + .../client/opensearch/_types/Retries.java | 1 + .../opensearch/_types/ShardFailure.java | 1 + .../opensearch/_types/ShardStatistics.java | 1 + .../opensearch/_types/WriteResponseBase.java | 1 + .../client/opensearch/core/InfoResponse.java | 1 + .../DeleteDanglingIndexResponse.java | 1 + .../ImportDanglingIndexResponse.java | 1 + .../ListDanglingIndicesResponse.java | 1 + .../list_dangling_indices/DanglingIndex.java | 1 + .../ml/DeleteModelGroupResponse.java | 1 + .../opensearch/ml/DeleteModelResponse.java | 1 + .../opensearch/ml/DeleteTaskResponse.java | 1 + .../opensearch/ml/DeployModelResponse.java | 1 + .../opensearch/ml/GetModelGroupResponse.java | 1 + .../client/opensearch/ml/GetTaskResponse.java | 1 + .../ml/RegisterModelGroupRequest.java | 1 + .../ml/RegisterModelGroupResponse.java | 1 + .../opensearch/ml/RegisterModelRequest.java | 1 + .../opensearch/ml/RegisterModelResponse.java | 1 + .../opensearch/ml/UndeployModelNode.java | 1 + .../opensearch/ml/UndeployModelResponse.java | 1 + .../opensearch/tasks/TaskExecutingNode.java | 1 + .../client/opensearch/tasks/TaskInfo.java | 124 ++++++++-------- .../client/codegen/model/Namespace.java | 7 +- .../client/codegen/model/ObjectShape.java | 21 ++- .../client/codegen/model/ReferenceKind.java | 25 ++++ .../client/codegen/model/RequestShape.java | 6 +- .../client/codegen/model/Shape.java | 43 +++++- .../client/codegen/model/SpecTransformer.java | 45 +++--- .../codegen/model/TaggedUnionShape.java | 1 + .../opensearch/client/codegen/model/Type.java | 24 ++-- .../client/codegen/model/Types.java | 20 ++- .../templates/ObjectShape/Builder.mustache | 133 +++++------------- .../ObjectShape/Builder/BuildImpl.mustache | 10 ++ .../ObjectShape/Builder/Fields.mustache | 69 +++++++++ .../ObjectShape/Builder/SelfImpl.mustache | 4 + .../ObjectShape/Constructor.mustache | 10 +- .../ObjectShape/Deserialize.mustache | 10 +- .../templates/TaggedUnionShape.mustache | 10 +- 44 files changed, 360 insertions(+), 229 deletions(-) create mode 100644 java-codegen/src/main/java/org/opensearch/client/codegen/model/ReferenceKind.java create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/BuildImpl.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/Fields.mustache create mode 100644 java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java index ee2f0572f9..d955102ca7 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java @@ -101,6 +101,7 @@ public final BuilderT acknowledged(boolean value) { protected abstract BuilderT self(); } + // --------------------------------------------------------------------------------------------- protected static > void setupAcknowledgedResponseBaseDeserializer( diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BaseNode.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BaseNode.java index 30550ebcf4..8726abe2e5 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BaseNode.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BaseNode.java @@ -270,6 +270,7 @@ public final BuilderT transportAddress(@Nullable String value) { protected abstract BuilderT self(); } + // --------------------------------------------------------------------------------------------- protected static > void setupBaseNodeDeserializer(ObjectDeserializer op) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java index 5184be7b16..c029456c39 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java @@ -379,6 +379,7 @@ public ErrorCause build() { return new ErrorCause(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeStatistics.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeStatistics.java index 098d4aa483..8f785bbccd 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeStatistics.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/NodeStatistics.java @@ -238,6 +238,7 @@ public NodeStatistics build() { return new NodeStatistics(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java index 1a168dc946..bcba2bafb9 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java @@ -328,6 +328,7 @@ public OpenSearchVersionInfo build() { return new OpenSearchVersionInfo(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Retries.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Retries.java index 34b168959b..034115ce2b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Retries.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/Retries.java @@ -138,6 +138,7 @@ public Retries build() { return new Retries(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java index 76397fa257..2d45c839e0 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardFailure.java @@ -227,6 +227,7 @@ public ShardFailure build() { return new ShardFailure(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardStatistics.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardStatistics.java index 04e9e5f14a..4c479c16e1 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardStatistics.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ShardStatistics.java @@ -245,6 +245,7 @@ public ShardStatistics build() { return new ShardStatistics(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WriteResponseBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WriteResponseBase.java index 83a031739d..10fc56bb6b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WriteResponseBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/WriteResponseBase.java @@ -264,6 +264,7 @@ public final BuilderT version(long value) { protected abstract BuilderT self(); } + // --------------------------------------------------------------------------------------------- protected static > void setupWriteResponseBaseDeserializer(ObjectDeserializer op) { diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/core/InfoResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/core/InfoResponse.java index f3c81d7cc6..8f48dfd984 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/core/InfoResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/core/InfoResponse.java @@ -212,6 +212,7 @@ public InfoResponse build() { return new InfoResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java index 72f04f6cb1..16feb43b56 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/DeleteDanglingIndexResponse.java @@ -87,6 +87,7 @@ public DeleteDanglingIndexResponse build() { return new DeleteDanglingIndexResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java index 90b180798e..eaef581983 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ImportDanglingIndexResponse.java @@ -87,6 +87,7 @@ public ImportDanglingIndexResponse build() { return new ImportDanglingIndexResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java index 989611ecb7..54acd845ff 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/ListDanglingIndicesResponse.java @@ -214,6 +214,7 @@ public ListDanglingIndicesResponse build() { return new ListDanglingIndicesResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java index 914101a624..c18d275f82 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/dangling_indices/list_dangling_indices/DanglingIndex.java @@ -231,6 +231,7 @@ public DanglingIndex build() { return new DanglingIndex(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java index d46916f638..742257bf99 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java @@ -59,6 +59,7 @@ public DeleteModelGroupResponse build() { return new DeleteModelGroupResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java index dcf77c93aa..1395e93e08 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java @@ -59,6 +59,7 @@ public DeleteModelResponse build() { return new DeleteModelResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java index f6d5e8c95d..93e33ffd2c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java @@ -59,6 +59,7 @@ public DeleteTaskResponse build() { return new DeleteTaskResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java index 6ba333cde4..23b01f8025 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java @@ -142,6 +142,7 @@ public DeployModelResponse build() { return new DeployModelResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetModelGroupResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetModelGroupResponse.java index 4a8321c607..9ca56a1e29 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetModelGroupResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetModelGroupResponse.java @@ -237,6 +237,7 @@ public GetModelGroupResponse build() { return new GetModelGroupResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetTaskResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetTaskResponse.java index 610b2c1cb4..6e0f7522e2 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetTaskResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/GetTaskResponse.java @@ -365,6 +365,7 @@ public GetTaskResponse build() { return new GetTaskResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java index ca633f61e5..2cf102fca7 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java @@ -259,6 +259,7 @@ public RegisterModelGroupRequest build() { return new RegisterModelGroupRequest(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java index 6a04cf66ad..240993a8c8 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java @@ -128,6 +128,7 @@ public RegisterModelGroupResponse build() { return new RegisterModelGroupResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java index c94be40813..98fb7909fd 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java @@ -227,6 +227,7 @@ public RegisterModelRequest build() { return new RegisterModelRequest(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelResponse.java index 3b42ed8903..af781c3769 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelResponse.java @@ -114,6 +114,7 @@ public RegisterModelResponse build() { return new RegisterModelResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelNode.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelNode.java index 6ba10b82ca..18b66b4dc3 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelNode.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelNode.java @@ -119,6 +119,7 @@ public UndeployModelNode build() { return new UndeployModelNode(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelResponse.java index f7cdfea593..83128a460a 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/UndeployModelResponse.java @@ -121,6 +121,7 @@ public UndeployModelResponse build() { return new UndeployModelResponse(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java index c12a673473..3f4c19e178 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskExecutingNode.java @@ -145,6 +145,7 @@ public TaskExecutingNode build() { return new TaskExecutingNode(this); } } + // --------------------------------------------------------------------------------------------- /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfo.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfo.java index 0523dc653f..dca26f3627 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfo.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfo.java @@ -91,7 +91,7 @@ public class TaskInfo implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- - private TaskInfo(Builder builder) { + protected TaskInfo(AbstractBuilder builder) { this.action = ApiTypeHelper.requireNonNull(builder.action, this, "action"); this.cancellable = ApiTypeHelper.requireNonNull(builder.cancellable, this, "cancellable"); this.cancelled = builder.cancelled; @@ -107,7 +107,7 @@ private TaskInfo(Builder builder) { this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); } - public static TaskInfo of(Function> fn) { + public static TaskInfo taskInfoOf(Function> fn) { return fn.apply(new Builder()).build(); } @@ -278,7 +278,25 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link TaskInfo}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends TaskInfo.AbstractBuilder implements ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link TaskInfo}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public TaskInfo build() { + _checkSingleUse(); + + return new TaskInfo(this); + } + } + + protected abstract static class AbstractBuilder> extends ObjectBuilderBase { private String action; private Boolean cancellable; @Nullable @@ -301,33 +319,33 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuildermap to headers. *

*/ - public final Builder headers(Map map) { + public final BuilderT headers(Map map) { this.headers = _mapPutAll(this.headers, map); - return this; + return self(); } /** @@ -349,100 +367,92 @@ public final Builder headers(Map map) { * Adds an entry to headers. *

*/ - public final Builder headers(String key, String value) { + public final BuilderT headers(String key, String value) { this.headers = _mapPut(this.headers, key, value); - return this; + return self(); } /** * Required - API name: {@code id} */ - public final Builder id(long value) { + public final BuilderT id(long value) { this.id = value; - return this; + return self(); } /** * Required - API name: {@code node} */ - public final Builder node(String value) { + public final BuilderT node(String value) { this.node = value; - return this; + return self(); } /** * API name: {@code parent_task_id} */ - public final Builder parentTaskId(@Nullable String value) { + public final BuilderT parentTaskId(@Nullable String value) { this.parentTaskId = value; - return this; + return self(); } /** * API name: {@code running_time} */ - public final Builder runningTime(@Nullable Time value) { + public final BuilderT runningTime(@Nullable Time value) { this.runningTime = value; - return this; + return self(); } /** * API name: {@code running_time} */ - public final Builder runningTime(Function> fn) { + public final BuilderT runningTime(Function> fn) { return runningTime(fn.apply(new Time.Builder()).build()); } /** * Required - API name: {@code running_time_in_nanos} */ - public final Builder runningTimeInNanos(long value) { + public final BuilderT runningTimeInNanos(long value) { this.runningTimeInNanos = value; - return this; + return self(); } /** * Required - API name: {@code start_time_in_millis} */ - public final Builder startTimeInMillis(long value) { + public final BuilderT startTimeInMillis(long value) { this.startTimeInMillis = value; - return this; + return self(); } /** * API name: {@code status} */ - public final Builder status(@Nullable Status value) { + public final BuilderT status(@Nullable Status value) { this.status = value; - return this; + return self(); } /** * API name: {@code status} */ - public final Builder status(Function> fn) { + public final BuilderT status(Function> fn) { return status(fn.apply(new Status.Builder()).build()); } /** * Required - API name: {@code type} */ - public final Builder type(String value) { + public final BuilderT type(String value) { this.type = value; - return this; + return self(); } - /** - * Builds a {@link TaskInfo}. - * - * @throws NullPointerException if some of the required fields are null. - */ - public TaskInfo build() { - _checkSingleUse(); - - return new TaskInfo(this); - } + protected abstract BuilderT self(); } + // --------------------------------------------------------------------------------------------- /** @@ -453,19 +463,19 @@ public TaskInfo build() { TaskInfo::setupTaskInfoDeserializer ); - protected static void setupTaskInfoDeserializer(ObjectDeserializer op) { - op.add(Builder::action, JsonpDeserializer.stringDeserializer(), "action"); - op.add(Builder::cancellable, JsonpDeserializer.booleanDeserializer(), "cancellable"); - op.add(Builder::cancelled, JsonpDeserializer.booleanDeserializer(), "cancelled"); - op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description"); - op.add(Builder::headers, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "headers"); - op.add(Builder::id, JsonpDeserializer.longDeserializer(), "id"); - op.add(Builder::node, JsonpDeserializer.stringDeserializer(), "node"); - op.add(Builder::parentTaskId, JsonpDeserializer.stringDeserializer(), "parent_task_id"); - op.add(Builder::runningTime, Time._DESERIALIZER, "running_time"); - op.add(Builder::runningTimeInNanos, JsonpDeserializer.longDeserializer(), "running_time_in_nanos"); - op.add(Builder::startTimeInMillis, JsonpDeserializer.longDeserializer(), "start_time_in_millis"); - op.add(Builder::status, Status._DESERIALIZER, "status"); - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + protected static > void setupTaskInfoDeserializer(ObjectDeserializer op) { + op.add(AbstractBuilder::action, JsonpDeserializer.stringDeserializer(), "action"); + op.add(AbstractBuilder::cancellable, JsonpDeserializer.booleanDeserializer(), "cancellable"); + op.add(AbstractBuilder::cancelled, JsonpDeserializer.booleanDeserializer(), "cancelled"); + op.add(AbstractBuilder::description, JsonpDeserializer.stringDeserializer(), "description"); + op.add(AbstractBuilder::headers, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "headers"); + op.add(AbstractBuilder::id, JsonpDeserializer.longDeserializer(), "id"); + op.add(AbstractBuilder::node, JsonpDeserializer.stringDeserializer(), "node"); + op.add(AbstractBuilder::parentTaskId, JsonpDeserializer.stringDeserializer(), "parent_task_id"); + op.add(AbstractBuilder::runningTime, Time._DESERIALIZER, "running_time"); + op.add(AbstractBuilder::runningTimeInNanos, JsonpDeserializer.longDeserializer(), "running_time_in_nanos"); + op.add(AbstractBuilder::startTimeInMillis, JsonpDeserializer.longDeserializer(), "start_time_in_millis"); + op.add(AbstractBuilder::status, Status._DESERIALIZER, "status"); + op.add(AbstractBuilder::type, JsonpDeserializer.stringDeserializer(), "type"); } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java index 711b5ae861..e29fc558cf 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java @@ -119,12 +119,17 @@ private Client(Namespace parent, boolean async, boolean base, Collection bodyFields = new TreeMap<>(); protected Field additionalPropertiesField; @@ -25,6 +24,7 @@ public ObjectShape(Namespace parent, String className, String typedefName, Strin public void addBodyField(Field field) { bodyFields.put(field.getName(), field); + tryAddReference(ReferenceKind.Field, field.getType()); } public Collection getBodyFields() { @@ -42,24 +42,15 @@ public Collection getFields() { public void setAdditionalPropertiesField(Field field) { additionalPropertiesField = field; + if (field != null) { + tryAddReference(ReferenceKind.Field, field.getType()); + } } public Field getAdditionalPropertiesField() { return additionalPropertiesField; } - public void setExtendsType(Type extendsType) { - this.extendsType = extendsType; - } - - public Type getExtendsType() { - return extendsType; - } - - public boolean extendsOtherShape() { - return extendsType != null; - } - public boolean hasFieldsToSerialize() { return !bodyFields.isEmpty() || additionalPropertiesField != null; } @@ -71,4 +62,8 @@ public Collection getImplementsTypes() { public Collection getAnnotations() { return (hasFieldsToSerialize() || extendsOtherShape()) && !isAbstract() ? List.of(Types.Client.Json.JsonpDeserializable) : null; } + + public static class BuilderModel { + + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ReferenceKind.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ReferenceKind.java new file mode 100644 index 0000000000..19a92dd6fb --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ReferenceKind.java @@ -0,0 +1,25 @@ +/* + * 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. + */ + +package org.opensearch.client.codegen.model; + +public enum ReferenceKind { + Extends(false), + Field(true), + UnionVariant(true); + + private final boolean isConcreteUsage; + + ReferenceKind(boolean isConcreteUsage) { + this.isConcreteUsage = isConcreteUsage; + } + + public boolean isConcreteUsage() { + return isConcreteUsage; + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index 2de1320733..18facfd53e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -50,11 +50,6 @@ public String getId() { return operationGroup.getName(); } - @Override - public boolean extendsOtherShape() { - return extendsType != Types.Client.OpenSearch._Types.RequestBase; - } - public String getHttpMethod() { return Streams.sortedBy(httpMethods.stream(), m -> { switch (m) { @@ -144,6 +139,7 @@ public void addBodyField(Field field) { private void addField(Field field) { fields.put(field.getName(), field); + tryAddReference(ReferenceKind.Field, field.getType()); } @Override diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java index 8f6eaa5c04..52f9d4c3be 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java @@ -8,11 +8,17 @@ package org.opensearch.client.codegen.model; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.Set; import java.util.TreeSet; +import java.util.stream.Collectors; +import javax.annotation.Nonnull; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.client.codegen.exceptions.RenderException; @@ -20,11 +26,14 @@ public abstract class Shape { private static final Logger LOGGER = LogManager.getLogger(); + private final Set referencedTypes = new HashSet<>(); + private final Map> incomingReferences = new HashMap<>(); + private final Map> outgoingReferences = new HashMap<>(); protected final Namespace parent; private final String className; - private final Set referencedTypes = new HashSet<>(); private final String typedefName; private final String description; + private Type extendsType; public Shape(Namespace parent, String className, String typedefName, String description) { this.parent = parent; @@ -46,7 +55,8 @@ public JavaClassKind getClassKind() { } public boolean isAbstract() { - return this.className.endsWith("Base") || this.className.startsWith("Base"); + var refKinds = incomingReferences.entrySet().stream().filter(e -> !e.getValue().isEmpty()).map(Map.Entry::getKey).collect(Collectors.toSet()); + return !refKinds.isEmpty() && refKinds.stream().noneMatch(ReferenceKind::isConcreteUsage); } public String getTypedefName() { @@ -66,15 +76,38 @@ public TypeParameterDiamond getTypeParameters() { } public Type getExtendsType() { - return null; + return extendsType; + } + + public void setExtendsType(Type extendsType) { + this.extendsType = extendsType; + tryAddReference(ReferenceKind.Extends, extendsType); + } + + public boolean extendsOtherShape() { + return extendsType != null && extendsType.getTargetShape().isPresent(); + } + + public boolean extendedByOtherShape() { + return !incomingReferences.getOrDefault(ReferenceKind.Extends, Collections.emptyList()).isEmpty(); } public Collection getImplementsTypes() { return Collections.emptyList(); } - public Type getType() { - return Type.builder().withPackage(getPackageName()).withName(className).build(); + protected void tryAddReference(ReferenceKind kind, Type to) { + if (to == null) return; + to.getTargetShape().ifPresent(s -> addReference(kind, s)); + } + + private void addReference(ReferenceKind kind, Shape to) { + outgoingReferences.computeIfAbsent(kind, k -> new ArrayList<>()).add(to); + to.incomingReferences.computeIfAbsent(kind, k -> new ArrayList<>()).add(this); + } + + public @Nonnull Type getType() { + return Type.builder().withPackage(getPackageName()).withName(className).withTargetShape(this).build(); } public Namespace getParent() { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java index fc994cc1d0..2a3b8ee993 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java @@ -54,7 +54,7 @@ public class SpecTransformer { @Nonnull private final Namespace root = new Namespace(); @Nonnull - private final Set visitedSchemas = new HashSet<>(); + private final Map visitedSchemas = new ConcurrentHashMap<>(); @Nonnull private final Map schemaToType = new ConcurrentHashMap<>(); @@ -232,29 +232,26 @@ private Field visit(OpenApiParameter parameter) { ); } - private void visit(OpenApiSchema schema) { + private Shape visit(OpenApiSchema schema) { var namespace = schema.getNamespace().orElseThrow(); var name = schema.getName().orElseThrow(); - visit(root.child(namespace), name, namespace + "." + name, schema); + return visit(root.child(namespace), name, namespace + "." + name, schema); } - private void visit(Namespace parent, String className, String typedefName, OpenApiSchema schema) { - if (!visitedSchemas.add(schema)) { - return; + private Shape visit(Namespace parent, String className, String typedefName, OpenApiSchema schema) { + Shape shape = visitedSchemas.get(schema); + + if (shape != null) { + return shape; } LOGGER.info("Visiting Schema: {}", schema); - Shape shape; - var description = schema.getDescription().orElse(null); if (schema.isArray()) { shape = new ArrayShape(parent, className, mapType(schema), typedefName, description); - } else if (schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object) { - var objShape = new ObjectShape(parent, className, typedefName, description); - visitInto(schema, objShape); - shape = objShape; + visitedSchemas.putIfAbsent(schema, shape); } else if (schema.isString() && schema.hasEnums()) { var deprecatedEnums = schema.getDeprecatedEnums().orElseGet(Collections::emptySet); shape = new EnumShape( @@ -264,25 +261,37 @@ private void visit(Namespace parent, String className, String typedefName, OpenA typedefName, description ); + visitedSchemas.putIfAbsent(schema, shape); } else if (schema.hasOneOf()) { var taggedUnion = new TaggedUnionShape(parent, className, typedefName, description); + shape = taggedUnion; + visitedSchemas.putIfAbsent(schema, shape); + schema.getOneOf().orElseThrow().forEach(s -> { var title = s.getTitle() .orElseThrow(() -> new IllegalStateException("oneOf variant [" + s.getPointer() + "] is missing a `title` tag")); taggedUnion.addVariant(title, mapType(s)); }); - shape = taggedUnion; + } else if (schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object) { + var objShape = new ObjectShape(parent, className, typedefName, description); + shape = objShape; + visitedSchemas.putIfAbsent(schema, shape); + + visitInto(schema, objShape); } else { throw new NotImplementedException("Unsupported schema: " + schema); } parent.addShape(shape); + + return shape; } private void visitInto(OpenApiSchema schema, ObjectShape shape) { var allOf = schema.getAllOf(); if (allOf.isPresent()) { - shape.setExtendsType(mapType(allOf.get().get(0))); + var baseSchema = allOf.get().get(0); + shape.setExtendsType(mapType(baseSchema)); schema = allOf.get().get(1); } @@ -392,13 +401,9 @@ private Type mapTypeInner(OpenApiSchema schema) { return mapType(schema); } - visit(schema); + var shape = visit(schema); - return Type.builder() - .withPackage(Types.Client.OpenSearch.PACKAGE + "." + schema.getNamespace().orElseThrow()) - .withName(schema.getName().orElseThrow()) - .isEnum(schema.hasEnums()) - .build(); + return shape.getType(); } var oneOf = schema.getOneOf(); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java index 36dc7e2f2a..cc3d28ff7c 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java @@ -22,6 +22,7 @@ public TaggedUnionShape(Namespace parent, String className, String typedefName, public void addVariant(String name, Type type) { variants.add(new Variant(name, type.getBoxed())); + tryAddReference(ReferenceKind.UnionVariant, type); } public Collection getVariants() { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java index b8e3585151..2e4391b787 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java @@ -12,6 +12,7 @@ import static org.opensearch.client.codegen.model.Types.Java; import com.samskivert.mustache.Mustache; +import java.util.Optional; import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -43,6 +44,7 @@ public class Type { "Number" ); + @Nonnull public static Builder builder() { return new Builder(); } @@ -53,17 +55,18 @@ public static Builder builder() { private final String name; @Nullable private final Type[] typeParams; - private final boolean isEnum; + private final Shape targetShape; private Type(Builder builder) { this.packageName = builder.packageName; this.name = Strings.requireNonBlank(builder.name, "name must not be blank"); this.typeParams = builder.typeParams; - this.isEnum = builder.isEnum; + this.targetShape = builder.targetShape; } + @Nonnull public Builder toBuilder() { - return new Builder().withPackage(packageName).withName(name).withTypeParameters(typeParams).isEnum(isEnum); + return new Builder().withPackage(packageName).withName(name).withTypeParameters(typeParams).withTargetShape(targetShape); } @Override @@ -105,6 +108,11 @@ public Type getBoxed() { } } + @Nonnull + public Optional getTargetShape() { + return Optional.ofNullable(targetShape); + } + public boolean isMap() { return "Map".equals(name); } @@ -154,7 +162,7 @@ public boolean isNumber() { } public boolean isEnum() { - return isEnum; + return targetShape != null && targetShape instanceof EnumShape; } public boolean isTime() { @@ -205,7 +213,7 @@ public void getRequiredImports(Set imports, String currentPkg) { } } - public Type withTypeParams(Type... typeParams) { + public Type withTypeParameters(Type... typeParams) { return toBuilder().withTypeParameters(typeParams).build(); } @@ -221,7 +229,7 @@ public static final class Builder extends ObjectBuilderBase { private String packageName; private String name; private Type[] typeParams; - private boolean isEnum; + private Shape targetShape; private Builder() {} @@ -250,8 +258,8 @@ public Builder withTypeParameters(@Nullable Type... typeParams) { } @Nonnull - public Builder isEnum(boolean isEnum) { - this.isEnum = isEnum; + public Builder withTargetShape(Shape shape) { + this.targetShape = shape; return this; } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java index be82acb55f..8d522a11f1 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java @@ -75,7 +75,10 @@ public static final class Util { public static final Type HashMap = Type.builder().withPackage(PACKAGE).withName("HashMap").build(); public static Type Map(Type keyType, Type valueType) { - return Map.withTypeParams(keyType, valueType); + return Map.toBuilder() + .withTypeParameters(keyType, valueType) + .withTargetShape(valueType.getTargetShape().orElse(null)) + .build(); } public static final Type Map = Type.builder().withPackage(PACKAGE).withName("Map").build(); @@ -85,7 +88,12 @@ public static Type MapEntry(Type keyType, Type valueType) { } public static Type List(Type valueType) { - return Type.builder().withPackage(PACKAGE).withName("List").withTypeParameters(valueType).build(); + return Type.builder() + .withPackage(PACKAGE) + .withName("List") + .withTypeParameters(valueType) + .withTargetShape(valueType.getTargetShape().orElse(null)) + .build(); } public static final class Concurrent { @@ -122,7 +130,7 @@ public static final class Client { public static final String PACKAGE = "org.opensearch.client"; public static Type ApiClient(Type transport, Type client) { - return ApiClient.withTypeParams(transport, client); + return ApiClient.withTypeParameters(transport, client); } public static final Type ApiClient = Type.builder().withPackage(PACKAGE).withName("ApiClient").build(); @@ -161,7 +169,7 @@ public static final class Transport { public static final Type Endpoint = Type.builder().withPackage(PACKAGE).withName("Endpoint").build(); public static Type JsonEndpoint(Type requestType, Type responseType, Type errorType) { - return JsonEndpoint.withTypeParams(requestType, responseType, errorType); + return JsonEndpoint.withTypeParameters(requestType, responseType, errorType); } public static final Type JsonEndpoint = Type.builder().withPackage(PACKAGE).withName("JsonEndpoint").build(); @@ -179,14 +187,14 @@ public static final class Util { public static final Type ApiTypeHelper = Type.builder().withPackage(PACKAGE).withName("ApiTypeHelper").build(); public static Type ObjectBuilder(Type type) { - return ObjectBuilder.withTypeParams(type); + return ObjectBuilder.withTypeParameters(type); } public static final Type ObjectBuilder = Type.builder().withPackage(PACKAGE).withName("ObjectBuilder").build(); public static final Type ObjectBuilderBase = Type.builder().withPackage(PACKAGE).withName("ObjectBuilderBase").build(); public static Type TaggedUnion(Type tagType, Type baseType) { - return TaggedUnion.withTypeParams(tagType, baseType); + return TaggedUnion.withTypeParameters(tagType, baseType); } public static final Type TaggedUnion = Type.builder().withPackage(PACKAGE).withName("TaggedUnion").build(); diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache index 26d308c6a5..b3ab0f1355 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache @@ -1,108 +1,41 @@ {{^abstract}} /** - * Builder for {@link {{className}}}. - */ - public static class Builder extends -{{#extendsOtherShape}} - {{extendsType}}.AbstractBuilder -{{/extendsOtherShape}} -{{^extendsOtherShape}} - {{TYPES.Client.Util.ObjectBuilderBase}} -{{/extendsOtherShape}} - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + * Builder for {@link {{className}}}. + */ {{#extendsOtherShape}} - @Override - protected Builder self() { - return this; - } - {{/extendsOtherShape}} -{{/abstract}} -{{#abstract}} - protected abstract static class AbstractBuilder> extends {{TYPES.Client.Util.ObjectBuilderBase}} { -{{/abstract}} - {{#fields}} - {{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}private {{type.boxed}} {{name}}; - {{/fields}} - - {{#fields}} - {{#type.isMap}} - {{>ObjectShape/FieldDoc/MapAddAll}} - {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type}} map) { - this.{{name}} = _mapPutAll(this.{{name}}, map); - return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; - } - - {{>ObjectShape/FieldDoc/MapAdd}} - {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.mapKeyType}} key, {{type.mapValueType}} value) { - this.{{name}} = _mapPut(this.{{name}}, key, value); - return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; - } - {{#type.mapValueType.hasBuilder}} - - {{>ObjectShape/FieldDoc/MapAddBuilderFn}} - {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder{{#abstract}}T{{/abstract}} {{name}}(String key, {{type.mapValueType.builderFnType}} fn) { - return {{name}}(key, fn.apply(new {{type.mapValueType.builderType}}()).build()); - } - {{/type.mapValueType.hasBuilder}} - {{/type.isMap}} - {{#type.isList}} - {{>ObjectShape/FieldDoc/ListAddAll}} - {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type}} list) { - this.{{name}} = _listAddAll(this.{{name}}, list); - return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; - } - - {{>ObjectShape/FieldDoc/ListAdd}} - {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.listValueType}} value, {{type.listValueType}}... values) { - this.{{name}} = _listAdd(this.{{name}}, value, values); - return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; - } - {{#type.listValueType.hasBuilder}} + public static class Builder extends {{extendsType}}.AbstractBuilder + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + {{>ObjectShape/Builder/SelfImpl}} - {{>ObjectShape/FieldDoc/ListAddBuilderFn}} - {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.listValueType.builderFnType}} fn) { - return {{name}}(fn.apply(new {{type.listValueType.builderType}}()).build()); - } - {{/type.listValueType.hasBuilder}} - {{/type.isList}} - {{^type.isListOrMap}} - {{>ObjectShape/FieldDoc/Basic}} - {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder{{#abstract}}T{{/abstract}} {{name}}({{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}{{type}} value) { - this.{{name}} = value; - return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; - } - {{#type.hasBuilder}} + {{>ObjectShape/Builder/Fields}} - {{>ObjectShape/FieldDoc/Basic}} - {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.builderFnType}} fn) { - return {{name}}(fn.apply(new {{type.builderType}}()).build()); + {{>ObjectShape/Builder/BuildImpl}} } - {{/type.hasBuilder}} - {{/type.isListOrMap}} - - {{/fields}} - {{^abstract}} - /** - * Builds a {@link {{className}}}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public {{className}} build() { - _checkSingleUse(); + {{/extendsOtherShape}} + {{^extendsOtherShape}} + {{#extendedByOtherShape}} + public static class Builder extends {{type}}.AbstractBuilder + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + {{>ObjectShape/Builder/SelfImpl}} + + {{>ObjectShape/Builder/BuildImpl}} + } + {{/extendedByOtherShape}} + {{^extendedByOtherShape}} + public static class Builder extends {{TYPES.Client.Util.ObjectBuilderBase}} + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + {{>ObjectShape/Builder/Fields}} + + {{>ObjectShape/Builder/BuildImpl}} + } + {{/extendedByOtherShape}} + {{/extendsOtherShape}} +{{/abstract}} +{{#extendedByOtherShape}} + protected abstract static class AbstractBuilder> + extends {{#extendsOtherShape}}{{extendsType}}.AbstractBuilder{{/extendsOtherShape}}{{^extendsOtherShape}}{{TYPES.Client.Util.ObjectBuilderBase}}{{/extendsOtherShape}} { + {{>ObjectShape/Builder/Fields}} - return new {{className}}(this); - } - {{/abstract}} - {{#abstract}} protected abstract BuilderT self(); - {{/abstract}} - } \ No newline at end of file + } +{{/extendedByOtherShape}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/BuildImpl.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/BuildImpl.mustache new file mode 100644 index 0000000000..882fad9d21 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/BuildImpl.mustache @@ -0,0 +1,10 @@ +/** + * Builds a {@link {{className}}}. + * + * @throws NullPointerException if some of the required fields are null. + */ +public {{className}} build() { + _checkSingleUse(); + + return new {{className}}(this); +} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/Fields.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/Fields.mustache new file mode 100644 index 0000000000..88184a506f --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/Fields.mustache @@ -0,0 +1,69 @@ +{{#fields}} + {{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}private {{type.boxed}} {{name}}; +{{/fields}} + +{{#fields}} + {{#type.isMap}} + {{>ObjectShape/FieldDoc/MapAddAll}} + {{#deprecation}}@Deprecated{{/deprecation}} + public final Builder{{#extendedByOtherShape}}T{{/extendedByOtherShape}} {{name}}({{type}} map) { + this.{{name}} = _mapPutAll(this.{{name}}, map); + return {{^extendedByOtherShape}}this{{/extendedByOtherShape}}{{#extendedByOtherShape}}self(){{/extendedByOtherShape}}; + } + + {{>ObjectShape/FieldDoc/MapAdd}} + {{#deprecation}}@Deprecated{{/deprecation}} + public final Builder{{#extendedByOtherShape}}T{{/extendedByOtherShape}} {{name}}({{type.mapKeyType}} key, {{type.mapValueType}} value) { + this.{{name}} = _mapPut(this.{{name}}, key, value); + return {{^extendedByOtherShape}}this{{/extendedByOtherShape}}{{#extendedByOtherShape}}self(){{/extendedByOtherShape}}; + } + {{#type.mapValueType.hasBuilder}} + + {{>ObjectShape/FieldDoc/MapAddBuilderFn}} + {{#deprecation}}@Deprecated{{/deprecation}} + public final Builder{{#extendedByOtherShape}}T{{/extendedByOtherShape}} {{name}}(String key, {{type.mapValueType.builderFnType}} fn) { + return {{name}}(key, fn.apply(new {{type.mapValueType.builderType}}()).build()); + } + {{/type.mapValueType.hasBuilder}} + {{/type.isMap}} + {{#type.isList}} + {{>ObjectShape/FieldDoc/ListAddAll}} + {{#deprecation}}@Deprecated{{/deprecation}} + public final Builder{{#extendedByOtherShape}}T{{/extendedByOtherShape}} {{name}}({{type}} list) { + this.{{name}} = _listAddAll(this.{{name}}, list); + return {{^extendedByOtherShape}}this{{/extendedByOtherShape}}{{#extendedByOtherShape}}self(){{/extendedByOtherShape}}; + } + + {{>ObjectShape/FieldDoc/ListAdd}} + {{#deprecation}}@Deprecated{{/deprecation}} + public final Builder{{#extendedByOtherShape}}T{{/extendedByOtherShape}} {{name}}({{type.listValueType}} value, {{type.listValueType}}... values) { + this.{{name}} = _listAdd(this.{{name}}, value, values); + return {{^extendedByOtherShape}}this{{/extendedByOtherShape}}{{#extendedByOtherShape}}self(){{/extendedByOtherShape}}; + } + {{#type.listValueType.hasBuilder}} + + {{>ObjectShape/FieldDoc/ListAddBuilderFn}} + {{#deprecation}}@Deprecated{{/deprecation}} + public final Builder{{#extendedByOtherShape}}T{{/extendedByOtherShape}} {{name}}({{type.listValueType.builderFnType}} fn) { + return {{name}}(fn.apply(new {{type.listValueType.builderType}}()).build()); + } + {{/type.listValueType.hasBuilder}} + {{/type.isList}} + {{^type.isListOrMap}} + {{>ObjectShape/FieldDoc/Basic}} + {{#deprecation}}@Deprecated{{/deprecation}} + public final Builder{{#extendedByOtherShape}}T{{/extendedByOtherShape}} {{name}}({{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}{{type}} value) { + this.{{name}} = value; + return {{^extendedByOtherShape}}this{{/extendedByOtherShape}}{{#extendedByOtherShape}}self(){{/extendedByOtherShape}}; + } + {{#type.hasBuilder}} + + {{>ObjectShape/FieldDoc/Basic}} + {{#deprecation}}@Deprecated{{/deprecation}} + public final Builder{{#extendedByOtherShape}}T{{/extendedByOtherShape}} {{name}}({{type.builderFnType}} fn) { + return {{name}}(fn.apply(new {{type.builderType}}()).build()); + } + {{/type.hasBuilder}} + {{/type.isListOrMap}} + +{{/fields}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache new file mode 100644 index 0000000000..7d897fe252 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache @@ -0,0 +1,4 @@ +@Override +protected Builder self() { + return this; +} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache index d526639524..b047e2a099 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Constructor.mustache @@ -1,9 +1,9 @@ -{{^abstract}} +{{^extendedByOtherShape}} private {{className}}(Builder builder) { -{{/abstract}} -{{#abstract}} +{{/extendedByOtherShape}} +{{#extendedByOtherShape}} protected {{className}}(AbstractBuilder builder) { -{{/abstract}} +{{/extendedByOtherShape}} {{#extendsOtherShape}} super(builder); {{/extendsOtherShape}} @@ -28,7 +28,7 @@ } {{^abstract}} - public static {{className}} of({{type.builderFnType}} fn) { + public static {{className}} {{#extendedByOtherShape}}{{#camelCase}}{{className}}{{/camelCase}}Of{{/extendedByOtherShape}}{{^extendedByOtherShape}}of{{/extendedByOtherShape}}({{type.builderFnType}} fn) { return fn.apply(new Builder()).build(); } {{/abstract}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache index 366d666744..4496a97a93 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache @@ -4,16 +4,18 @@ */ public static final {{TYPES.Client.Json.JsonpDeserializer}}<{{className}}> _DESERIALIZER = {{TYPES.Client.Json.ObjectBuilderDeserializer}}.lazy(Builder::new, {{className}}::setup{{className}}Deserializer); - protected static void setup{{className}}Deserializer({{TYPES.Client.Json.ObjectDeserializer}}<{{type.builderType}}> op) { {{/abstract}} -{{#abstract}} +{{^extendedByOtherShape}} + protected static void setup{{className}}Deserializer({{TYPES.Client.Json.ObjectDeserializer}}<{{type.builderType}}> op) { +{{/extendedByOtherShape}} +{{#extendedByOtherShape}} protected static > void setup{{className}}Deserializer({{TYPES.Client.Json.ObjectDeserializer}} op) { -{{/abstract}} +{{/extendedByOtherShape}} {{#extendsOtherShape}} {{extendsType}}.setup{{extendsType.name}}Deserializer(op); {{/extendsOtherShape}} {{#bodyFields}} - op.add({{#abstract}}Abstract{{/abstract}}Builder::{{name}}, {{#type}}{{>Type/deserializer}}{{/type}}, {{#quoted}}{{wireName}}{{/quoted}}); + op.add({{#extendedByOtherShape}}Abstract{{/extendedByOtherShape}}Builder::{{name}}, {{#type}}{{>Type/deserializer}}{{/type}}, {{#quoted}}{{wireName}}{{/quoted}}); {{/bodyFields}} {{#additionalPropertiesField}} op.setUnknownFieldHandler((builder, name, parser, mapper) -> { diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache index 65bb3b6360..236daf9abb 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache @@ -35,7 +35,7 @@ switch (_kind) { {{#variants}} case {{#pascalCase}}{{name}}{{/pascalCase}}: - return {{#type.queryParamify}}this.{{name}}(){{/type.queryParamify}}; + return {{#type.queryParamify}}this.{{#camelCase}}{{name}}{{/camelCase}}(){{/type.queryParamify}}; {{/variants}} default: throw new IllegalStateException("Unknown kind " + _kind); @@ -56,7 +56,7 @@ * * @throws IllegalStateException if the current variant is not the {@code {{name}}} kind. */ - public {{type}} {{name}}() { + public {{type}} {{#camelCase}}{{name}}{{/camelCase}}() { return {{TYPES.Client.Util.TaggedUnionUtils}}.get(this, Kind.{{#pascalCase}}{{name}}{{/pascalCase}}); } @@ -84,15 +84,15 @@ private Object _value; {{#variants}} - public {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{name}}({{type}} v) { + public {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{#camelCase}}{{name}}{{/camelCase}}({{type}} v) { this._kind = Kind.{{#pascalCase}}{{name}}{{/pascalCase}}; this._value = v; return this; } {{#type.hasBuilder}} - public {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{name}}({{type.builderFnType}} fn) { - return this.{{name}}(fn.apply(new {{type.builderType}}()).build()); + public {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{#camelCase}}{{name}}{{/camelCase}}({{type.builderFnType}} fn) { + return this.{{#camelCase}}{{name}}{{/camelCase}}(fn.apply(new {{type.builderType}}()).build()); } {{/type.hasBuilder}} From 4ca5c0a797e43b0a84c57fb2dd88c82de50a6deb Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 9 Sep 2024 15:49:51 +1200 Subject: [PATCH 07/11] Re-generate tasks.ListResponse Signed-off-by: Thomas Farr --- UPGRADING.md | 7 +- .../_types/BulkByScrollTaskStatus.java} | 379 +++++---- .../BulkByScrollTaskStatusOrException.java | 178 ++++ .../client/opensearch/_types/TaskFailure.java | 209 +++++ .../client/opensearch/tasks/ListResponse.java | 99 +++ .../client/opensearch/tasks/Status.java | 770 ++++++++++++++++++ .../client/opensearch/tasks/TaskGroup.java | 165 ++++ .../client/opensearch/tasks/TaskInfos.java | 163 ++++ .../tasks/TaskListResponseBase.java} | 185 +++-- .../core/DeleteByQueryRethrottleResponse.java | 7 +- .../opensearch/tasks/ListResponseTest.java | 13 +- .../integTest/AbstractTasksClientIT.java | 8 +- 12 files changed, 1915 insertions(+), 268 deletions(-) rename java-client/src/{main/java/org/opensearch/client/opensearch/tasks/Status.java => generated/java/org/opensearch/client/opensearch/_types/BulkByScrollTaskStatus.java} (62%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollTaskStatusOrException.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/TaskFailure.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/tasks/ListResponse.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/tasks/Status.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskGroup.java create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfos.java rename java-client/src/{main/java/org/opensearch/client/opensearch/tasks/ListResponse.java => generated/java/org/opensearch/client/opensearch/tasks/TaskListResponseBase.java} (64%) diff --git a/UPGRADING.md b/UPGRADING.md index dfa60f870b..03d240c506 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -32,4 +32,9 @@ After: ### tasks.State class renamed to tasks.TaskInfo - The `tasks.State` class has been renamed to `tasks.TaskInfo`, this affects: - `TaskExecutingNode`'s `tasks` field. -- The `headers` field is now a `Map` instead of a `Map>`. \ No newline at end of file +- The `headers` field is now a `Map` instead of a `Map>`. + +### tasks.ListResponse properties lifted to tasks.TaskListResponseBase +- All fields previously defined on `tasks.ListResponse` have been lifted to `tasks.TaskListResponseBase`. +- `DeleteByQueryRethrottleResponse` now extends `tasks.TaskListResponseBase` instead of `tasks.ListResponse`. +- The `tasks` field is now a `TaskInfos` union type instead of a `Map` to correctly handle `groupBy` parents or none. \ No newline at end of file diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/Status.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollTaskStatus.java similarity index 62% rename from java-client/src/main/java/org/opensearch/client/opensearch/tasks/Status.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollTaskStatus.java index 264dbf04d7..5d3a9500db 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/Status.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollTaskStatus.java @@ -30,11 +30,16 @@ * GitHub history for details. */ -package org.opensearch.client.opensearch.tasks; +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch._types; import jakarta.json.stream.JsonGenerator; import java.util.List; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -42,33 +47,37 @@ import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.opensearch._types.Retries; -import org.opensearch.client.opensearch._types.Time; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: tasks._types.Status +// typedef: _types.BulkByScrollTaskStatus @JsonpDeserializable -public class Status implements PlainJsonSerializable { - private final long batches; +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class BulkByScrollTaskStatus implements PlainJsonSerializable { + + private final int batches; @Nullable private final String canceled; - private final long created; + @Nullable + private final Long created; private final long deleted; private final long noops; - private final List failures; - private final float requestsPerSecond; private final Retries retries; + @Nullable + private final Integer sliceId; + + private final List slices; + @Nullable private final Time throttled; @@ -79,50 +88,45 @@ public class Status implements PlainJsonSerializable { private final long throttledUntilMillis; - @Nullable - private final Boolean timedOut; - - @Nullable - private final Long took; - private final long total; - private final long updated; + @Nullable + private final Long updated; private final long versionConflicts; // --------------------------------------------------------------------------------------------- - private Status(Builder builder) { - + private BulkByScrollTaskStatus(Builder builder) { this.batches = ApiTypeHelper.requireNonNull(builder.batches, this, "batches"); this.canceled = builder.canceled; - this.created = ApiTypeHelper.requireNonNull(builder.created, this, "created"); + this.created = builder.created; this.deleted = ApiTypeHelper.requireNonNull(builder.deleted, this, "deleted"); this.noops = ApiTypeHelper.requireNonNull(builder.noops, this, "noops"); - this.failures = ApiTypeHelper.unmodifiable(builder.failures); this.requestsPerSecond = ApiTypeHelper.requireNonNull(builder.requestsPerSecond, this, "requestsPerSecond"); this.retries = ApiTypeHelper.requireNonNull(builder.retries, this, "retries"); + this.sliceId = builder.sliceId; + this.slices = ApiTypeHelper.unmodifiable(builder.slices); this.throttled = builder.throttled; this.throttledMillis = ApiTypeHelper.requireNonNull(builder.throttledMillis, this, "throttledMillis"); this.throttledUntil = builder.throttledUntil; this.throttledUntilMillis = ApiTypeHelper.requireNonNull(builder.throttledUntilMillis, this, "throttledUntilMillis"); - this.timedOut = builder.timedOut; - this.took = builder.took; this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - this.updated = ApiTypeHelper.requireNonNull(builder.updated, this, "updated"); + this.updated = builder.updated; this.versionConflicts = ApiTypeHelper.requireNonNull(builder.versionConflicts, this, "versionConflicts"); - } - public static Status of(Function> fn) { + public static BulkByScrollTaskStatus of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Required - API name: {@code batches} + * Required - The number of scroll responses pulled back by the reindex. + *

+ * API name: {@code batches} + *

*/ - public final long batches() { + public final int batches() { return this.batches; } @@ -135,35 +139,41 @@ public final String canceled() { } /** - * Required - API name: {@code created} + * The number of documents that were successfully created. + *

+ * API name: {@code created} + *

*/ - public final long created() { + @Nullable + public final Long created() { return this.created; } /** - * Required - API name: {@code deleted} + * Required - The number of documents that were successfully deleted. + *

+ * API name: {@code deleted} + *

*/ public final long deleted() { return this.deleted; } /** - * Required - API name: {@code noops} + * Required - The number of documents that were ignored. + *

+ * API name: {@code noops} + *

*/ public final long noops() { return this.noops; } /** - * API name: {@code failures} - */ - public final List failures() { - return this.failures; - } - - /** - * Required - API name: {@code requests_per_second} + * Required - The number of requests per second effectively executed during the reindex. + *

+ * API name: {@code requests_per_second} + *

*/ public final float requestsPerSecond() { return this.requestsPerSecond; @@ -176,6 +186,21 @@ public final Retries retries() { return this.retries; } + /** + * API name: {@code slice_id} + */ + @Nullable + public final Integer sliceId() { + return this.sliceId; + } + + /** + * API name: {@code slices} + */ + public final List slices() { + return this.slices; + } + /** * API name: {@code throttled} */ @@ -207,37 +232,32 @@ public final long throttledUntilMillis() { } /** - * API name: {@code timed_out} - */ - @Nullable - public final Boolean timedOut() { - return this.timedOut; - } - - /** - * API name: {@code took} - */ - @Nullable - public final Long took() { - return this.took; - } - - /** - * Required - API name: {@code total} + * Required - The number of documents that were successfully processed. + *

+ * API name: {@code total} + *

*/ public final long total() { return this.total; } /** - * Required - API name: {@code updated} + * The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex + * updating it. + *

+ * API name: {@code updated} + *

*/ - public final long updated() { + @Nullable + public final Long updated() { return this.updated; } /** - * Required - API name: {@code version_conflicts} + * Required - The number of version conflicts that reindex hits. + *

+ * API name: {@code version_conflicts} + *

*/ public final long versionConflicts() { return this.versionConflicts; @@ -246,6 +266,7 @@ public final long versionConflicts() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -253,17 +274,18 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("batches"); generator.write(this.batches); if (this.canceled != null) { generator.writeKey("canceled"); generator.write(this.canceled); + } + if (this.created != null) { + generator.writeKey("created"); + generator.write(this.created); } - generator.writeKey("created"); - generator.write(this.created); generator.writeKey("deleted"); generator.write(this.deleted); @@ -271,110 +293,91 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("noops"); generator.write(this.noops); - if (ApiTypeHelper.isDefined(this.failures)) { - generator.writeKey("failures"); - generator.writeStartArray(); - for (String item0 : this.failures) { - generator.write(item0); - - } - generator.writeEnd(); - - } generator.writeKey("requests_per_second"); generator.write(this.requestsPerSecond); generator.writeKey("retries"); this.retries.serialize(generator, mapper); + if (this.sliceId != null) { + generator.writeKey("slice_id"); + generator.write(this.sliceId); + } + + if (ApiTypeHelper.isDefined(this.slices)) { + generator.writeKey("slices"); + generator.writeStartArray(); + for (BulkByScrollTaskStatusOrException item0 : this.slices) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + } + if (this.throttled != null) { generator.writeKey("throttled"); this.throttled.serialize(generator, mapper); - } + generator.writeKey("throttled_millis"); generator.write(this.throttledMillis); if (this.throttledUntil != null) { generator.writeKey("throttled_until"); this.throttledUntil.serialize(generator, mapper); - } + generator.writeKey("throttled_until_millis"); generator.write(this.throttledUntilMillis); - if (this.timedOut != null) { - generator.writeKey("timed_out"); - generator.write(this.timedOut); - - } - if (this.took != null) { - generator.writeKey("took"); - generator.write(this.took); - - } generator.writeKey("total"); generator.write(this.total); - generator.writeKey("updated"); - generator.write(this.updated); + if (this.updated != null) { + generator.writeKey("updated"); + generator.write(this.updated); + } generator.writeKey("version_conflicts"); generator.write(this.versionConflicts); - } // --------------------------------------------------------------------------------------------- /** - * Builder for {@link Status}. + * Builder for {@link BulkByScrollTaskStatus}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long batches; - + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Integer batches; @Nullable private String canceled; - + @Nullable private Long created; - private Long deleted; - private Long noops; - - @Nullable - private List failures; - private Float requestsPerSecond; - private Retries retries; - + @Nullable + private Integer sliceId; + @Nullable + private List slices; @Nullable private Time throttled; - private Long throttledMillis; - @Nullable private Time throttledUntil; - private Long throttledUntilMillis; - - @Nullable - private Boolean timedOut; - - @Nullable - private Long took; - private Long total; - + @Nullable private Long updated; - private Long versionConflicts; /** - * Required - API name: {@code batches} + * Required - The number of scroll responses pulled back by the reindex. + *

+ * API name: {@code batches} + *

*/ - public final Builder batches(long value) { + public final Builder batches(int value) { this.batches = value; return this; } @@ -388,15 +391,21 @@ public final Builder canceled(@Nullable String value) { } /** - * Required - API name: {@code created} + * The number of documents that were successfully created. + *

+ * API name: {@code created} + *

*/ - public final Builder created(long value) { + public final Builder created(@Nullable Long value) { this.created = value; return this; } /** - * Required - API name: {@code deleted} + * Required - The number of documents that were successfully deleted. + *

+ * API name: {@code deleted} + *

*/ public final Builder deleted(long value) { this.deleted = value; @@ -404,7 +413,10 @@ public final Builder deleted(long value) { } /** - * Required - API name: {@code noops} + * Required - The number of documents that were ignored. + *

+ * API name: {@code noops} + *

*/ public final Builder noops(long value) { this.noops = value; @@ -412,46 +424,74 @@ public final Builder noops(long value) { } /** - * API name: {@code failures} + * Required - The number of requests per second effectively executed during the reindex. *

- * Adds all elements of list to failures. + * API name: {@code requests_per_second} + *

*/ - public final Builder failures(List list) { - this.failures = _listAddAll(this.failures, list); + public final Builder requestsPerSecond(float value) { + this.requestsPerSecond = value; return this; } /** - * API name: {@code failures} - *

- * Adds one or more values to failures. + * Required - API name: {@code retries} */ - public final Builder failures(String value, String... values) { - this.failures = _listAdd(this.failures, value, values); + public final Builder retries(Retries value) { + this.retries = value; return this; } /** - * Required - API name: {@code requests_per_second} + * Required - API name: {@code retries} */ - public final Builder requestsPerSecond(float value) { - this.requestsPerSecond = value; + public final Builder retries(Function> fn) { + return retries(fn.apply(new Retries.Builder()).build()); + } + + /** + * API name: {@code slice_id} + */ + public final Builder sliceId(@Nullable Integer value) { + this.sliceId = value; return this; } /** - * Required - API name: {@code retries} + * API name: {@code slices} + * + *

+ * Adds all elements of list to slices. + *

*/ - public final Builder retries(Retries value) { - this.retries = value; + public final Builder slices(List list) { + this.slices = _listAddAll(this.slices, list); return this; } /** - * Required - API name: {@code retries} + * API name: {@code slices} + * + *

+ * Adds one or more values to slices. + *

*/ - public final Builder retries(Function> fn) { - return this.retries(fn.apply(new Retries.Builder()).build()); + public final Builder slices(BulkByScrollTaskStatusOrException value, BulkByScrollTaskStatusOrException... values) { + this.slices = _listAdd(this.slices, value, values); + return this; + } + + /** + * API name: {@code slices} + * + *

+ * Adds a value to slices using a builder lambda. + *

+ */ + public final Builder slices( + Function> fn + ) { + return slices(fn.apply(new BulkByScrollTaskStatusOrException.Builder()).build()); } /** @@ -466,7 +506,7 @@ public final Builder throttled(@Nullable Time value) { * API name: {@code throttled} */ public final Builder throttled(Function> fn) { - return this.throttled(fn.apply(new Time.Builder()).build()); + return throttled(fn.apply(new Time.Builder()).build()); } /** @@ -489,7 +529,7 @@ public final Builder throttledUntil(@Nullable Time value) { * API name: {@code throttled_until} */ public final Builder throttledUntil(Function> fn) { - return this.throttledUntil(fn.apply(new Time.Builder()).build()); + return throttledUntil(fn.apply(new Time.Builder()).build()); } /** @@ -501,23 +541,10 @@ public final Builder throttledUntilMillis(long value) { } /** - * API name: {@code timed_out} - */ - public final Builder timedOut(@Nullable Boolean value) { - this.timedOut = value; - return this; - } - - /** - * API name: {@code took} - */ - public final Builder took(@Nullable Long value) { - this.took = value; - return this; - } - - /** - * Required - API name: {@code total} + * Required - The number of documents that were successfully processed. + *

+ * API name: {@code total} + *

*/ public final Builder total(long value) { this.total = value; @@ -525,15 +552,22 @@ public final Builder total(long value) { } /** - * Required - API name: {@code updated} + * The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex + * updating it. + *

+ * API name: {@code updated} + *

*/ - public final Builder updated(long value) { + public final Builder updated(@Nullable Long value) { this.updated = value; return this; } /** - * Required - API name: {@code version_conflicts} + * Required - The number of version conflicts that reindex hits. + *

+ * API name: {@code version_conflicts} + *

*/ public final Builder versionConflicts(long value) { this.versionConflicts = value; @@ -541,48 +575,43 @@ public final Builder versionConflicts(long value) { } /** - * Builds a {@link Status}. + * Builds a {@link BulkByScrollTaskStatus}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ - public Status build() { + public BulkByScrollTaskStatus build() { _checkSingleUse(); - return new Status(this); + return new BulkByScrollTaskStatus(this); } } // --------------------------------------------------------------------------------------------- /** - * Json deserializer for {@link Status} + * Json deserializer for {@link BulkByScrollTaskStatus} */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( Builder::new, - Status::setupStatusDeserializer + BulkByScrollTaskStatus::setupBulkByScrollTaskStatusDeserializer ); - protected static void setupStatusDeserializer(ObjectDeserializer op) { - - op.add(Builder::batches, JsonpDeserializer.longDeserializer(), "batches"); + protected static void setupBulkByScrollTaskStatusDeserializer(ObjectDeserializer op) { + op.add(Builder::batches, JsonpDeserializer.integerDeserializer(), "batches"); op.add(Builder::canceled, JsonpDeserializer.stringDeserializer(), "canceled"); op.add(Builder::created, JsonpDeserializer.longDeserializer(), "created"); op.add(Builder::deleted, JsonpDeserializer.longDeserializer(), "deleted"); op.add(Builder::noops, JsonpDeserializer.longDeserializer(), "noops"); - op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "failures"); op.add(Builder::requestsPerSecond, JsonpDeserializer.floatDeserializer(), "requests_per_second"); op.add(Builder::retries, Retries._DESERIALIZER, "retries"); + op.add(Builder::sliceId, JsonpDeserializer.integerDeserializer(), "slice_id"); + op.add(Builder::slices, JsonpDeserializer.arrayDeserializer(BulkByScrollTaskStatusOrException._DESERIALIZER), "slices"); op.add(Builder::throttled, Time._DESERIALIZER, "throttled"); op.add(Builder::throttledMillis, JsonpDeserializer.longDeserializer(), "throttled_millis"); op.add(Builder::throttledUntil, Time._DESERIALIZER, "throttled_until"); op.add(Builder::throttledUntilMillis, JsonpDeserializer.longDeserializer(), "throttled_until_millis"); - op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out"); - op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); op.add(Builder::updated, JsonpDeserializer.longDeserializer(), "updated"); op.add(Builder::versionConflicts, JsonpDeserializer.longDeserializer(), "version_conflicts"); - } - } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollTaskStatusOrException.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollTaskStatusOrException.java new file mode 100644 index 0000000000..10d8cd24cb --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollTaskStatusOrException.java @@ -0,0 +1,178 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch._types; + +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Generated; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.json.UnionDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.TaggedUnion; +import org.opensearch.client.util.TaggedUnionUtils; + +// typedef: _types.BulkByScrollTaskStatusOrException + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class BulkByScrollTaskStatusOrException + implements + TaggedUnion, + PlainJsonSerializable { + public enum Kind { + Status, + Exception + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + private BulkByScrollTaskStatusOrException(Kind kind, Object value) { + this._kind = kind; + this._value = value; + } + + private BulkByScrollTaskStatusOrException(Builder builder) { + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + } + + public static BulkByScrollTaskStatusOrException of( + Function> fn + ) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code status}? + */ + public boolean isStatus() { + return _kind == Kind.Status; + } + + /** + * Get the {@code status} variant value. + * + * @throws IllegalStateException if the current variant is not the {@code status} kind. + */ + public BulkByScrollTaskStatus status() { + return TaggedUnionUtils.get(this, Kind.Status); + } + + /** + * Is this variant instance of kind {@code exception}? + */ + public boolean isException() { + return _kind == Kind.Exception; + } + + /** + * Get the {@code exception} variant value. + * + * @throws IllegalStateException if the current variant is not the {@code exception} kind. + */ + public ErrorCause exception() { + return TaggedUnionUtils.get(this, Kind.Exception); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder status(BulkByScrollTaskStatus v) { + this._kind = Kind.Status; + this._value = v; + return this; + } + + public ObjectBuilder status( + Function> fn + ) { + return this.status(fn.apply(new BulkByScrollTaskStatus.Builder()).build()); + } + + public ObjectBuilder exception(ErrorCause v) { + this._kind = Kind.Exception; + this._value = v; + return this; + } + + public ObjectBuilder exception(Function> fn) { + return this.exception(fn.apply(new ErrorCause.Builder()).build()); + } + + @Override + public BulkByScrollTaskStatusOrException build() { + _checkSingleUse(); + return new BulkByScrollTaskStatusOrException(this); + } + } + + private static JsonpDeserializer buildBulkByScrollTaskStatusOrExceptionDeserializer() { + return new UnionDeserializer.Builder(BulkByScrollTaskStatusOrException::new, false) + .addMember(Kind.Status, BulkByScrollTaskStatus._DESERIALIZER) + .addMember(Kind.Exception, ErrorCause._DESERIALIZER) + .build(); + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.lazy( + BulkByScrollTaskStatusOrException::buildBulkByScrollTaskStatusOrExceptionDeserializer + ); +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/TaskFailure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/TaskFailure.java new file mode 100644 index 0000000000..ad679c5cbd --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/TaskFailure.java @@ -0,0 +1,209 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch._types; + +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Generated; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; + +// typedef: _types.TaskFailure + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class TaskFailure implements PlainJsonSerializable { + + private final String nodeId; + + private final ErrorCause reason; + + private final String status; + + private final int taskId; + + // --------------------------------------------------------------------------------------------- + + private TaskFailure(Builder builder) { + this.nodeId = ApiTypeHelper.requireNonNull(builder.nodeId, this, "nodeId"); + this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason"); + this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); + this.taskId = ApiTypeHelper.requireNonNull(builder.taskId, this, "taskId"); + } + + public static TaskFailure of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code node_id} + */ + public final String nodeId() { + return this.nodeId; + } + + /** + * Required - API name: {@code reason} + */ + public final ErrorCause reason() { + return this.reason; + } + + /** + * Required - API name: {@code status} + */ + public final String status() { + return this.status; + } + + /** + * Required - API name: {@code task_id} + */ + public final int taskId() { + return this.taskId; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("node_id"); + generator.write(this.nodeId); + + generator.writeKey("reason"); + this.reason.serialize(generator, mapper); + + generator.writeKey("status"); + generator.write(this.status); + + generator.writeKey("task_id"); + generator.write(this.taskId); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link TaskFailure}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private String nodeId; + private ErrorCause reason; + private String status; + private Integer taskId; + + /** + * Required - API name: {@code node_id} + */ + public final Builder nodeId(String value) { + this.nodeId = value; + return this; + } + + /** + * Required - API name: {@code reason} + */ + public final Builder reason(ErrorCause value) { + this.reason = value; + return this; + } + + /** + * Required - API name: {@code reason} + */ + public final Builder reason(Function> fn) { + return reason(fn.apply(new ErrorCause.Builder()).build()); + } + + /** + * Required - API name: {@code status} + */ + public final Builder status(String value) { + this.status = value; + return this; + } + + /** + * Required - API name: {@code task_id} + */ + public final Builder taskId(int value) { + this.taskId = value; + return this; + } + + /** + * Builds a {@link TaskFailure}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public TaskFailure build() { + _checkSingleUse(); + + return new TaskFailure(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link TaskFailure} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + TaskFailure::setupTaskFailureDeserializer + ); + + protected static void setupTaskFailureDeserializer(ObjectDeserializer op) { + op.add(Builder::nodeId, JsonpDeserializer.stringDeserializer(), "node_id"); + op.add(Builder::reason, ErrorCause._DESERIALIZER, "reason"); + op.add(Builder::status, JsonpDeserializer.stringDeserializer(), "status"); + op.add(Builder::taskId, JsonpDeserializer.integerDeserializer(), "task_id"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/ListResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/ListResponse.java new file mode 100644 index 0000000000..906b8da91c --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/ListResponse.java @@ -0,0 +1,99 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.tasks; + +import java.util.function.Function; +import javax.annotation.Generated; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ObjectBuilder; + +// typedef: tasks.list.Response + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class ListResponse extends TaskListResponseBase { + + // --------------------------------------------------------------------------------------------- + + private ListResponse(Builder builder) { + super(builder); + } + + public static ListResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ListResponse}. + */ + public static class Builder extends TaskListResponseBase.AbstractBuilder implements ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link ListResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public ListResponse build() { + _checkSingleUse(); + + return new ListResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ListResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + ListResponse::setupListResponseDeserializer + ); + + protected static void setupListResponseDeserializer(ObjectDeserializer op) { + TaskListResponseBase.setupTaskListResponseBaseDeserializer(op); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/Status.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/Status.java new file mode 100644 index 0000000000..743796d107 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/Status.java @@ -0,0 +1,770 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.tasks; + +import jakarta.json.stream.JsonGenerator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.json.JsonData; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.BulkByScrollTaskStatusOrException; +import org.opensearch.client.opensearch._types.Retries; +import org.opensearch.client.opensearch._types.Time; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; + +// typedef: tasks.Status + +/** + * Task status information can vary wildly from task to task. + */ +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class Status implements PlainJsonSerializable { + + @Nullable + private final Integer batches; + + @Nullable + private final String canceled; + + @Nullable + private final Long created; + + @Nullable + private final Long deleted; + + @Nullable + private final Long noops; + + @Nullable + private final String phase; + + @Nullable + private final Float requestsPerSecond; + + @Nullable + private final Retries retries; + + @Nullable + private final Integer sliceId; + + private final List slices; + + @Nullable + private final String state; + + @Nullable + private final Time throttled; + + @Nullable + private final Long throttledMillis; + + @Nullable + private final Time throttledUntil; + + @Nullable + private final Long throttledUntilMillis; + + @Nullable + private final Long total; + + @Nullable + private final Long updated; + + @Nullable + private final Long versionConflicts; + + private final Map metadata; + + // --------------------------------------------------------------------------------------------- + + private Status(Builder builder) { + this.batches = builder.batches; + this.canceled = builder.canceled; + this.created = builder.created; + this.deleted = builder.deleted; + this.noops = builder.noops; + this.phase = builder.phase; + this.requestsPerSecond = builder.requestsPerSecond; + this.retries = builder.retries; + this.sliceId = builder.sliceId; + this.slices = ApiTypeHelper.unmodifiable(builder.slices); + this.state = builder.state; + this.throttled = builder.throttled; + this.throttledMillis = builder.throttledMillis; + this.throttledUntil = builder.throttledUntil; + this.throttledUntilMillis = builder.throttledUntilMillis; + this.total = builder.total; + this.updated = builder.updated; + this.versionConflicts = builder.versionConflicts; + this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); + } + + public static Status of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * The number of scroll responses pulled back by the reindex. + *

+ * API name: {@code batches} + *

+ */ + @Nullable + public final Integer batches() { + return this.batches; + } + + /** + * API name: {@code canceled} + */ + @Nullable + public final String canceled() { + return this.canceled; + } + + /** + * The number of documents that were successfully created. + *

+ * API name: {@code created} + *

+ */ + @Nullable + public final Long created() { + return this.created; + } + + /** + * The number of documents that were successfully deleted. + *

+ * API name: {@code deleted} + *

+ */ + @Nullable + public final Long deleted() { + return this.deleted; + } + + /** + * The number of documents that were ignored. + *

+ * API name: {@code noops} + *

+ */ + @Nullable + public final Long noops() { + return this.noops; + } + + /** + * API name: {@code phase} + */ + @Nullable + public final String phase() { + return this.phase; + } + + /** + * The number of requests per second effectively executed during the reindex. + *

+ * API name: {@code requests_per_second} + *

+ */ + @Nullable + public final Float requestsPerSecond() { + return this.requestsPerSecond; + } + + /** + * API name: {@code retries} + */ + @Nullable + public final Retries retries() { + return this.retries; + } + + /** + * API name: {@code slice_id} + */ + @Nullable + public final Integer sliceId() { + return this.sliceId; + } + + /** + * API name: {@code slices} + */ + public final List slices() { + return this.slices; + } + + /** + * API name: {@code state} + */ + @Nullable + public final String state() { + return this.state; + } + + /** + * API name: {@code throttled} + */ + @Nullable + public final Time throttled() { + return this.throttled; + } + + /** + * API name: {@code throttled_millis} + */ + @Nullable + public final Long throttledMillis() { + return this.throttledMillis; + } + + /** + * API name: {@code throttled_until} + */ + @Nullable + public final Time throttledUntil() { + return this.throttledUntil; + } + + /** + * API name: {@code throttled_until_millis} + */ + @Nullable + public final Long throttledUntilMillis() { + return this.throttledUntilMillis; + } + + /** + * The number of documents that were successfully processed. + *

+ * API name: {@code total} + *

+ */ + @Nullable + public final Long total() { + return this.total; + } + + /** + * The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex + * updating it. + *

+ * API name: {@code updated} + *

+ */ + @Nullable + public final Long updated() { + return this.updated; + } + + /** + * The number of version conflicts that reindex hits. + *

+ * API name: {@code version_conflicts} + *

+ */ + @Nullable + public final Long versionConflicts() { + return this.versionConflicts; + } + + /** + */ + public final Map metadata() { + return this.metadata; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + for (Map.Entry item0 : this.metadata.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + if (this.batches != null) { + generator.writeKey("batches"); + generator.write(this.batches); + } + + if (this.canceled != null) { + generator.writeKey("canceled"); + generator.write(this.canceled); + } + + if (this.created != null) { + generator.writeKey("created"); + generator.write(this.created); + } + + if (this.deleted != null) { + generator.writeKey("deleted"); + generator.write(this.deleted); + } + + if (this.noops != null) { + generator.writeKey("noops"); + generator.write(this.noops); + } + + if (this.phase != null) { + generator.writeKey("phase"); + generator.write(this.phase); + } + + if (this.requestsPerSecond != null) { + generator.writeKey("requests_per_second"); + generator.write(this.requestsPerSecond); + } + + if (this.retries != null) { + generator.writeKey("retries"); + this.retries.serialize(generator, mapper); + } + + if (this.sliceId != null) { + generator.writeKey("slice_id"); + generator.write(this.sliceId); + } + + if (ApiTypeHelper.isDefined(this.slices)) { + generator.writeKey("slices"); + generator.writeStartArray(); + for (BulkByScrollTaskStatusOrException item0 : this.slices) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.state != null) { + generator.writeKey("state"); + generator.write(this.state); + } + + if (this.throttled != null) { + generator.writeKey("throttled"); + this.throttled.serialize(generator, mapper); + } + + if (this.throttledMillis != null) { + generator.writeKey("throttled_millis"); + generator.write(this.throttledMillis); + } + + if (this.throttledUntil != null) { + generator.writeKey("throttled_until"); + this.throttledUntil.serialize(generator, mapper); + } + + if (this.throttledUntilMillis != null) { + generator.writeKey("throttled_until_millis"); + generator.write(this.throttledUntilMillis); + } + + if (this.total != null) { + generator.writeKey("total"); + generator.write(this.total); + } + + if (this.updated != null) { + generator.writeKey("updated"); + generator.write(this.updated); + } + + if (this.versionConflicts != null) { + generator.writeKey("version_conflicts"); + generator.write(this.versionConflicts); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link Status}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private Integer batches; + @Nullable + private String canceled; + @Nullable + private Long created; + @Nullable + private Long deleted; + @Nullable + private Long noops; + @Nullable + private String phase; + @Nullable + private Float requestsPerSecond; + @Nullable + private Retries retries; + @Nullable + private Integer sliceId; + @Nullable + private List slices; + @Nullable + private String state; + @Nullable + private Time throttled; + @Nullable + private Long throttledMillis; + @Nullable + private Time throttledUntil; + @Nullable + private Long throttledUntilMillis; + @Nullable + private Long total; + @Nullable + private Long updated; + @Nullable + private Long versionConflicts; + @Nullable + private Map metadata; + + /** + * The number of scroll responses pulled back by the reindex. + *

+ * API name: {@code batches} + *

+ */ + public final Builder batches(@Nullable Integer value) { + this.batches = value; + return this; + } + + /** + * API name: {@code canceled} + */ + public final Builder canceled(@Nullable String value) { + this.canceled = value; + return this; + } + + /** + * The number of documents that were successfully created. + *

+ * API name: {@code created} + *

+ */ + public final Builder created(@Nullable Long value) { + this.created = value; + return this; + } + + /** + * The number of documents that were successfully deleted. + *

+ * API name: {@code deleted} + *

+ */ + public final Builder deleted(@Nullable Long value) { + this.deleted = value; + return this; + } + + /** + * The number of documents that were ignored. + *

+ * API name: {@code noops} + *

+ */ + public final Builder noops(@Nullable Long value) { + this.noops = value; + return this; + } + + /** + * API name: {@code phase} + */ + public final Builder phase(@Nullable String value) { + this.phase = value; + return this; + } + + /** + * The number of requests per second effectively executed during the reindex. + *

+ * API name: {@code requests_per_second} + *

+ */ + public final Builder requestsPerSecond(@Nullable Float value) { + this.requestsPerSecond = value; + return this; + } + + /** + * API name: {@code retries} + */ + public final Builder retries(@Nullable Retries value) { + this.retries = value; + return this; + } + + /** + * API name: {@code retries} + */ + public final Builder retries(Function> fn) { + return retries(fn.apply(new Retries.Builder()).build()); + } + + /** + * API name: {@code slice_id} + */ + public final Builder sliceId(@Nullable Integer value) { + this.sliceId = value; + return this; + } + + /** + * API name: {@code slices} + * + *

+ * Adds all elements of list to slices. + *

+ */ + public final Builder slices(List list) { + this.slices = _listAddAll(this.slices, list); + return this; + } + + /** + * API name: {@code slices} + * + *

+ * Adds one or more values to slices. + *

+ */ + public final Builder slices(BulkByScrollTaskStatusOrException value, BulkByScrollTaskStatusOrException... values) { + this.slices = _listAdd(this.slices, value, values); + return this; + } + + /** + * API name: {@code slices} + * + *

+ * Adds a value to slices using a builder lambda. + *

+ */ + public final Builder slices( + Function> fn + ) { + return slices(fn.apply(new BulkByScrollTaskStatusOrException.Builder()).build()); + } + + /** + * API name: {@code state} + */ + public final Builder state(@Nullable String value) { + this.state = value; + return this; + } + + /** + * API name: {@code throttled} + */ + public final Builder throttled(@Nullable Time value) { + this.throttled = value; + return this; + } + + /** + * API name: {@code throttled} + */ + public final Builder throttled(Function> fn) { + return throttled(fn.apply(new Time.Builder()).build()); + } + + /** + * API name: {@code throttled_millis} + */ + public final Builder throttledMillis(@Nullable Long value) { + this.throttledMillis = value; + return this; + } + + /** + * API name: {@code throttled_until} + */ + public final Builder throttledUntil(@Nullable Time value) { + this.throttledUntil = value; + return this; + } + + /** + * API name: {@code throttled_until} + */ + public final Builder throttledUntil(Function> fn) { + return throttledUntil(fn.apply(new Time.Builder()).build()); + } + + /** + * API name: {@code throttled_until_millis} + */ + public final Builder throttledUntilMillis(@Nullable Long value) { + this.throttledUntilMillis = value; + return this; + } + + /** + * The number of documents that were successfully processed. + *

+ * API name: {@code total} + *

+ */ + public final Builder total(@Nullable Long value) { + this.total = value; + return this; + } + + /** + * The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex + * updating it. + *

+ * API name: {@code updated} + *

+ */ + public final Builder updated(@Nullable Long value) { + this.updated = value; + return this; + } + + /** + * The number of version conflicts that reindex hits. + *

+ * API name: {@code version_conflicts} + *

+ */ + public final Builder versionConflicts(@Nullable Long value) { + this.versionConflicts = value; + return this; + } + + /** + * + *

+ * Adds all elements of map to metadata. + *

+ */ + public final Builder metadata(Map map) { + this.metadata = _mapPutAll(this.metadata, map); + return this; + } + + /** + * + *

+ * Adds an entry to metadata. + *

+ */ + public final Builder metadata(String key, JsonData value) { + this.metadata = _mapPut(this.metadata, key, value); + return this; + } + + /** + * Builds a {@link Status}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public Status build() { + _checkSingleUse(); + + return new Status(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link Status} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + Status::setupStatusDeserializer + ); + + protected static void setupStatusDeserializer(ObjectDeserializer op) { + op.add(Builder::batches, JsonpDeserializer.integerDeserializer(), "batches"); + op.add(Builder::canceled, JsonpDeserializer.stringDeserializer(), "canceled"); + op.add(Builder::created, JsonpDeserializer.longDeserializer(), "created"); + op.add(Builder::deleted, JsonpDeserializer.longDeserializer(), "deleted"); + op.add(Builder::noops, JsonpDeserializer.longDeserializer(), "noops"); + op.add(Builder::phase, JsonpDeserializer.stringDeserializer(), "phase"); + op.add(Builder::requestsPerSecond, JsonpDeserializer.floatDeserializer(), "requests_per_second"); + op.add(Builder::retries, Retries._DESERIALIZER, "retries"); + op.add(Builder::sliceId, JsonpDeserializer.integerDeserializer(), "slice_id"); + op.add(Builder::slices, JsonpDeserializer.arrayDeserializer(BulkByScrollTaskStatusOrException._DESERIALIZER), "slices"); + op.add(Builder::state, JsonpDeserializer.stringDeserializer(), "state"); + op.add(Builder::throttled, Time._DESERIALIZER, "throttled"); + op.add(Builder::throttledMillis, JsonpDeserializer.longDeserializer(), "throttled_millis"); + op.add(Builder::throttledUntil, Time._DESERIALIZER, "throttled_until"); + op.add(Builder::throttledUntilMillis, JsonpDeserializer.longDeserializer(), "throttled_until_millis"); + op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); + op.add(Builder::updated, JsonpDeserializer.longDeserializer(), "updated"); + op.add(Builder::versionConflicts, JsonpDeserializer.longDeserializer(), "version_conflicts"); + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + if (builder.metadata == null) { + builder.metadata = new HashMap<>(); + } + builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskGroup.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskGroup.java new file mode 100644 index 0000000000..d1650b85b3 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskGroup.java @@ -0,0 +1,165 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.tasks; + +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; + +// typedef: tasks.TaskGroup + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class TaskGroup extends TaskInfo { + + private final List children; + + // --------------------------------------------------------------------------------------------- + + private TaskGroup(Builder builder) { + super(builder); + this.children = ApiTypeHelper.unmodifiable(builder.children); + } + + public static TaskGroup of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code children} + */ + public final List children() { + return this.children; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + super.serializeInternal(generator, mapper); + if (ApiTypeHelper.isDefined(this.children)) { + generator.writeKey("children"); + generator.writeStartArray(); + for (TaskGroup item0 : this.children) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link TaskGroup}. + */ + public static class Builder extends TaskInfo.AbstractBuilder implements ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + @Nullable + private List children; + + /** + * API name: {@code children} + * + *

+ * Adds all elements of list to children. + *

+ */ + public final Builder children(List list) { + this.children = _listAddAll(this.children, list); + return this; + } + + /** + * API name: {@code children} + * + *

+ * Adds one or more values to children. + *

+ */ + public final Builder children(TaskGroup value, TaskGroup... values) { + this.children = _listAdd(this.children, value, values); + return this; + } + + /** + * API name: {@code children} + * + *

+ * Adds a value to children using a builder lambda. + *

+ */ + public final Builder children(Function> fn) { + return children(fn.apply(new TaskGroup.Builder()).build()); + } + + /** + * Builds a {@link TaskGroup}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public TaskGroup build() { + _checkSingleUse(); + + return new TaskGroup(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link TaskGroup} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + TaskGroup::setupTaskGroupDeserializer + ); + + protected static void setupTaskGroupDeserializer(ObjectDeserializer op) { + TaskInfo.setupTaskInfoDeserializer(op); + op.add(Builder::children, JsonpDeserializer.arrayDeserializer(TaskGroup._DESERIALIZER), "children"); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfos.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfos.java new file mode 100644 index 0000000000..9e394d3d7a --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskInfos.java @@ -0,0 +1,163 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.tasks; + +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Generated; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.json.UnionDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.TaggedUnion; +import org.opensearch.client.util.TaggedUnionUtils; + +// typedef: tasks.TaskInfos + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class TaskInfos implements TaggedUnion, PlainJsonSerializable { + public enum Kind { + GroupedByNone, + GroupedByParents + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + private TaskInfos(Kind kind, Object value) { + this._kind = kind; + this._value = value; + } + + private TaskInfos(Builder builder) { + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + } + + public static TaskInfos of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code grouped_by_none}? + */ + public boolean isGroupedByNone() { + return _kind == Kind.GroupedByNone; + } + + /** + * Get the {@code grouped_by_none} variant value. + * + * @throws IllegalStateException if the current variant is not the {@code grouped_by_none} kind. + */ + public List groupedByNone() { + return TaggedUnionUtils.get(this, Kind.GroupedByNone); + } + + /** + * Is this variant instance of kind {@code grouped_by_parents}? + */ + public boolean isGroupedByParents() { + return _kind == Kind.GroupedByParents; + } + + /** + * Get the {@code grouped_by_parents} variant value. + * + * @throws IllegalStateException if the current variant is not the {@code grouped_by_parents} kind. + */ + public Map groupedByParents() { + return TaggedUnionUtils.get(this, Kind.GroupedByParents); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder groupedByNone(List v) { + this._kind = Kind.GroupedByNone; + this._value = v; + return this; + } + + public ObjectBuilder groupedByParents(Map v) { + this._kind = Kind.GroupedByParents; + this._value = v; + return this; + } + + @Override + public TaskInfos build() { + _checkSingleUse(); + return new TaskInfos(this); + } + } + + private static JsonpDeserializer buildTaskInfosDeserializer() { + return new UnionDeserializer.Builder(TaskInfos::new, false).addMember( + Kind.GroupedByNone, + JsonpDeserializer.arrayDeserializer(TaskInfo._DESERIALIZER) + ).addMember(Kind.GroupedByParents, JsonpDeserializer.stringMapDeserializer(TaskGroup._DESERIALIZER)).build(); + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.lazy(TaskInfos::buildTaskInfosDeserializer); +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/ListResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskListResponseBase.java similarity index 64% rename from java-client/src/main/java/org/opensearch/client/opensearch/tasks/ListResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskListResponseBase.java index 8f63dbea1f..b67eb2965d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/ListResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskListResponseBase.java @@ -30,46 +30,49 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.tasks; import jakarta.json.stream.JsonGenerator; import java.util.List; import java.util.Map; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; -import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.opensearch._types.ErrorCause; +import org.opensearch.client.opensearch._types.TaskFailure; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: tasks.list.Response +// typedef: tasks.TaskListResponseBase + +@Generated("org.opensearch.client.codegen.CodeGenerator") +public abstract class TaskListResponseBase implements PlainJsonSerializable { -@JsonpDeserializable -public class ListResponse implements PlainJsonSerializable { private final List nodeFailures; private final Map nodes; - private final Map tasks; + private final List taskFailures; - // --------------------------------------------------------------------------------------------- + @Nullable + private final TaskInfos tasks; - protected ListResponse(AbstractBuilder builder) { + // --------------------------------------------------------------------------------------------- + protected TaskListResponseBase(AbstractBuilder builder) { this.nodeFailures = ApiTypeHelper.unmodifiable(builder.nodeFailures); this.nodes = ApiTypeHelper.unmodifiable(builder.nodes); - this.tasks = ApiTypeHelper.unmodifiable(builder.tasks); - - } - - public static ListResponse listResponseOf(Function> fn) { - return fn.apply(new Builder()).build(); + this.taskFailures = ApiTypeHelper.unmodifiable(builder.taskFailures); + this.tasks = builder.tasks; } /** @@ -80,22 +83,34 @@ public final List nodeFailures() { } /** + * Task information grouped by node, if `group_by` was set to `node` (the default). + *

* API name: {@code nodes} + *

*/ public final Map nodes() { return this.nodes; } + /** + * API name: {@code task_failures} + */ + public final List taskFailures() { + return this.taskFailures; + } + /** * API name: {@code tasks} */ - public final Map tasks() { + @Nullable + public final TaskInfos tasks() { return this.tasks; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -103,81 +118,58 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.nodeFailures)) { generator.writeKey("node_failures"); generator.writeStartArray(); for (ErrorCause item0 : this.nodeFailures) { item0.serialize(generator, mapper); - } generator.writeEnd(); - } + if (ApiTypeHelper.isDefined(this.nodes)) { generator.writeKey("nodes"); generator.writeStartObject(); for (Map.Entry item0 : this.nodes.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } - if (ApiTypeHelper.isDefined(this.tasks)) { - generator.writeKey("tasks"); - generator.writeStartObject(); - for (Map.Entry item0 : this.tasks.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); + if (ApiTypeHelper.isDefined(this.taskFailures)) { + generator.writeKey("task_failures"); + generator.writeStartArray(); + for (TaskFailure item0 : this.taskFailures) { + item0.serialize(generator, mapper); } generator.writeEnd(); - } + if (this.tasks != null) { + generator.writeKey("tasks"); + this.tasks.serialize(generator, mapper); + } } // --------------------------------------------------------------------------------------------- - /** - * Builder for {@link ListResponse}. - */ - - public static class Builder extends ListResponse.AbstractBuilder implements ObjectBuilder { - @Override - protected Builder self() { - return this; - } - - /** - * Builds a {@link ListResponse}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public ListResponse build() { - _checkSingleUse(); - - return new ListResponse(this); - } - } - protected abstract static class AbstractBuilder> extends ObjectBuilderBase { @Nullable private List nodeFailures; - @Nullable private Map nodes; - @Nullable - private Map tasks; + private List taskFailures; + @Nullable + private TaskInfos tasks; /** * API name: {@code node_failures} + * *

* Adds all elements of list to nodeFailures. + *

*/ public final BuilderT nodeFailures(List list) { this.nodeFailures = _listAddAll(this.nodeFailures, list); @@ -186,8 +178,10 @@ public final BuilderT nodeFailures(List list) { /** * API name: {@code node_failures} + * *

* Adds one or more values to nodeFailures. + *

*/ public final BuilderT nodeFailures(ErrorCause value, ErrorCause... values) { this.nodeFailures = _listAdd(this.nodeFailures, value, values); @@ -196,17 +190,24 @@ public final BuilderT nodeFailures(ErrorCause value, ErrorCause... values) { /** * API name: {@code node_failures} + * *

* Adds a value to nodeFailures using a builder lambda. + *

*/ public final BuilderT nodeFailures(Function> fn) { return nodeFailures(fn.apply(new ErrorCause.Builder()).build()); } /** + * Task information grouped by node, if `group_by` was set to `node` (the default). + *

* API name: {@code nodes} + *

+ * *

- * Adds all entries of map to nodes. + * Adds all elements of map to nodes. + *

*/ public final BuilderT nodes(Map map) { this.nodes = _mapPutAll(this.nodes, map); @@ -214,9 +215,14 @@ public final BuilderT nodes(Map map) { } /** + * Task information grouped by node, if `group_by` was set to `node` (the default). + *

* API name: {@code nodes} + *

+ * *

* Adds an entry to nodes. + *

*/ public final BuilderT nodes(String key, TaskExecutingNode value) { this.nodes = _mapPut(this.nodes, key, value); @@ -224,63 +230,80 @@ public final BuilderT nodes(String key, TaskExecutingNode value) { } /** + * Task information grouped by node, if `group_by` was set to `node` (the default). + *

* API name: {@code nodes} + *

+ * *

- * Adds an entry to nodes using a builder lambda. + * Adds a value to nodes using a builder lambda. + *

*/ public final BuilderT nodes(String key, Function> fn) { return nodes(key, fn.apply(new TaskExecutingNode.Builder()).build()); } /** - * API name: {@code tasks} + * API name: {@code task_failures} + * *

- * Adds all entries of map to tasks. + * Adds all elements of list to taskFailures. + *

*/ - public final BuilderT tasks(Map map) { - this.tasks = _mapPutAll(this.tasks, map); + public final BuilderT taskFailures(List list) { + this.taskFailures = _listAddAll(this.taskFailures, list); return self(); } /** - * API name: {@code tasks} + * API name: {@code task_failures} + * *

- * Adds an entry to tasks. + * Adds one or more values to taskFailures. + *

*/ - public final BuilderT tasks(String key, Info value) { - this.tasks = _mapPut(this.tasks, key, value); + public final BuilderT taskFailures(TaskFailure value, TaskFailure... values) { + this.taskFailures = _listAdd(this.taskFailures, value, values); return self(); } /** - * API name: {@code tasks} + * API name: {@code task_failures} + * *

- * Adds an entry to tasks using a builder lambda. + * Adds a value to taskFailures using a builder lambda. + *

*/ - public final BuilderT tasks(String key, Function> fn) { - return tasks(key, fn.apply(new Info.Builder()).build()); + public final BuilderT taskFailures(Function> fn) { + return taskFailures(fn.apply(new TaskFailure.Builder()).build()); } - protected abstract BuilderT self(); + /** + * API name: {@code tasks} + */ + public final BuilderT tasks(@Nullable TaskInfos value) { + this.tasks = value; + return self(); + } + + /** + * API name: {@code tasks} + */ + public final BuilderT tasks(Function> fn) { + return tasks(fn.apply(new TaskInfos.Builder()).build()); + } + protected abstract BuilderT self(); } // --------------------------------------------------------------------------------------------- - /** - * Json deserializer for {@link ListResponse} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - ListResponse::setupListResponseDeserializer - ); - - protected static > void setupListResponseDeserializer(ObjectDeserializer op) { - + protected static > void setupTaskListResponseBaseDeserializer( + ObjectDeserializer op + ) { op.add(AbstractBuilder::nodeFailures, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "node_failures"); op.add(AbstractBuilder::nodes, JsonpDeserializer.stringMapDeserializer(TaskExecutingNode._DESERIALIZER), "nodes"); - op.add(AbstractBuilder::tasks, JsonpDeserializer.stringMapDeserializer(Info._DESERIALIZER), "tasks"); - + op.add(AbstractBuilder::taskFailures, JsonpDeserializer.arrayDeserializer(TaskFailure._DESERIALIZER), "task_failures"); + op.add(AbstractBuilder::tasks, TaskInfos._DESERIALIZER, "tasks"); } - } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/DeleteByQueryRethrottleResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/DeleteByQueryRethrottleResponse.java index 6aa588a151..3880fe3604 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/DeleteByQueryRethrottleResponse.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/DeleteByQueryRethrottleResponse.java @@ -38,12 +38,13 @@ import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.opensearch.tasks.ListResponse; +import org.opensearch.client.opensearch.tasks.TaskListResponseBase; import org.opensearch.client.util.ObjectBuilder; // typedef: _global.delete_by_query_rethrottle.Response @JsonpDeserializable -public class DeleteByQueryRethrottleResponse extends ListResponse { +public class DeleteByQueryRethrottleResponse extends TaskListResponseBase { // --------------------------------------------------------------------------------------------- private DeleteByQueryRethrottleResponse(Builder builder) { @@ -61,7 +62,7 @@ public static DeleteByQueryRethrottleResponse of(Function implements ObjectBuilder { + public static class Builder extends TaskListResponseBase.AbstractBuilder implements ObjectBuilder { @Override protected Builder self() { return this; @@ -91,7 +92,7 @@ public DeleteByQueryRethrottleResponse build() { ); protected static void setupDeleteByQueryRethrottleResponseDeserializer(ObjectDeserializer op) { - ListResponse.setupListResponseDeserializer(op); + TaskListResponseBase.setupTaskListResponseBaseDeserializer(op); } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/tasks/ListResponseTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/tasks/ListResponseTest.java index 2328335cf3..3899abf82a 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/tasks/ListResponseTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/tasks/ListResponseTest.java @@ -94,7 +94,7 @@ public void canDeserializeGroupedByNodes() { + "}"; final ListResponse response = fromJson(json, ListResponse._DESERIALIZER); - assertTrue(response.tasks().isEmpty()); + assertNull(response.tasks()); final Map nodes = response.nodes(); assertNotNull(nodes); @@ -152,14 +152,17 @@ public void canDeserializeGroupedByParents() { final ListResponse response = fromJson(json, ListResponse._DESERIALIZER); assertTrue(response.nodes().isEmpty()); - final Map tasks = response.tasks(); + final TaskInfos tasks = response.tasks(); assertNotNull(tasks); - assertEquals(1, tasks.size()); + assertTrue(tasks.isGroupedByParents()); - final Info task = tasks.get("y2hDJUdMTWa6sNA_0vdF6Q:5306"); + final Map groups = tasks.groupedByParents(); + assertEquals(1, groups.size()); + + final TaskGroup task = groups.get("y2hDJUdMTWa6sNA_0vdF6Q:5306"); assertNotNull(task); - final List children = task.children(); + final List children = task.children(); assertEquals(2, children.size()); assertEquals("cluster:monitor/tasks/lists[n]", children.get(0).action()); diff --git a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractTasksClientIT.java b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractTasksClientIT.java index 2018c2202c..00421d5bae 100644 --- a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractTasksClientIT.java +++ b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractTasksClientIT.java @@ -18,20 +18,22 @@ public abstract class AbstractTasksClientIT extends OpenSearchJavaClientTestCase public void list_groupedByNodes() throws IOException { final ListResponse response = javaClient().tasks().list(l -> l.groupBy(GroupBy.Nodes)); assertFalse(response.nodes().isEmpty()); - assertTrue(response.tasks().isEmpty()); + assertNull(response.tasks()); } @Test public void list_groupedByParents() throws IOException { final ListResponse response = javaClient().tasks().list(l -> l.groupBy(GroupBy.Parents)); assertTrue(response.nodes().isEmpty()); - assertFalse(response.tasks().isEmpty()); + assertNotNull(response.tasks()); + assertTrue(response.tasks().isGroupedByParents()); } @Test public void list_groupedByNone() throws IOException { final ListResponse response = javaClient().tasks().list(l -> l.groupBy(GroupBy.None)); assertTrue(response.nodes().isEmpty()); - assertFalse(response.tasks().isEmpty()); + assertNotNull(response.tasks()); + assertTrue(response.tasks().isGroupedByNone()); } } From 278ffde6f8a21f994b436fda1bc4a389b61f4106 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 9 Sep 2024 15:58:23 +1200 Subject: [PATCH 08/11] Regenerate tasks.cancel Signed-off-by: Thomas Farr --- .../opensearch/tasks/CancelRequest.java | 106 ++++----- .../opensearch/tasks/CancelResponse.java | 99 ++++++++ .../tasks/OpenSearchTasksAsyncClientBase.java | 26 +++ .../tasks/OpenSearchTasksClientBase.java | 26 +++ .../opensearch/tasks/CancelResponse.java | 221 ------------------ .../tasks/OpenSearchTasksAsyncClient.java | 42 ---- .../tasks/OpenSearchTasksClient.java | 42 ---- .../client/codegen/CodeGenerator.java | 2 +- 8 files changed, 201 insertions(+), 363 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/tasks/CancelRequest.java (76%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/tasks/CancelResponse.java delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/tasks/CancelResponse.java diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/CancelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/CancelRequest.java similarity index 76% rename from java-client/src/main/java/org/opensearch/client/opensearch/tasks/CancelRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/CancelRequest.java index 7f23b42031..44b99ef7a0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/CancelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/CancelRequest.java @@ -30,13 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.tasks; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; -import java.util.stream.Collectors; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; @@ -50,10 +54,10 @@ /** * Cancels a task, if it can be cancelled through an API. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class CancelRequest extends RequestBase { + private final List actions; private final List nodes; @@ -70,45 +74,42 @@ public class CancelRequest extends RequestBase { // --------------------------------------------------------------------------------------------- private CancelRequest(Builder builder) { - this.actions = ApiTypeHelper.unmodifiable(builder.actions); this.nodes = ApiTypeHelper.unmodifiable(builder.nodes); this.parentTaskId = builder.parentTaskId; this.taskId = builder.taskId; this.waitForCompletion = builder.waitForCompletion; - } - public static CancelRequest of(Function> fn) { + public static CancelRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * A comma-separated list of actions that should be cancelled. Leave empty to - * cancel all. + * Comma-separated list or wildcard expression of actions used to limit the request. *

* API name: {@code actions} + *

*/ public final List actions() { return this.actions; } /** - * A comma-separated list of node IDs or names to limit the returned - * information; use _local to return information from the node - * you're connecting to, leave empty to get information from all nodes + * Comma-separated list of node IDs or names used to limit the request. *

* API name: {@code nodes} + *

*/ public final List nodes() { return this.nodes; } /** - * Cancel tasks with specified parent task id (node_id:task_number). Set to -1 - * to cancel all. + * Parent task ID used to limit the tasks. *

* API name: {@code parent_task_id} + *

*/ @Nullable public final String parentTaskId() { @@ -116,9 +117,10 @@ public final String parentTaskId() { } /** - * Cancel the task with specified task id (node_id:task_number) + * ID of the task. *

* API name: {@code task_id} + *

*/ @Nullable public final String taskId() { @@ -126,10 +128,10 @@ public final String taskId() { } /** - * Should the request block until the cancellation of the task and its - * descendant tasks is completed. Defaults to false + * Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false *

* API name: {@code wait_for_completion} + *

*/ @Nullable public final Boolean waitForCompletion() { @@ -141,30 +143,27 @@ public final Boolean waitForCompletion() { /** * Builder for {@link CancelRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private List actions; - @Nullable private List nodes; - @Nullable private String parentTaskId; - @Nullable private String taskId; - @Nullable private Boolean waitForCompletion; /** - * A comma-separated list of actions that should be cancelled. Leave empty to - * cancel all. + * Comma-separated list or wildcard expression of actions used to limit the request. *

* API name: {@code actions} + *

+ * *

* Adds all elements of list to actions. + *

*/ public final Builder actions(List list) { this.actions = _listAddAll(this.actions, list); @@ -172,12 +171,14 @@ public final Builder actions(List list) { } /** - * A comma-separated list of actions that should be cancelled. Leave empty to - * cancel all. + * Comma-separated list or wildcard expression of actions used to limit the request. *

* API name: {@code actions} + *

+ * *

* Adds one or more values to actions. + *

*/ public final Builder actions(String value, String... values) { this.actions = _listAdd(this.actions, value, values); @@ -185,13 +186,14 @@ public final Builder actions(String value, String... values) { } /** - * A comma-separated list of node IDs or names to limit the returned - * information; use _local to return information from the node - * you're connecting to, leave empty to get information from all nodes + * Comma-separated list of node IDs or names used to limit the request. *

* API name: {@code nodes} + *

+ * *

* Adds all elements of list to nodes. + *

*/ public final Builder nodes(List list) { this.nodes = _listAddAll(this.nodes, list); @@ -199,13 +201,14 @@ public final Builder nodes(List list) { } /** - * A comma-separated list of node IDs or names to limit the returned - * information; use _local to return information from the node - * you're connecting to, leave empty to get information from all nodes + * Comma-separated list of node IDs or names used to limit the request. *

* API name: {@code nodes} + *

+ * *

* Adds one or more values to nodes. + *

*/ public final Builder nodes(String value, String... values) { this.nodes = _listAdd(this.nodes, value, values); @@ -213,10 +216,10 @@ public final Builder nodes(String value, String... values) { } /** - * Cancel tasks with specified parent task id (node_id:task_number). Set to -1 - * to cancel all. + * Parent task ID used to limit the tasks. *

* API name: {@code parent_task_id} + *

*/ public final Builder parentTaskId(@Nullable String value) { this.parentTaskId = value; @@ -224,9 +227,10 @@ public final Builder parentTaskId(@Nullable String value) { } /** - * Cancel the task with specified task id (node_id:task_number) + * ID of the task. *

* API name: {@code task_id} + *

*/ public final Builder taskId(@Nullable String value) { this.taskId = value; @@ -234,10 +238,10 @@ public final Builder taskId(@Nullable String value) { } /** - * Should the request block until the cancellation of the task and its - * descendant tasks is completed. Defaults to false + * Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false *

* API name: {@code wait_for_completion} + *

*/ public final Builder waitForCompletion(@Nullable Boolean value) { this.waitForCompletion = value; @@ -247,8 +251,7 @@ public final Builder waitForCompletion(@Nullable Boolean value) { /** * Builds a {@link CancelRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public CancelRequest build() { _checkSingleUse(); @@ -263,13 +266,8 @@ public CancelRequest build() { * Endpoint "{@code tasks.cancel}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "POST"; - - }, - + request -> "POST", // Request path request -> { final int _taskId = 1 << 0; @@ -279,40 +277,34 @@ public CancelRequest build() { if (request.taskId() != null) propsSet |= _taskId; if (propsSet == 0) { - StringBuilder buf = new StringBuilder(); - buf.append("/_tasks"); - buf.append("/_cancel"); - return buf.toString(); + return "/_tasks/_cancel"; } if (propsSet == (_taskId)) { StringBuilder buf = new StringBuilder(); - buf.append("/_tasks"); - buf.append("/"); + buf.append("/_tasks/"); SimpleEndpoint.pathEncode(request.taskId, buf); buf.append("/_cancel"); return buf.toString(); } - throw SimpleEndpoint.noPathTemplateFound("path"); + throw SimpleEndpoint.noPathTemplateFound("path"); }, - // Request parameters request -> { Map params = new HashMap<>(); + if (ApiTypeHelper.isDefined(request.actions)) { + params.put("actions", String.join(",", request.actions)); + } if (ApiTypeHelper.isDefined(request.nodes)) { - params.put("nodes", request.nodes.stream().map(v -> v).collect(Collectors.joining(","))); + params.put("nodes", String.join(",", request.nodes)); } if (request.parentTaskId != null) { params.put("parent_task_id", request.parentTaskId); } - if (ApiTypeHelper.isDefined(request.actions)) { - params.put("actions", request.actions.stream().map(v -> v).collect(Collectors.joining(","))); - } if (request.waitForCompletion != null) { params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); } return params; - }, SimpleEndpoint.emptyMap(), false, diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/CancelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/CancelResponse.java new file mode 100644 index 0000000000..c8b3e3f539 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/CancelResponse.java @@ -0,0 +1,99 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.tasks; + +import java.util.function.Function; +import javax.annotation.Generated; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ObjectBuilder; + +// typedef: tasks.cancel.Response + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class CancelResponse extends TaskListResponseBase { + + // --------------------------------------------------------------------------------------------- + + private CancelResponse(Builder builder) { + super(builder); + } + + public static CancelResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link CancelResponse}. + */ + public static class Builder extends TaskListResponseBase.AbstractBuilder implements ObjectBuilder { + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link CancelResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public CancelResponse build() { + _checkSingleUse(); + + return new CancelResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link CancelResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + CancelResponse::setupCancelResponseDeserializer + ); + + protected static void setupCancelResponseDeserializer(ObjectDeserializer op) { + TaskListResponseBase.setupTaskListResponseBaseDeserializer(op); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java index 7fab24ba00..be136b62ec 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java @@ -58,6 +58,32 @@ public OpenSearchTasksAsyncClientBase(OpenSearchTransport transport, @Nullable T super(transport, transportOptions); } + // ----- Endpoint: tasks.cancel + + /** + * Cancels a task, if it can be cancelled through an API. + */ + public CompletableFuture cancel(CancelRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, CancelRequest._ENDPOINT, this.transportOptions); + } + + /** + * Cancels a task, if it can be cancelled through an API. + * + * @param fn a function that initializes a builder to create the {@link CancelRequest} + */ + public final CompletableFuture cancel(Function> fn) + throws IOException, OpenSearchException { + return cancel(fn.apply(new CancelRequest.Builder()).build()); + } + + /** + * Cancels a task, if it can be cancelled through an API. + */ + public final CompletableFuture cancel() throws IOException, OpenSearchException { + return cancel(new CancelRequest.Builder().build()); + } + // ----- Endpoint: tasks.list /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java index 5881ebe95f..0ce1d56603 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java @@ -55,6 +55,32 @@ public OpenSearchTasksClientBase(OpenSearchTransport transport, @Nullable Transp super(transport, transportOptions); } + // ----- Endpoint: tasks.cancel + + /** + * Cancels a task, if it can be cancelled through an API. + */ + public CancelResponse cancel(CancelRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, CancelRequest._ENDPOINT, this.transportOptions); + } + + /** + * Cancels a task, if it can be cancelled through an API. + * + * @param fn a function that initializes a builder to create the {@link CancelRequest} + */ + public final CancelResponse cancel(Function> fn) throws IOException, + OpenSearchException { + return cancel(fn.apply(new CancelRequest.Builder()).build()); + } + + /** + * Cancels a task, if it can be cancelled through an API. + */ + public final CancelResponse cancel() throws IOException, OpenSearchException { + return cancel(new CancelRequest.Builder().build()); + } + // ----- Endpoint: tasks.list /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/CancelResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/CancelResponse.java deleted file mode 100644 index abe4da1157..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/CancelResponse.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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. - */ - -/* - * 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. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.tasks; - -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.opensearch._types.ErrorCause; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: tasks.cancel.Response - -@JsonpDeserializable -public class CancelResponse implements PlainJsonSerializable { - private final List nodeFailures; - - private final Map nodes; - - // --------------------------------------------------------------------------------------------- - - private CancelResponse(Builder builder) { - - this.nodeFailures = ApiTypeHelper.unmodifiable(builder.nodeFailures); - this.nodes = ApiTypeHelper.unmodifiableRequired(builder.nodes, this, "nodes"); - - } - - public static CancelResponse of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * API name: {@code node_failures} - */ - public final List nodeFailures() { - return this.nodeFailures; - } - - /** - * Required - API name: {@code nodes} - */ - public final Map nodes() { - return this.nodes; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.nodeFailures)) { - generator.writeKey("node_failures"); - generator.writeStartArray(); - for (ErrorCause item0 : this.nodeFailures) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - } - if (ApiTypeHelper.isDefined(this.nodes)) { - generator.writeKey("nodes"); - generator.writeStartObject(); - for (Map.Entry item0 : this.nodes.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link CancelResponse}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private List nodeFailures; - - private Map nodes; - - /** - * API name: {@code node_failures} - *

- * Adds all elements of list to nodeFailures. - */ - public final Builder nodeFailures(List list) { - this.nodeFailures = _listAddAll(this.nodeFailures, list); - return this; - } - - /** - * API name: {@code node_failures} - *

- * Adds one or more values to nodeFailures. - */ - public final Builder nodeFailures(ErrorCause value, ErrorCause... values) { - this.nodeFailures = _listAdd(this.nodeFailures, value, values); - return this; - } - - /** - * API name: {@code node_failures} - *

- * Adds a value to nodeFailures using a builder lambda. - */ - public final Builder nodeFailures(Function> fn) { - return nodeFailures(fn.apply(new ErrorCause.Builder()).build()); - } - - /** - * Required - API name: {@code nodes} - *

- * Adds all entries of map to nodes. - */ - public final Builder nodes(Map map) { - this.nodes = _mapPutAll(this.nodes, map); - return this; - } - - /** - * Required - API name: {@code nodes} - *

- * Adds an entry to nodes. - */ - public final Builder nodes(String key, TaskExecutingNode value) { - this.nodes = _mapPut(this.nodes, key, value); - return this; - } - - /** - * Required - API name: {@code nodes} - *

- * Adds an entry to nodes using a builder lambda. - */ - public final Builder nodes(String key, Function> fn) { - return nodes(key, fn.apply(new TaskExecutingNode.Builder()).build()); - } - - /** - * Builds a {@link CancelResponse}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public CancelResponse build() { - _checkSingleUse(); - - return new CancelResponse(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link CancelResponse} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - CancelResponse::setupCancelResponseDeserializer - ); - - protected static void setupCancelResponseDeserializer(ObjectDeserializer op) { - - op.add(Builder::nodeFailures, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "node_failures"); - op.add(Builder::nodes, JsonpDeserializer.stringMapDeserializer(TaskExecutingNode._DESERIALIZER), "nodes"); - - } - -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java index d83bb1f53d..dc58027f8b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java @@ -61,48 +61,6 @@ public OpenSearchTasksAsyncClient withTransportOptions(@Nullable TransportOption return new OpenSearchTasksAsyncClient(this.transport, transportOptions); } - // ----- Endpoint: tasks.cancel - - /** - * Cancels a task, if it can be cancelled through an API. - * - * - */ - - public CompletableFuture cancel(CancelRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - CancelRequest, - CancelResponse, - ErrorResponse>) CancelRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Cancels a task, if it can be cancelled through an API. - * - * @param fn - * a function that initializes a builder to create the - * {@link CancelRequest} - * - */ - - public final CompletableFuture cancel(Function> fn) - throws IOException, OpenSearchException { - return cancel(fn.apply(new CancelRequest.Builder()).build()); - } - - /** - * Cancels a task, if it can be cancelled through an API. - * - * - */ - - public CompletableFuture cancel() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new CancelRequest.Builder().build(), CancelRequest._ENDPOINT, this.transportOptions); - } - // ----- Endpoint: tasks.get /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java index 607ba4a6ca..11c8add97f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java @@ -60,48 +60,6 @@ public OpenSearchTasksClient withTransportOptions(@Nullable TransportOptions tra return new OpenSearchTasksClient(this.transport, transportOptions); } - // ----- Endpoint: tasks.cancel - - /** - * Cancels a task, if it can be cancelled through an API. - * - * - */ - - public CancelResponse cancel(CancelRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - CancelRequest, - CancelResponse, - ErrorResponse>) CancelRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Cancels a task, if it can be cancelled through an API. - * - * @param fn - * a function that initializes a builder to create the - * {@link CancelRequest} - * - */ - - public final CancelResponse cancel(Function> fn) throws IOException, - OpenSearchException { - return cancel(fn.apply(new CancelRequest.Builder()).build()); - } - - /** - * Cancels a task, if it can be cancelled through an API. - * - * - */ - - public CancelResponse cancel() throws IOException, OpenSearchException { - return this.transport.performRequest(new CancelRequest.Builder().build(), CancelRequest._ENDPOINT, this.transportOptions); - } - // ----- Endpoint: tasks.get /** diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java index 5434ea1e16..6773ef3dcb 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java @@ -44,7 +44,7 @@ public class CodeGenerator { and(namespace(""), named("info")), namespace("dangling_indices"), and(namespace("ml"), not(named("search_models"))), // TODO: search_models is complex and ideally should re-use the search structures - and(namespace("tasks"), named("list")) + and(namespace("tasks"), named("cancel", "list")) ); public static void main(String[] args) { From 61e046eb2503723dd6a2cd5e220505aa2f5b807d Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 9 Sep 2024 16:38:55 +1200 Subject: [PATCH 09/11] Regenerate tasks.get Signed-off-by: Thomas Farr --- UPGRADING.md | 10 +- .../_types/BulkByScrollFailure.java | 316 ++++++++ .../opensearch/tasks/GetTasksRequest.java | 76 +- .../opensearch/tasks/GetTasksResponse.java | 105 ++- ...e.java => OpenSearchTasksAsyncClient.java} | 34 +- ...ntBase.java => OpenSearchTasksClient.java} | 32 +- .../client/opensearch/tasks/TaskResponse.java | 721 ++++++++++++++++++ .../client/opensearch/tasks/Info.java | 481 ------------ .../tasks/OpenSearchTasksAsyncClient.java | 95 --- .../tasks/OpenSearchTasksClient.java | 94 --- .../client/codegen/CodeGenerator.java | 2 +- .../client/codegen/model/Namespace.java | 2 +- 12 files changed, 1188 insertions(+), 780 deletions(-) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollFailure.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/tasks/GetTasksRequest.java (78%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/tasks/GetTasksResponse.java (81%) rename java-client/src/generated/java/org/opensearch/client/opensearch/tasks/{OpenSearchTasksAsyncClientBase.java => OpenSearchTasksAsyncClient.java} (75%) rename java-client/src/generated/java/org/opensearch/client/opensearch/tasks/{OpenSearchTasksClientBase.java => OpenSearchTasksClient.java} (75%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskResponse.java delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/tasks/Info.java delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java diff --git a/UPGRADING.md b/UPGRADING.md index 03d240c506..e2047ad692 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -29,12 +29,16 @@ After: - The type of the `total`, `successful` and `failed` fields has been corrected from `Number` to `int`. - The type of the `skipped` field has been corrected from `Number` to `Integer`. -### tasks.State class renamed to tasks.TaskInfo -- The `tasks.State` class has been renamed to `tasks.TaskInfo`, this affects: +### Unified tasks.Info & tasks.State classes into tasks.TaskInfo +- The `tasks.Info` and `tasks.State` classes have been unified into `tasks.TaskInfo`, this affects: - `TaskExecutingNode`'s `tasks` field. + - `GetTasksResponse`'s `task` field. - The `headers` field is now a `Map` instead of a `Map>`. ### tasks.ListResponse properties lifted to tasks.TaskListResponseBase - All fields previously defined on `tasks.ListResponse` have been lifted to `tasks.TaskListResponseBase`. - `DeleteByQueryRethrottleResponse` now extends `tasks.TaskListResponseBase` instead of `tasks.ListResponse`. -- The `tasks` field is now a `TaskInfos` union type instead of a `Map` to correctly handle `groupBy` parents or none. \ No newline at end of file +- The `tasks` field is now a `TaskInfos` union type instead of a `Map` to correctly handle `groupBy` parents or none. + +### GetTasksResponse response type +- The type of `GetTasksResponse`'s `response` field has been changed from `tasks.Status` to `tasks.TaskResponse`. \ No newline at end of file diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollFailure.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollFailure.java new file mode 100644 index 0000000000..a31cc9741a --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/BulkByScrollFailure.java @@ -0,0 +1,316 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch._types; + +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; + +// typedef: _types.BulkByScrollFailure + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class BulkByScrollFailure implements PlainJsonSerializable { + + @Nullable + private final ErrorCause cause; + + @Nullable + private final String id; + + @Nullable + private final String index; + + @Nullable + private final String node; + + @Nullable + private final ErrorCause reason; + + @Nullable + private final Integer shard; + + private final int status; + + // --------------------------------------------------------------------------------------------- + + private BulkByScrollFailure(Builder builder) { + this.cause = builder.cause; + this.id = builder.id; + this.index = builder.index; + this.node = builder.node; + this.reason = builder.reason; + this.shard = builder.shard; + this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); + } + + public static BulkByScrollFailure of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code cause} + */ + @Nullable + public final ErrorCause cause() { + return this.cause; + } + + /** + * API name: {@code id} + */ + @Nullable + public final String id() { + return this.id; + } + + /** + * API name: {@code index} + */ + @Nullable + public final String index() { + return this.index; + } + + /** + * API name: {@code node} + */ + @Nullable + public final String node() { + return this.node; + } + + /** + * API name: {@code reason} + */ + @Nullable + public final ErrorCause reason() { + return this.reason; + } + + /** + * API name: {@code shard} + */ + @Nullable + public final Integer shard() { + return this.shard; + } + + /** + * Required - API name: {@code status} + */ + public final int status() { + return this.status; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.cause != null) { + generator.writeKey("cause"); + this.cause.serialize(generator, mapper); + } + + if (this.id != null) { + generator.writeKey("id"); + generator.write(this.id); + } + + if (this.index != null) { + generator.writeKey("index"); + generator.write(this.index); + } + + if (this.node != null) { + generator.writeKey("node"); + generator.write(this.node); + } + + if (this.reason != null) { + generator.writeKey("reason"); + this.reason.serialize(generator, mapper); + } + + if (this.shard != null) { + generator.writeKey("shard"); + generator.write(this.shard); + } + + generator.writeKey("status"); + generator.write(this.status); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link BulkByScrollFailure}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private ErrorCause cause; + @Nullable + private String id; + @Nullable + private String index; + @Nullable + private String node; + @Nullable + private ErrorCause reason; + @Nullable + private Integer shard; + private Integer status; + + /** + * API name: {@code cause} + */ + public final Builder cause(@Nullable ErrorCause value) { + this.cause = value; + return this; + } + + /** + * API name: {@code cause} + */ + public final Builder cause(Function> fn) { + return cause(fn.apply(new ErrorCause.Builder()).build()); + } + + /** + * API name: {@code id} + */ + public final Builder id(@Nullable String value) { + this.id = value; + return this; + } + + /** + * API name: {@code index} + */ + public final Builder index(@Nullable String value) { + this.index = value; + return this; + } + + /** + * API name: {@code node} + */ + public final Builder node(@Nullable String value) { + this.node = value; + return this; + } + + /** + * API name: {@code reason} + */ + public final Builder reason(@Nullable ErrorCause value) { + this.reason = value; + return this; + } + + /** + * API name: {@code reason} + */ + public final Builder reason(Function> fn) { + return reason(fn.apply(new ErrorCause.Builder()).build()); + } + + /** + * API name: {@code shard} + */ + public final Builder shard(@Nullable Integer value) { + this.shard = value; + return this; + } + + /** + * Required - API name: {@code status} + */ + public final Builder status(int value) { + this.status = value; + return this; + } + + /** + * Builds a {@link BulkByScrollFailure}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public BulkByScrollFailure build() { + _checkSingleUse(); + + return new BulkByScrollFailure(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link BulkByScrollFailure} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + BulkByScrollFailure::setupBulkByScrollFailureDeserializer + ); + + protected static void setupBulkByScrollFailureDeserializer(ObjectDeserializer op) { + op.add(Builder::cause, ErrorCause._DESERIALIZER, "cause"); + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); + op.add(Builder::node, JsonpDeserializer.stringDeserializer(), "node"); + op.add(Builder::reason, ErrorCause._DESERIALIZER, "reason"); + op.add(Builder::shard, JsonpDeserializer.integerDeserializer(), "shard"); + op.add(Builder::status, JsonpDeserializer.integerDeserializer(), "status"); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/GetTasksRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/GetTasksRequest.java similarity index 78% rename from java-client/src/main/java/org/opensearch/client/opensearch/tasks/GetTasksRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/GetTasksRequest.java index 1dd8575647..7f120b8d9e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/GetTasksRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/GetTasksRequest.java @@ -30,11 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.tasks; import java.util.HashMap; import java.util.Map; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; @@ -49,10 +54,10 @@ /** * Returns information about a task. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetTasksRequest extends RequestBase { + private final String taskId; @Nullable @@ -64,30 +69,30 @@ public class GetTasksRequest extends RequestBase { // --------------------------------------------------------------------------------------------- private GetTasksRequest(Builder builder) { - this.taskId = ApiTypeHelper.requireNonNull(builder.taskId, this, "taskId"); this.timeout = builder.timeout; this.waitForCompletion = builder.waitForCompletion; - } - public static GetTasksRequest of(Function> fn) { + public static GetTasksRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Required - Return the task with specified id (node_id:task_number) + * Required - ID of the task. *

* API name: {@code task_id} + *

*/ public final String taskId() { return this.taskId; } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ @Nullable public final Time timeout() { @@ -95,9 +100,10 @@ public final Time timeout() { } /** - * Wait for the matching tasks to complete (default: false) + * If `true`, the request blocks until the task has completed. *

* API name: {@code wait_for_completion} + *

*/ @Nullable public final Boolean waitForCompletion() { @@ -109,20 +115,18 @@ public final Boolean waitForCompletion() { /** * Builder for {@link GetTasksRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private String taskId; - @Nullable private Time timeout; - @Nullable private Boolean waitForCompletion; /** - * Required - Return the task with specified id (node_id:task_number) + * Required - ID of the task. *

* API name: {@code task_id} + *

*/ public final Builder taskId(String value) { this.taskId = value; @@ -130,9 +134,10 @@ public final Builder taskId(String value) { } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ public final Builder timeout(@Nullable Time value) { this.timeout = value; @@ -140,18 +145,20 @@ public final Builder timeout(@Nullable Time value) { } /** - * Explicit operation timeout + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. *

* API name: {@code timeout} + *

*/ public final Builder timeout(Function> fn) { - return this.timeout(fn.apply(new Time.Builder()).build()); + return timeout(fn.apply(new Time.Builder()).build()); } /** - * Wait for the matching tasks to complete (default: false) + * If `true`, the request blocks until the task has completed. *

* API name: {@code wait_for_completion} + *

*/ public final Builder waitForCompletion(@Nullable Boolean value) { this.waitForCompletion = value; @@ -161,8 +168,7 @@ public final Builder waitForCompletion(@Nullable Boolean value) { /** * Builds a {@link GetTasksRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public GetTasksRequest build() { _checkSingleUse(); @@ -177,43 +183,25 @@ public GetTasksRequest build() { * Endpoint "{@code tasks.get}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // Request path request -> { - final int _taskId = 1 << 0; - - int propsSet = 0; - - propsSet |= _taskId; - - if (propsSet == (_taskId)) { - StringBuilder buf = new StringBuilder(); - buf.append("/_tasks"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.taskId, buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_tasks/"); + SimpleEndpoint.pathEncode(request.taskId, buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.waitForCompletion != null) { - params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); - } if (request.timeout != null) { params.put("timeout", request.timeout._toJsonString()); } + if (request.waitForCompletion != null) { + params.put("wait_for_completion", String.valueOf(request.waitForCompletion)); + } return params; - }, SimpleEndpoint.emptyMap(), false, diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/GetTasksResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/GetTasksResponse.java similarity index 81% rename from java-client/src/main/java/org/opensearch/client/opensearch/tasks/GetTasksResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/GetTasksResponse.java index 00b4878d81..929d2ebbf0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/GetTasksResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/GetTasksResponse.java @@ -30,10 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.tasks; import jakarta.json.stream.JsonGenerator; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -49,29 +54,29 @@ // typedef: tasks.get.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetTasksResponse implements PlainJsonSerializable { - private final boolean completed; - private final Info task; + private final boolean completed; @Nullable - private final Status response; + private final ErrorCause error; @Nullable - private final ErrorCause error; + private final TaskResponse response; + + private final TaskInfo task; // --------------------------------------------------------------------------------------------- private GetTasksResponse(Builder builder) { - this.completed = ApiTypeHelper.requireNonNull(builder.completed, this, "completed"); - this.task = ApiTypeHelper.requireNonNull(builder.task, this, "task"); - this.response = builder.response; this.error = builder.error; - + this.response = builder.response; + this.task = ApiTypeHelper.requireNonNull(builder.task, this, "task"); } - public static GetTasksResponse of(Function> fn) { + public static GetTasksResponse of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -83,31 +88,32 @@ public final boolean completed() { } /** - * Required - API name: {@code task} + * API name: {@code error} */ - public final Info task() { - return this.task; + @Nullable + public final ErrorCause error() { + return this.error; } /** * API name: {@code response} */ @Nullable - public final Status response() { + public final TaskResponse response() { return this.response; } /** - * API name: {@code error} + * Required - API name: {@code task} */ - @Nullable - public final ErrorCause error() { - return this.error; + public final TaskInfo task() { + return this.task; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -115,24 +121,21 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("completed"); generator.write(this.completed); - generator.writeKey("task"); - this.task.serialize(generator, mapper); - - if (this.response != null) { - generator.writeKey("response"); - this.response.serialize(generator, mapper); - - } if (this.error != null) { generator.writeKey("error"); this.error.serialize(generator, mapper); + } + if (this.response != null) { + generator.writeKey("response"); + this.response.serialize(generator, mapper); } + generator.writeKey("task"); + this.task.serialize(generator, mapper); } // --------------------------------------------------------------------------------------------- @@ -140,17 +143,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link GetTasksResponse}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Boolean completed; - - private Info task; - - @Nullable - private Status response; - @Nullable private ErrorCause error; + @Nullable + private TaskResponse response; + private TaskInfo task; /** * Required - API name: {@code completed} @@ -161,24 +160,24 @@ public final Builder completed(boolean value) { } /** - * Required - API name: {@code task} + * API name: {@code error} */ - public final Builder task(Info value) { - this.task = value; + public final Builder error(@Nullable ErrorCause value) { + this.error = value; return this; } /** - * Required - API name: {@code task} + * API name: {@code error} */ - public final Builder task(Function> fn) { - return this.task(fn.apply(new Info.Builder()).build()); + public final Builder error(Function> fn) { + return error(fn.apply(new ErrorCause.Builder()).build()); } /** * API name: {@code response} */ - public final Builder response(@Nullable Status value) { + public final Builder response(@Nullable TaskResponse value) { this.response = value; return this; } @@ -186,30 +185,29 @@ public final Builder response(@Nullable Status value) { /** * API name: {@code response} */ - public final Builder response(Function> fn) { - return this.response(fn.apply(new Status.Builder()).build()); + public final Builder response(Function> fn) { + return response(fn.apply(new TaskResponse.Builder()).build()); } /** - * API name: {@code error} + * Required - API name: {@code task} */ - public final Builder error(@Nullable ErrorCause value) { - this.error = value; + public final Builder task(TaskInfo value) { + this.task = value; return this; } /** - * API name: {@code error} + * Required - API name: {@code task} */ - public final Builder error(Function> fn) { - return this.error(fn.apply(new ErrorCause.Builder()).build()); + public final Builder task(Function> fn) { + return task(fn.apply(new TaskInfo.Builder()).build()); } /** * Builds a {@link GetTasksResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public GetTasksResponse build() { _checkSingleUse(); @@ -229,12 +227,9 @@ public GetTasksResponse build() { ); protected static void setupGetTasksResponseDeserializer(ObjectDeserializer op) { - op.add(Builder::completed, JsonpDeserializer.booleanDeserializer(), "completed"); - op.add(Builder::task, Info._DESERIALIZER, "task"); - op.add(Builder::response, Status._DESERIALIZER, "response"); op.add(Builder::error, ErrorCause._DESERIALIZER, "error"); - + op.add(Builder::response, TaskResponse._DESERIALIZER, "response"); + op.add(Builder::task, TaskInfo._DESERIALIZER, "task"); } - } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java similarity index 75% rename from java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java index be136b62ec..520cc219e7 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java @@ -51,13 +51,20 @@ * Client for the tasks namespace. */ @Generated("org.opensearch.client.codegen.CodeGenerator") -public abstract class OpenSearchTasksAsyncClientBase> extends ApiClient< - OpenSearchTransport, - Self> { - public OpenSearchTasksAsyncClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { +public class OpenSearchTasksAsyncClient extends ApiClient { + public OpenSearchTasksAsyncClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchTasksAsyncClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { super(transport, transportOptions); } + @Override + public OpenSearchTasksAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchTasksAsyncClient(this.transport, transportOptions); + } + // ----- Endpoint: tasks.cancel /** @@ -84,6 +91,25 @@ public final CompletableFuture cancel() throws IOException, Open return cancel(new CancelRequest.Builder().build()); } + // ----- Endpoint: tasks.get + + /** + * Returns information about a task. + */ + public CompletableFuture get(GetTasksRequest request) throws IOException, OpenSearchException { + return this.transport.performRequestAsync(request, GetTasksRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about a task. + * + * @param fn a function that initializes a builder to create the {@link GetTasksRequest} + */ + public final CompletableFuture get(Function> fn) + throws IOException, OpenSearchException { + return get(fn.apply(new GetTasksRequest.Builder()).build()); + } + // ----- Endpoint: tasks.list /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java similarity index 75% rename from java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java index 0ce1d56603..3ee39153a4 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java @@ -50,11 +50,20 @@ * Client for the tasks namespace. */ @Generated("org.opensearch.client.codegen.CodeGenerator") -public abstract class OpenSearchTasksClientBase> extends ApiClient { - public OpenSearchTasksClientBase(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { +public class OpenSearchTasksClient extends ApiClient { + public OpenSearchTasksClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchTasksClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { super(transport, transportOptions); } + @Override + public OpenSearchTasksClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchTasksClient(this.transport, transportOptions); + } + // ----- Endpoint: tasks.cancel /** @@ -81,6 +90,25 @@ public final CancelResponse cancel() throws IOException, OpenSearchException { return cancel(new CancelRequest.Builder().build()); } + // ----- Endpoint: tasks.get + + /** + * Returns information about a task. + */ + public GetTasksResponse get(GetTasksRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, GetTasksRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about a task. + * + * @param fn a function that initializes a builder to create the {@link GetTasksRequest} + */ + public final GetTasksResponse get(Function> fn) throws IOException, + OpenSearchException { + return get(fn.apply(new GetTasksRequest.Builder()).build()); + } + // ----- Endpoint: tasks.list /** diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskResponse.java new file mode 100644 index 0000000000..80edbb43d0 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/tasks/TaskResponse.java @@ -0,0 +1,721 @@ +/* + * 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. + */ + +/* + * 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.tasks; + +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.BulkByScrollFailure; +import org.opensearch.client.opensearch._types.BulkByScrollTaskStatusOrException; +import org.opensearch.client.opensearch._types.Retries; +import org.opensearch.client.opensearch._types.Time; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; + +// typedef: tasks.TaskResponse + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class TaskResponse implements PlainJsonSerializable { + + private final int batches; + + @Nullable + private final String canceled; + + @Nullable + private final Long created; + + private final long deleted; + + private final List failures; + + private final long noops; + + private final float requestsPerSecond; + + private final Retries retries; + + @Nullable + private final Integer sliceId; + + private final List slices; + + @Nullable + private final Time throttled; + + private final long throttledMillis; + + @Nullable + private final Time throttledUntil; + + private final long throttledUntilMillis; + + private final boolean timedOut; + + private final long took; + + private final long total; + + @Nullable + private final Long updated; + + private final long versionConflicts; + + // --------------------------------------------------------------------------------------------- + + private TaskResponse(Builder builder) { + this.batches = ApiTypeHelper.requireNonNull(builder.batches, this, "batches"); + this.canceled = builder.canceled; + this.created = builder.created; + this.deleted = ApiTypeHelper.requireNonNull(builder.deleted, this, "deleted"); + this.failures = ApiTypeHelper.unmodifiableRequired(builder.failures, this, "failures"); + this.noops = ApiTypeHelper.requireNonNull(builder.noops, this, "noops"); + this.requestsPerSecond = ApiTypeHelper.requireNonNull(builder.requestsPerSecond, this, "requestsPerSecond"); + this.retries = ApiTypeHelper.requireNonNull(builder.retries, this, "retries"); + this.sliceId = builder.sliceId; + this.slices = ApiTypeHelper.unmodifiable(builder.slices); + this.throttled = builder.throttled; + this.throttledMillis = ApiTypeHelper.requireNonNull(builder.throttledMillis, this, "throttledMillis"); + this.throttledUntil = builder.throttledUntil; + this.throttledUntilMillis = ApiTypeHelper.requireNonNull(builder.throttledUntilMillis, this, "throttledUntilMillis"); + this.timedOut = ApiTypeHelper.requireNonNull(builder.timedOut, this, "timedOut"); + this.took = ApiTypeHelper.requireNonNull(builder.took, this, "took"); + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); + this.updated = builder.updated; + this.versionConflicts = ApiTypeHelper.requireNonNull(builder.versionConflicts, this, "versionConflicts"); + } + + public static TaskResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The number of scroll responses pulled back by the reindex. + *

+ * API name: {@code batches} + *

+ */ + public final int batches() { + return this.batches; + } + + /** + * API name: {@code canceled} + */ + @Nullable + public final String canceled() { + return this.canceled; + } + + /** + * The number of documents that were successfully created. + *

+ * API name: {@code created} + *

+ */ + @Nullable + public final Long created() { + return this.created; + } + + /** + * Required - The number of documents that were successfully deleted. + *

+ * API name: {@code deleted} + *

+ */ + public final long deleted() { + return this.deleted; + } + + /** + * Required - API name: {@code failures} + */ + public final List failures() { + return this.failures; + } + + /** + * Required - The number of documents that were ignored. + *

+ * API name: {@code noops} + *

+ */ + public final long noops() { + return this.noops; + } + + /** + * Required - The number of requests per second effectively executed during the reindex. + *

+ * API name: {@code requests_per_second} + *

+ */ + public final float requestsPerSecond() { + return this.requestsPerSecond; + } + + /** + * Required - API name: {@code retries} + */ + public final Retries retries() { + return this.retries; + } + + /** + * API name: {@code slice_id} + */ + @Nullable + public final Integer sliceId() { + return this.sliceId; + } + + /** + * API name: {@code slices} + */ + public final List slices() { + return this.slices; + } + + /** + * API name: {@code throttled} + */ + @Nullable + public final Time throttled() { + return this.throttled; + } + + /** + * Required - API name: {@code throttled_millis} + */ + public final long throttledMillis() { + return this.throttledMillis; + } + + /** + * API name: {@code throttled_until} + */ + @Nullable + public final Time throttledUntil() { + return this.throttledUntil; + } + + /** + * Required - API name: {@code throttled_until_millis} + */ + public final long throttledUntilMillis() { + return this.throttledUntilMillis; + } + + /** + * Required - API name: {@code timed_out} + */ + public final boolean timedOut() { + return this.timedOut; + } + + /** + * Required - API name: {@code took} + */ + public final long took() { + return this.took; + } + + /** + * Required - The number of documents that were successfully processed. + *

+ * API name: {@code total} + *

+ */ + public final long total() { + return this.total; + } + + /** + * The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex + * updating it. + *

+ * API name: {@code updated} + *

+ */ + @Nullable + public final Long updated() { + return this.updated; + } + + /** + * Required - The number of version conflicts that reindex hits. + *

+ * API name: {@code version_conflicts} + *

+ */ + public final long versionConflicts() { + return this.versionConflicts; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey("batches"); + generator.write(this.batches); + + if (this.canceled != null) { + generator.writeKey("canceled"); + generator.write(this.canceled); + } + + if (this.created != null) { + generator.writeKey("created"); + generator.write(this.created); + } + + generator.writeKey("deleted"); + generator.write(this.deleted); + + generator.writeKey("failures"); + generator.writeStartArray(); + for (BulkByScrollFailure item0 : this.failures) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + + generator.writeKey("noops"); + generator.write(this.noops); + + generator.writeKey("requests_per_second"); + generator.write(this.requestsPerSecond); + + generator.writeKey("retries"); + this.retries.serialize(generator, mapper); + + if (this.sliceId != null) { + generator.writeKey("slice_id"); + generator.write(this.sliceId); + } + + if (ApiTypeHelper.isDefined(this.slices)) { + generator.writeKey("slices"); + generator.writeStartArray(); + for (BulkByScrollTaskStatusOrException item0 : this.slices) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.throttled != null) { + generator.writeKey("throttled"); + this.throttled.serialize(generator, mapper); + } + + generator.writeKey("throttled_millis"); + generator.write(this.throttledMillis); + + if (this.throttledUntil != null) { + generator.writeKey("throttled_until"); + this.throttledUntil.serialize(generator, mapper); + } + + generator.writeKey("throttled_until_millis"); + generator.write(this.throttledUntilMillis); + + generator.writeKey("timed_out"); + generator.write(this.timedOut); + + generator.writeKey("took"); + generator.write(this.took); + + generator.writeKey("total"); + generator.write(this.total); + + if (this.updated != null) { + generator.writeKey("updated"); + generator.write(this.updated); + } + + generator.writeKey("version_conflicts"); + generator.write(this.versionConflicts); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link TaskResponse}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Integer batches; + @Nullable + private String canceled; + @Nullable + private Long created; + private Long deleted; + private List failures; + private Long noops; + private Float requestsPerSecond; + private Retries retries; + @Nullable + private Integer sliceId; + @Nullable + private List slices; + @Nullable + private Time throttled; + private Long throttledMillis; + @Nullable + private Time throttledUntil; + private Long throttledUntilMillis; + private Boolean timedOut; + private Long took; + private Long total; + @Nullable + private Long updated; + private Long versionConflicts; + + /** + * Required - The number of scroll responses pulled back by the reindex. + *

+ * API name: {@code batches} + *

+ */ + public final Builder batches(int value) { + this.batches = value; + return this; + } + + /** + * API name: {@code canceled} + */ + public final Builder canceled(@Nullable String value) { + this.canceled = value; + return this; + } + + /** + * The number of documents that were successfully created. + *

+ * API name: {@code created} + *

+ */ + public final Builder created(@Nullable Long value) { + this.created = value; + return this; + } + + /** + * Required - The number of documents that were successfully deleted. + *

+ * API name: {@code deleted} + *

+ */ + public final Builder deleted(long value) { + this.deleted = value; + return this; + } + + /** + * Required - API name: {@code failures} + * + *

+ * Adds all elements of list to failures. + *

+ */ + public final Builder failures(List list) { + this.failures = _listAddAll(this.failures, list); + return this; + } + + /** + * Required - API name: {@code failures} + * + *

+ * Adds one or more values to failures. + *

+ */ + public final Builder failures(BulkByScrollFailure value, BulkByScrollFailure... values) { + this.failures = _listAdd(this.failures, value, values); + return this; + } + + /** + * Required - API name: {@code failures} + * + *

+ * Adds a value to failures using a builder lambda. + *

+ */ + public final Builder failures(Function> fn) { + return failures(fn.apply(new BulkByScrollFailure.Builder()).build()); + } + + /** + * Required - The number of documents that were ignored. + *

+ * API name: {@code noops} + *

+ */ + public final Builder noops(long value) { + this.noops = value; + return this; + } + + /** + * Required - The number of requests per second effectively executed during the reindex. + *

+ * API name: {@code requests_per_second} + *

+ */ + public final Builder requestsPerSecond(float value) { + this.requestsPerSecond = value; + return this; + } + + /** + * Required - API name: {@code retries} + */ + public final Builder retries(Retries value) { + this.retries = value; + return this; + } + + /** + * Required - API name: {@code retries} + */ + public final Builder retries(Function> fn) { + return retries(fn.apply(new Retries.Builder()).build()); + } + + /** + * API name: {@code slice_id} + */ + public final Builder sliceId(@Nullable Integer value) { + this.sliceId = value; + return this; + } + + /** + * API name: {@code slices} + * + *

+ * Adds all elements of list to slices. + *

+ */ + public final Builder slices(List list) { + this.slices = _listAddAll(this.slices, list); + return this; + } + + /** + * API name: {@code slices} + * + *

+ * Adds one or more values to slices. + *

+ */ + public final Builder slices(BulkByScrollTaskStatusOrException value, BulkByScrollTaskStatusOrException... values) { + this.slices = _listAdd(this.slices, value, values); + return this; + } + + /** + * API name: {@code slices} + * + *

+ * Adds a value to slices using a builder lambda. + *

+ */ + public final Builder slices( + Function> fn + ) { + return slices(fn.apply(new BulkByScrollTaskStatusOrException.Builder()).build()); + } + + /** + * API name: {@code throttled} + */ + public final Builder throttled(@Nullable Time value) { + this.throttled = value; + return this; + } + + /** + * API name: {@code throttled} + */ + public final Builder throttled(Function> fn) { + return throttled(fn.apply(new Time.Builder()).build()); + } + + /** + * Required - API name: {@code throttled_millis} + */ + public final Builder throttledMillis(long value) { + this.throttledMillis = value; + return this; + } + + /** + * API name: {@code throttled_until} + */ + public final Builder throttledUntil(@Nullable Time value) { + this.throttledUntil = value; + return this; + } + + /** + * API name: {@code throttled_until} + */ + public final Builder throttledUntil(Function> fn) { + return throttledUntil(fn.apply(new Time.Builder()).build()); + } + + /** + * Required - API name: {@code throttled_until_millis} + */ + public final Builder throttledUntilMillis(long value) { + this.throttledUntilMillis = value; + return this; + } + + /** + * Required - API name: {@code timed_out} + */ + public final Builder timedOut(boolean value) { + this.timedOut = value; + return this; + } + + /** + * Required - API name: {@code took} + */ + public final Builder took(long value) { + this.took = value; + return this; + } + + /** + * Required - The number of documents that were successfully processed. + *

+ * API name: {@code total} + *

+ */ + public final Builder total(long value) { + this.total = value; + return this; + } + + /** + * The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex + * updating it. + *

+ * API name: {@code updated} + *

+ */ + public final Builder updated(@Nullable Long value) { + this.updated = value; + return this; + } + + /** + * Required - The number of version conflicts that reindex hits. + *

+ * API name: {@code version_conflicts} + *

+ */ + public final Builder versionConflicts(long value) { + this.versionConflicts = value; + return this; + } + + /** + * Builds a {@link TaskResponse}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public TaskResponse build() { + _checkSingleUse(); + + return new TaskResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link TaskResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + TaskResponse::setupTaskResponseDeserializer + ); + + protected static void setupTaskResponseDeserializer(ObjectDeserializer op) { + op.add(Builder::batches, JsonpDeserializer.integerDeserializer(), "batches"); + op.add(Builder::canceled, JsonpDeserializer.stringDeserializer(), "canceled"); + op.add(Builder::created, JsonpDeserializer.longDeserializer(), "created"); + op.add(Builder::deleted, JsonpDeserializer.longDeserializer(), "deleted"); + op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(BulkByScrollFailure._DESERIALIZER), "failures"); + op.add(Builder::noops, JsonpDeserializer.longDeserializer(), "noops"); + op.add(Builder::requestsPerSecond, JsonpDeserializer.floatDeserializer(), "requests_per_second"); + op.add(Builder::retries, Retries._DESERIALIZER, "retries"); + op.add(Builder::sliceId, JsonpDeserializer.integerDeserializer(), "slice_id"); + op.add(Builder::slices, JsonpDeserializer.arrayDeserializer(BulkByScrollTaskStatusOrException._DESERIALIZER), "slices"); + op.add(Builder::throttled, Time._DESERIALIZER, "throttled"); + op.add(Builder::throttledMillis, JsonpDeserializer.longDeserializer(), "throttled_millis"); + op.add(Builder::throttledUntil, Time._DESERIALIZER, "throttled_until"); + op.add(Builder::throttledUntilMillis, JsonpDeserializer.longDeserializer(), "throttled_until_millis"); + op.add(Builder::timedOut, JsonpDeserializer.booleanDeserializer(), "timed_out"); + op.add(Builder::took, JsonpDeserializer.longDeserializer(), "took"); + op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); + op.add(Builder::updated, JsonpDeserializer.longDeserializer(), "updated"); + op.add(Builder::versionConflicts, JsonpDeserializer.longDeserializer(), "version_conflicts"); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/Info.java b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/Info.java deleted file mode 100644 index d2f72fff0d..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/Info.java +++ /dev/null @@ -1,481 +0,0 @@ -/* - * 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. - */ - -/* - * 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. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.tasks; - -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: tasks._types.Info - -@JsonpDeserializable -public class Info implements PlainJsonSerializable { - private final String action; - - private final boolean cancellable; - - private final List children; - - @Nullable - private final String description; - - private final Map> headers; - - private final long id; - - private final String node; - - private final long runningTimeInNanos; - - private final long startTimeInMillis; - - @Nullable - private final Status status; - - private final String type; - - @Nullable - private final String parentTaskId; - - // --------------------------------------------------------------------------------------------- - - private Info(Builder builder) { - - this.action = ApiTypeHelper.requireNonNull(builder.action, this, "action"); - this.cancellable = ApiTypeHelper.requireNonNull(builder.cancellable, this, "cancellable"); - this.children = ApiTypeHelper.unmodifiable(builder.children); - this.description = builder.description; - this.headers = ApiTypeHelper.unmodifiableRequired(builder.headers, this, "headers"); - this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); - this.node = ApiTypeHelper.requireNonNull(builder.node, this, "node"); - this.runningTimeInNanos = ApiTypeHelper.requireNonNull(builder.runningTimeInNanos, this, "runningTimeInNanos"); - this.startTimeInMillis = ApiTypeHelper.requireNonNull(builder.startTimeInMillis, this, "startTimeInMillis"); - this.status = builder.status; - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - this.parentTaskId = builder.parentTaskId; - - } - - public static Info of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code action} - */ - public final String action() { - return this.action; - } - - /** - * Required - API name: {@code cancellable} - */ - public final boolean cancellable() { - return this.cancellable; - } - - /** - * API name: {@code children} - */ - public final List children() { - return this.children; - } - - /** - * API name: {@code description} - */ - @Nullable - public final String description() { - return this.description; - } - - /** - * Required - API name: {@code headers} - */ - public final Map> headers() { - return this.headers; - } - - /** - * Required - API name: {@code id} - */ - public final long id() { - return this.id; - } - - /** - * Required - API name: {@code node} - */ - public final String node() { - return this.node; - } - - /** - * Required - API name: {@code running_time_in_nanos} - */ - public final long runningTimeInNanos() { - return this.runningTimeInNanos; - } - - /** - * Required - API name: {@code start_time_in_millis} - */ - public final long startTimeInMillis() { - return this.startTimeInMillis; - } - - /** - * API name: {@code status} - */ - @Nullable - public final Status status() { - return this.status; - } - - /** - * Required - API name: {@code type} - */ - public final String type() { - return this.type; - } - - /** - * API name: {@code parent_task_id} - */ - @Nullable - public final String parentTaskId() { - return this.parentTaskId; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("action"); - generator.write(this.action); - - generator.writeKey("cancellable"); - generator.write(this.cancellable); - - if (ApiTypeHelper.isDefined(this.children)) { - generator.writeKey("children"); - generator.writeStartArray(); - for (Info item0 : this.children) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - } - if (this.description != null) { - generator.writeKey("description"); - generator.write(this.description); - - } - if (ApiTypeHelper.isDefined(this.headers)) { - generator.writeKey("headers"); - generator.writeStartObject(); - for (Map.Entry> item0 : this.headers.entrySet()) { - generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (String item1 : item0.getValue()) { - generator.write(item1); - - } - } - generator.writeEnd(); - - } - generator.writeEnd(); - - } - generator.writeKey("id"); - generator.write(this.id); - - generator.writeKey("node"); - generator.write(this.node); - - generator.writeKey("running_time_in_nanos"); - generator.write(this.runningTimeInNanos); - - generator.writeKey("start_time_in_millis"); - generator.write(this.startTimeInMillis); - - if (this.status != null) { - generator.writeKey("status"); - this.status.serialize(generator, mapper); - - } - generator.writeKey("type"); - generator.write(this.type); - - if (this.parentTaskId != null) { - generator.writeKey("parent_task_id"); - generator.write(this.parentTaskId); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link Info}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String action; - - private Boolean cancellable; - - @Nullable - private List children; - - @Nullable - private String description; - - private Map> headers; - - private Long id; - - private String node; - - private Long runningTimeInNanos; - - private Long startTimeInMillis; - - @Nullable - private Status status; - - private String type; - - @Nullable - private String parentTaskId; - - /** - * Required - API name: {@code action} - */ - public final Builder action(String value) { - this.action = value; - return this; - } - - /** - * Required - API name: {@code cancellable} - */ - public final Builder cancellable(boolean value) { - this.cancellable = value; - return this; - } - - /** - * API name: {@code children} - *

- * Adds all elements of list to children. - */ - public final Builder children(List list) { - this.children = _listAddAll(this.children, list); - return this; - } - - /** - * API name: {@code children} - *

- * Adds one or more values to children. - */ - public final Builder children(Info value, Info... values) { - this.children = _listAdd(this.children, value, values); - return this; - } - - /** - * API name: {@code children} - *

- * Adds a value to children using a builder lambda. - */ - public final Builder children(Function> fn) { - return children(fn.apply(new Info.Builder()).build()); - } - - /** - * API name: {@code description} - */ - public final Builder description(@Nullable String value) { - this.description = value; - return this; - } - - /** - * Required - API name: {@code headers} - *

- * Adds all entries of map to headers. - */ - public final Builder headers(Map> map) { - this.headers = _mapPutAll(this.headers, map); - return this; - } - - /** - * Required - API name: {@code headers} - *

- * Adds an entry to headers. - */ - public final Builder headers(String key, List value) { - this.headers = _mapPut(this.headers, key, value); - return this; - } - - /** - * Required - API name: {@code id} - */ - public final Builder id(long value) { - this.id = value; - return this; - } - - /** - * Required - API name: {@code node} - */ - public final Builder node(String value) { - this.node = value; - return this; - } - - /** - * Required - API name: {@code running_time_in_nanos} - */ - public final Builder runningTimeInNanos(long value) { - this.runningTimeInNanos = value; - return this; - } - - /** - * Required - API name: {@code start_time_in_millis} - */ - public final Builder startTimeInMillis(long value) { - this.startTimeInMillis = value; - return this; - } - - /** - * API name: {@code status} - */ - public final Builder status(@Nullable Status value) { - this.status = value; - return this; - } - - /** - * API name: {@code status} - */ - public final Builder status(Function> fn) { - return this.status(fn.apply(new Status.Builder()).build()); - } - - /** - * Required - API name: {@code type} - */ - public final Builder type(String value) { - this.type = value; - return this; - } - - /** - * API name: {@code parent_task_id} - */ - public final Builder parentTaskId(@Nullable String value) { - this.parentTaskId = value; - return this; - } - - /** - * Builds a {@link Info}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public Info build() { - _checkSingleUse(); - - return new Info(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link Info} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, Info::setupInfoDeserializer); - - protected static void setupInfoDeserializer(ObjectDeserializer op) { - - op.add(Builder::action, JsonpDeserializer.stringDeserializer(), "action"); - op.add(Builder::cancellable, JsonpDeserializer.booleanDeserializer(), "cancellable"); - op.add(Builder::children, JsonpDeserializer.arrayDeserializer(Info._DESERIALIZER), "children"); - op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description"); - op.add( - Builder::headers, - JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer())), - "headers" - ); - op.add(Builder::id, JsonpDeserializer.longDeserializer(), "id"); - op.add(Builder::node, JsonpDeserializer.stringDeserializer(), "node"); - op.add(Builder::runningTimeInNanos, JsonpDeserializer.longDeserializer(), "running_time_in_nanos"); - op.add(Builder::startTimeInMillis, JsonpDeserializer.longDeserializer(), "start_time_in_millis"); - op.add(Builder::status, Status._DESERIALIZER, "status"); - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - op.add(Builder::parentTaskId, JsonpDeserializer.stringDeserializer(), "parent_task_id"); - - } - -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java deleted file mode 100644 index dc58027f8b..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksAsyncClient.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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. - */ - -/* - * 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. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.tasks; - -import java.io.IOException; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.opensearch._types.ErrorResponse; -import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; -import org.opensearch.client.transport.OpenSearchTransport; -import org.opensearch.client.transport.TransportOptions; -import org.opensearch.client.util.ObjectBuilder; - -/** - * Client for the tasks namespace. - */ -public class OpenSearchTasksAsyncClient extends OpenSearchTasksAsyncClientBase { - - public OpenSearchTasksAsyncClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchTasksAsyncClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchTasksAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchTasksAsyncClient(this.transport, transportOptions); - } - - // ----- Endpoint: tasks.get - - /** - * Returns information about a task. - * - * - */ - - public CompletableFuture get(GetTasksRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetTasksRequest, - GetTasksResponse, - ErrorResponse>) GetTasksRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about a task. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetTasksRequest} - * - */ - - public final CompletableFuture get(Function> fn) - throws IOException, OpenSearchException { - return get(fn.apply(new GetTasksRequest.Builder()).build()); - } -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java deleted file mode 100644 index 11c8add97f..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/tasks/OpenSearchTasksClient.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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. - */ - -/* - * 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. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.tasks; - -import java.io.IOException; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.opensearch._types.ErrorResponse; -import org.opensearch.client.opensearch._types.OpenSearchException; -import org.opensearch.client.transport.JsonEndpoint; -import org.opensearch.client.transport.OpenSearchTransport; -import org.opensearch.client.transport.TransportOptions; -import org.opensearch.client.util.ObjectBuilder; - -/** - * Client for the tasks namespace. - */ -public class OpenSearchTasksClient extends OpenSearchTasksClientBase { - - public OpenSearchTasksClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchTasksClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchTasksClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchTasksClient(this.transport, transportOptions); - } - - // ----- Endpoint: tasks.get - - /** - * Returns information about a task. - * - * - */ - - public GetTasksResponse get(GetTasksRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetTasksRequest, - GetTasksResponse, - ErrorResponse>) GetTasksRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about a task. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetTasksRequest} - * - */ - - public final GetTasksResponse get(Function> fn) throws IOException, - OpenSearchException { - return get(fn.apply(new GetTasksRequest.Builder()).build()); - } -} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java index 6773ef3dcb..b1eaa8d06b 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java @@ -44,7 +44,7 @@ public class CodeGenerator { and(namespace(""), named("info")), namespace("dangling_indices"), and(namespace("ml"), not(named("search_models"))), // TODO: search_models is complex and ideally should re-use the search structures - and(namespace("tasks"), named("cancel", "list")) + and(namespace("tasks")) ); public static void main(String[] args) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java index e29fc558cf..e0e3861bcc 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java @@ -23,7 +23,7 @@ import org.opensearch.client.codegen.utils.Strings; public class Namespace { - private static final Set PARTIAL_NAMESPACES = Set.of("", "tasks"); + private static final Set PARTIAL_NAMESPACES = Set.of(""); private final Namespace parent; private final String name; From e25ec82902d190ab25d2cfdc001b428105ed468f Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 9 Sep 2024 16:52:41 +1200 Subject: [PATCH 10/11] spotless Signed-off-by: Thomas Farr --- .../opensearch/core/DeleteByQueryRethrottleResponse.java | 5 +++-- .../java/org/opensearch/client/codegen/model/Shape.java | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/DeleteByQueryRethrottleResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/DeleteByQueryRethrottleResponse.java index 3880fe3604..4ceb7faa26 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/DeleteByQueryRethrottleResponse.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/DeleteByQueryRethrottleResponse.java @@ -37,7 +37,6 @@ import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.opensearch.tasks.ListResponse; import org.opensearch.client.opensearch.tasks.TaskListResponseBase; import org.opensearch.client.util.ObjectBuilder; @@ -62,7 +61,9 @@ public static DeleteByQueryRethrottleResponse of(Function implements ObjectBuilder { + public static class Builder extends TaskListResponseBase.AbstractBuilder + implements + ObjectBuilder { @Override protected Builder self() { return this; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java index 52f9d4c3be..c44c8d72d9 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java @@ -55,7 +55,11 @@ public JavaClassKind getClassKind() { } public boolean isAbstract() { - var refKinds = incomingReferences.entrySet().stream().filter(e -> !e.getValue().isEmpty()).map(Map.Entry::getKey).collect(Collectors.toSet()); + var refKinds = incomingReferences.entrySet() + .stream() + .filter(e -> !e.getValue().isEmpty()) + .map(Map.Entry::getKey) + .collect(Collectors.toSet()); return !refKinds.isEmpty() && refKinds.stream().noneMatch(ReferenceKind::isConcreteUsage); } From ff5a99a02e01ca11210c5303b3ae2afa20608946 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Mon, 9 Sep 2024 17:09:13 +1200 Subject: [PATCH 11/11] Fixes Signed-off-by: Thomas Farr --- CHANGELOG.md | 6 ++++-- UPGRADING.md | 1 + .../UpdateByQueryRethrottleNode.java | 20 +++++++++---------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12fdec3acd..1489b7d53c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased 3.0] ### Dependencies -- Bumps `org.junit:junit-bom` from 5.10.2 to 5.11.0 - Bumps `org.owasp.dependencycheck` from 10.0.2 to 10.0.4 - Bumps `org.eclipse.parsson:parsson` from 1.1.6 to 1.1.7 - Bumps `org.hamcrest:hamcrest` from 2.2 to 3.0 @@ -21,6 +20,7 @@ This section is for maintaining a changelog for all breaking changes for the cli - Changed SearchAfter of SearchRequest type to FieldValue instead of String ([#769](https://github.com/opensearch-project/opensearch-java/pull/769)) - Changed type of `DanglingIndex`'s `creationDateMillis` field from `String` to `long` ([#1124](https://github.com/opensearch-project/opensearch-java/pull/1124)) - Changed type of `ShardStatistics`'s `total`, `successful`, `failed` & `skipped` fields from `Number` to `int/Integer` ([#1158](https://github.com/opensearch-project/opensearch-java/pull/1158)) +- Unified `tasks.Info` and `tasks.State` classes into `tasks.TaskInfo` ([#1187](https://github.com/opensearch-project/opensearch-java/pull/1187)) ### Deprecated - Deprecate RestClientTransport ([#536](https://github.com/opensearch-project/opensearch-java/pull/536)) @@ -29,7 +29,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Fixed - Fix version and build ([#254](https://github.com/opensearch-project/opensearch-java/pull/254)) -- Fix queries not preserving boost and name when converted to builders ([#1181](https://github.com/opensearch-project/opensearch-java/pull/1181)) +- Fixed deserializing `tasks.ListResponse` when using `GroupBy.None` ([#1187](https://github.com/opensearch-project/opensearch-java/pull/1187)) ### Security @@ -38,6 +38,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Added ### Dependencies +- Bumps `org.junit:junit-bom` from 5.10.3 to 5.11.0 ### Changed @@ -46,6 +47,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Removed ### Fixed +- Fix queries not preserving boost and name when converted to builders ([#1181](https://github.com/opensearch-project/opensearch-java/pull/1181)) ### Security diff --git a/UPGRADING.md b/UPGRADING.md index e2047ad692..e59cba1254 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -33,6 +33,7 @@ After: - The `tasks.Info` and `tasks.State` classes have been unified into `tasks.TaskInfo`, this affects: - `TaskExecutingNode`'s `tasks` field. - `GetTasksResponse`'s `task` field. + - `core.update_by_query_rethrottle.UpdateByQueryRethrottleNode`'s `tasks` field. - The `headers` field is now a `Map` instead of a `Map>`. ### tasks.ListResponse properties lifted to tasks.TaskListResponseBase diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/update_by_query_rethrottle/UpdateByQueryRethrottleNode.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/update_by_query_rethrottle/UpdateByQueryRethrottleNode.java index bbb2f678d9..d79457067e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/update_by_query_rethrottle/UpdateByQueryRethrottleNode.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/update_by_query_rethrottle/UpdateByQueryRethrottleNode.java @@ -41,7 +41,7 @@ import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.opensearch._types.BaseNode; -import org.opensearch.client.opensearch.tasks.Info; +import org.opensearch.client.opensearch.tasks.TaskInfo; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; @@ -49,7 +49,7 @@ @JsonpDeserializable public class UpdateByQueryRethrottleNode extends BaseNode { - private final Map tasks; + private final Map tasks; // --------------------------------------------------------------------------------------------- @@ -67,7 +67,7 @@ public static UpdateByQueryRethrottleNode of(Function tasks() { + public final Map tasks() { return this.tasks; } @@ -77,7 +77,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.tasks)) { generator.writeKey("tasks"); generator.writeStartObject(); - for (Map.Entry item0 : this.tasks.entrySet()) { + for (Map.Entry item0 : this.tasks.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); @@ -95,14 +95,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { */ public static class Builder extends BaseNode.AbstractBuilder implements ObjectBuilder { - private Map tasks; + private Map tasks; /** * Required - API name: {@code tasks} *

* Adds all entries of map to tasks. */ - public final Builder tasks(Map map) { + public final Builder tasks(Map map) { this.tasks = _mapPutAll(this.tasks, map); return this; } @@ -112,7 +112,7 @@ public final Builder tasks(Map map) { *

* Adds an entry to tasks. */ - public final Builder tasks(String key, Info value) { + public final Builder tasks(String key, TaskInfo value) { this.tasks = _mapPut(this.tasks, key, value); return this; } @@ -122,8 +122,8 @@ public final Builder tasks(String key, Info value) { *

* Adds an entry to tasks using a builder lambda. */ - public final Builder tasks(String key, Function> fn) { - return tasks(key, fn.apply(new Info.Builder()).build()); + public final Builder tasks(String key, Function> fn) { + return tasks(key, fn.apply(new TaskInfo.Builder()).build()); } @Override @@ -156,7 +156,7 @@ public UpdateByQueryRethrottleNode build() { protected static void setupUpdateByQueryRethrottleNodeDeserializer(ObjectDeserializer op) { BaseNode.setupBaseNodeDeserializer(op); - op.add(Builder::tasks, JsonpDeserializer.stringMapDeserializer(Info._DESERIALIZER), "tasks"); + op.add(Builder::tasks, JsonpDeserializer.stringMapDeserializer(TaskInfo._DESERIALIZER), "tasks"); }